Archive for February, 2010

Email PHP Errors Plugin

Tuesday, February 23rd, 2010

I wrote a plugin that notifies me of PHP errors in my WordPress sites. I set it initially to send everything up to E_NOTICE and received over 500 messages in two minutes.

If you want to use this, the first thing you want to do is turn on PHP5. WordPress will work with PHP4 in most cases, but it generates a huge number of notices, especially where it uses HTML_entities functions. Whoever wrote these parts of WordPress was not aware of the various flavors in these functions.

I also received a large number of reports that an index was not found. The code should use an if (array_key_exists(..)) whenever it accesses an array, even $_GET or $_POST. The E_NOTICE is thrown, slowing things down and adding to the errors reported.

I found large numbers of errors in supposedly “premium” themes. They consistently refer to variables which have not been defined – perhaps they did exist in older versions of WordPress.

I found an error in one of my own plugins. It tried to load HTTP_REFERER, without checking to see it it was in the server array. I need to fix that, even though it does not show an error, I should fix the E_NOTICE being thrown.

If you use this, turn it on for 30 seconds and then turn it off. If it is a new without traffic, then hit the site once or twice, exercising the code and then quickly deactivate the plugin.