WordPress and Suppressed Errors

One of the errors found by the Error Reporting plugin was an E_WARNING thrown by the constant() function. Upon investigation, it was discovered that the core file had the function call prefixed with the "@" error control operator. The log file also contained a few database function errors. The corresponding lines for those were found to have the error control operator prefixed to the calls as well.

Curious, I decided to see just how often error suppression was used in WordPress core files. After what proved to be a tedious undertaking, the error control operator was found in 53 files, including 26 under the wp-admin folder, and occurred anywhere from only once up to 146 times per file. No doubt, as the search was not thorough, some were not found.

What does the PHP documentation have to say? From Error Control Operators:

Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why.

I imagine that if any of the core files caused such an event, there would be a large number of "I get a blank screen" complaints almost as soon as a version was released. Still, the number of variables, objects, PHP functions and WordPress functions is quite extensive.

I agree that it is better to suppress errors than to show them in a live blog. They would only confuse most visitors, and there's no need to help the script kiddies. And I also agree that although it might be preferrable to deal with errors in a better fashion, it is not always possible, especially as WordPress still supports PHP version 4. Yet, I can't help but think that in some cases at least, the code could be written differently without the need to suppress an error. I also have mixed feelings about the use of them in files under the wp-admin folder. On the one hand, presumably only an authorized admin would see them, and could benefit from seeing them, if and when they happened. On the other hand, every level of security, even by obscurity, is a good thing.

Technorati Tags: ,


  1. Posted September 5, 2009 at 1:39 am | Permalink


    Thanks for the article…I have been having issue of blank screen for a while now…If I do not have any plugins on my wp 2.8 then it works…but if I enable some plugins like supercache, related posts the it starts giving blank pages for tag pages…Only Tag pages not categories nor single pages. I am using Thesis framework and have been unable to resolve this issue for last 3 months.
    Please help

  2. Posted September 5, 2009 at 1:43 pm | Permalink

    Hi arun,

    If you try a different theme do you still have the same problem? If not, contacting the theme author and asking for support is probably your best bet.

    You could also try my Error Reporting plugin set to include the wp-contents folder. Then you may be able to spot the cause and fix it.