Strict Standards: Assigning the return value of new by reference is deprecated...

"Strict Standards: Assigning the return value of new by reference is deprecated..." I tried to setup wordpress version 2.3 in my computer where Apache webserver is also installed. However, the installation was throwing errors as shown below (refer images) .


The first image shows these errors when trying to install wordpress. Paths are intentionally edited.

Strict Standards: Assigning the return value of new by reference is deprecated in C:\..\..\wp-settings.php on line 271

Strict Standards: Assigning the return value of new by reference is deprecated in C:\..\..\\wp-settings.php on line 273

Strict Standards: Assigning the return value of new by reference is deprecated in C:\..\..\wp-settings.php on line 274

Strict Standards: Assigning the return value of new by reference is deprecated in C:\..\..\wp-settings.php on line 291

Warning: Cannot modify header information - headers already sent by (output started at C:\..\..\wp-settings.php:271) in C:\..\..\wp-admin\install.php on line 16



The second image shows these errors. Paths are intentionally edited.

Strict Standards: Assigning the return value of new by reference is deprecated in C:\..\..\wp-settings.php on line 271

Strict Standards: Assigning the return value of new by reference is deprecated in C:\..\..\wp-settings.php on line 273

Strict Standards: Assigning the return value of new by reference is deprecated in C:\..\..\wp-settings.php on line 274

Strict Standards: Assigning the return value of new by reference is deprecated in C:\..\..\wp-settings.php on line 291

Warning: Cannot modify header information - headers already sent by (output started at C:\..\..\wp-settings.php:271) in C:\..\..\wp-login.php on line 12

Warning: Cannot modify header information - headers already sent by (output started at C:\..\..\wp-settings.php:271) in C:\..\...\wp-login.php on line 24

Although the error is there I continued until the wordpress login screen. When I keyed in the username and pasword it denied access. I am testing my computer as a web host. The intention is to test php scripts and web pages before loading to a external webhost.

I am using the following versions:

  • Apache 2.2.4(win32)
  • PHP 5.2.4
  • Wordpress Version 2.3
  • MySQL Server version: 5.0.45-community-nt MySQL Community Edition (GPL)

The recommended requirements for Wordpress 2.3 are PHP version 4.2 or higher and MySQL version 4.0 or higher. This is not a problem compared to my installation. Coming back to the issue, I did a google search for available solution for the problem. I found an explaination posted regarding the issue, below is the explaination from the link shown below.

http://wordpress.org/support/topic/104918

"This is not a standards violation, it's a difference between versions of PHP.

Strict Standards: Assigning the return value of new by reference is deprecated...

What's going on here has to do with lines like these:

$variable = & new SomeObject();

In PHP4, the ampersand is necessary to get the variable and not a copy of it. In PHP5, this behavior is the default and the ampersand is not needed, thus generating that error message when Strict mode is enabled.

Since Wordpress is designed to work on PHP4 *and* PHP5, that ampersand is necessary to make it work on PHP4.

Therefore, you need to disable strict mode. Or, at least, disable reporting of E_STRICT. "

However the suggestion to "disable strict mode or disable reporting of E_STRICT." did not solve the problem.I retained my error_reporting setting in php.ini as shown below.

; - Show all errors except for notices and coding standards warnings
;
;error_reporting = E_ALL & ~E_NOTICE (original)
error_reporting = E_ALL E_NOTICE E_STRICT

Based on the explaination provided in the link "In PHP5, this behavior is the default and the ampersand is not needed." I edited wp-settings.php as shown below. I duplicated the variables and commented the original settings. Then I removed the ampersand sign from the copy of variables. Refer below for the changes I made in wp-settings.php.

//Original variables commented
//$wp_the_query =& new WP_Query();
//$wp_query =& $wp_the_query;
//$wp_rewrite =& new WP_Rewrite();
//$wp =& new WP();

//Copied variables and removed ampersand
$wp_the_query = new WP_Query();
$wp_query = $wp_the_query;
$wp_rewrite = new WP_Rewrite();
$wp = new WP();
.
.
//Original variable commented
//$wp_locale =& new WP_Locale();

//Copied variable and removed ampersand
$wp_locale = new WP_Locale();

It worked! I didn't get any errors. I fired the browser and keyed http://localhost/.../wp-admin/install.php and it brought up the screen shown below without any errors. It says Wordpress already installed.


So I typed http://localhost/../wp-login.php in the browser location and the login screen appeared without error messages.

I was able to login and the wordpress welcome screen was shown, see screenshot.

I hope this could help those are facing similar problem. This may or may not help everyone as the installation configuration may vary and I would advice getting professional help. This post only explains how I managed to solve the problem which I was facing. Good luck!

No comments: