WordPress: Fixing PHP4 deprecated warnings

I got a nasty little shock when deprecated warnings started popping up everywhere on an old WordPress setup, so it was back to Google-the-shit-out-of-the-error-message mode.

The error messages looked like these:

PHP Deprecated: Assigning the return value of new by reference is deprecated in …

Fix: (via Otto on this thread)
This happens because debug messages are being displayed when PHP5 is running PHP4 code. Disable the debug at the beginning of the affected files by adding error_reporting(0); after the initial parentheses.

The wp-settings.php file has an option that has to be disabled as well.
From: error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE);
To: error_reporting(0);

Warning: Cannot modify header information – headers already sent by …

Fix: (via Samuel B on this thread)
This happens from trailing or leading spaces at the beginning/end of the affected files – remove, save and you should be good.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.