Environmental Awareness Quickie

I ran into an instance recently where someone was trying to run Phergie in an environment where the exec function was disabled. This causes a warning in the Quit plugin, which uses exec to automatically detect the full path to the PHP CLI binary on non-Windows systems that it will later use that path to initiate a new PHP CLI process to “restart” the bot.

I realized when I started digging into this issue that I wasn’t aware of a way to check the PHP configuration to see whether or not a function was disabled, save for using the ini_get function to get the value of the disable_functions setting and parse it manually.

Thanks to Johannes Schlüter for cluing me into the fact that the SPL ReflectionFunction class has an isDisabled method, which is exactly what I was looking for. Unfortunately, there’s no equivalent method in the SPL ReflectionClass class for the disable_classes setting. Thankfully, though, I haven’t run into a use case for that yet.

Update: Apparently I inspired Johannes to write a patch to add ReflectionClass::isDisabled(). It most likely won’t make it in until 5.3.1, but at least the patch is there if you need the feature. Thanks Johannes!

One Comment

  1. …t/” title=”View all posts in Development” rel=”category tag”>Development Matthew Turland came across someone having an issue running his PHP-based IRC bot (Phergie) a…