1

In php.ini, my error display settings are as follows:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
display_errors  = Off

which works for any normally called file, however, if a file is called using jQuery/AJAX, I receive errors such as:

Strict Standards: Non-static method XML_Util::replaceEntities() should not be called statically, assuming $this from incompatible context in /usr/lib/php/XML/Util.php on line 664

Strict Standards: Non-static method XML_Util::createTagFromArray() should not be called statically, assuming $this from incompatible context in /home/site/public_html/site/paypal/lib/Serializer/Serializer.php on line 1231

Strict Standards: Non-static method XML_Util::attributesToString() should not be called statically, assuming $this from incompatible context in /usr/lib/php/XML/Util.php on line 652

As can be assumed, this is breaking parts of my website, how can I fix this?

I am running PHP 5.4.10

The files are being called using Jquery functions: $.get or $.post

Community
  • 1
  • 1
JimmyBanks
  • 4,178
  • 8
  • 45
  • 72
  • Where is `display_errors = Off` set from? If it's not in the `ini`, it should be at all relevant entry-points (or in the front-controller) – John Dvorak Jan 03 '13 at 01:40
  • Did you set it in the correct php.ini? Check the output of `phpinfo()` or `php -i` to see _which_ php.ini is being called. – Michael Berkowski Jan 05 '13 at 13:32
  • 3
    Unrelated but why the hell would you disable `E_NOTICE`? If you get notices it usually means your code is bad and should be fixed... – ThiefMaster Jan 05 '13 at 13:32
  • @ThiefMaster This is for the production site, errors are on for the dev/test site. – JimmyBanks Jan 05 '13 at 19:17
  • Even in production you should keep E_NOTICE enabled - just with display_errors=off and errors going to syslog. – ThiefMaster Jan 05 '13 at 20:56

1 Answers1

1

The code/library you are using is triggering a Strict Standards error/notice/warning.

The related error-reporting constant for it is called E_STRICTDocs which was introduced in PHP 5.0Docs.

Since PHP 5.4 E_STRICT is part of E_ALL, so it has to be removed from it as well if you configure the way you do:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
                                                    ^^^^^^^^^^^

So if you exclude E_STRICT from your production error settings, these Strict Standards errors should not be logged any longer - which would be probably like you would have had it with your earlier PHP 5.3 version.

Additionally you should contact the vendor of the library and request to make the code E_STRICT compatible. This is good practice and also shows you that some code has a certain quality.

For your development you should equally make your code E_STRICT compatible, fixing any place that is causing a Strict Standards error.

Same applies to E_NOTICE and E_DEPRECATED, you should enable these messages in your development environment and fix all the reported problems. This saves you from getting more and more bugs too easily.

From the php.ini:

;;;;;;;;;;;;;;;;;;;
; Quick Reference ;
;;;;;;;;;;;;;;;;;;;
; The following are all the settings which are different in either the production
; or development versions of the INIs with respect to PHP's default behavior.
; Please see the actual settings later in the document for more details as to why
; we recommend these changes in PHP's behavior.

...

; error_reporting
;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
;   Development Value: E_ALL
;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

The reason why you see the error messages outputted instead of logged is not clear from the information you provide in your question. This can have multiple reasons,

  • most straight forward because you have not properly disabled display of errors - or enabled it again in the runtime (that setting can be changed from within PHP code, too).
  • error display is disabled but there is some error handlerDocs that is displaying them anyway.

So apart from the error level setting, this part of your question requires more trouble-shooting on your end to find out why the error messages are being displayed.


See Also:

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836