#272 MRBS clobbers error_reporting settings

Minor
open
nobody
None
1
2013-08-19
2013-05-22
Brian De Wolf
No

After upgrading to PHP5.4, we are now seeing lots of PHP Strict Standards errors in our logs from MRBS on our production box. Our production box's php.ini has this configured for error reporting:

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

This should prevent the log lines from appearing, but MRBS clobbers this value with its own in internalconfig.inc.php, re-enabling E_DEPRECATED and E_STRICT.

Rather than hard-coding the error_reporting value, shouldn't MRBS read the existing one, remove E_NOTICE/E_USER_NOTICE, and set it to that?

Discussion

  • I think it is reasonable that MRBS sets its own reporting level, which is only for the duration of the script. However, you are right that the E_STRICT errors which are included in E_ALL in PHP 5.4 cause unnecessary error log messages. I have therefore fixed this in Rev 2732 in the trunk by adding the lines

    // The Mail and Net libraries generate E_STRICT errors, so disable E_STRICT (which became
    // part of E_ALL in PHP 5.4)
    if (defined("E_STRICT"))
    {
      $error_level = $error_level ^ E_STRICT;
    }
    

    to internalconfig.inc.php

    Campbell

     
  • Brian De Wolf
    Brian De Wolf
    2013-05-29

    Well, what about E_DEPRECATED? I haven't seen messages from it, but some might show up. Also, what if a patch to MRBS introduces errors that would be caught by E_STRICT or E_DEPRECATED (or E_NOTICE)? You won't see it in your dev environment because they are permanently disabled. :(

    As an admin that's paying attention, it's frustrating for MRBS to ignore the system configuration. I'm not even sure MRBS needs to disable E_NOTICE because I have display_errors set to off (are there other reasons I'm not aware of?).

     

  • Anonymous
    2013-08-19

    Campbell, unfortunately your fix is wrong. As you wrote in the comment, E_STRICT became part of E_ALL in PHP 5.4. However, it has been defined all the way back to PHP 5.0 (cf. http://php.net/manual/en/function.error-reporting.php#refsect1-function.error-reporting-changelog). And that's all you check. In other words, the code you wrote enables E_STRICT in any PHP version >= 5.0 and < 5.4, e.g. PHP 5.3.8 as I have here on my test server. Suggested fix (alternatively with E_ALL & E_STRICT > 0 if you want):

    if (defined("E_STRICT") && (E_ALL & E_STRICT))

     
    Last edit: Anonymous 2013-08-19
  • Yes, I realised this, though too late for 1.4.10 unfortunately. A second fix was committed to the trunk in Rev 2746:

    if (defined("E_STRICT"))
    {
      $error_level = $error_level & !E_STRICT;
    }
    

    Campbell

     


Anonymous


Cancel   Add attachments