views:

196

answers:

1

Hi, I have set error reporting in my development environment to E_STRICT by adding to the top of my wp-config.php file:

ini_set( 'error_reporting', E_STRICT );

This shows many places where return values are passed by reference, eg $wp_the_query = &new WP_Query(); throws the error Strict standards: Assigning the return value of new by reference is deprecated in /htdocs/site/wp-settings.php

I'm hoping I can simply remove the reference operator and not break this anywhere else, or do I need a more complex solution? I'm hoping do to better than just turn error_reporting off, that would just feel dirty.

I am running Wordpress 2.7.1 mu, PHP 5.2.6 with Xdebug 2.1.0.

Edit: As well as passing objects / values by reference, there are plenty of other warnings, including Redefining already defined constructor for class WP_Object_Cache, Creating default object from empty value, Non-static method WP_Http_ExtHTTP::test() should not be called statically , etc. Rather than looking for specific solutions, can you share any experiences in dealing with this mess of code? I'm okay with modifying the core files, at the risk of losing the ability upgrade in the future.

+2  A: 

Since PHP5, objects are always passed by reference, so the & is not needed here. You can remove it without having to worry. However, it does not hurt either.

Edit: You can find some more information on object references in PHP5 here.

rodion
Thanks, thats great to know. I edited the question, I guess I'm looking for experiences hunting down all the various warnings that strict mode throws.
postpostmodern