Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.0

Bug #12071 Error message: Assigning the return value of new by reference is deprecated
Submitted: 2007-09-18 15:02 UTC
From: dninja Assigned: chagenbu
Status: Closed Package: Mail (version 1.1.14)
PHP Version: 5.2.4 OS: arch linux
Roadmaps: (Not assigned)    

 [2007-09-18 15:02 UTC] dninja (Digi Ninja)
Description: ------------ I've been seeing this error message for a while (since php4.x), when error reporting is turned on to high (8191) I get the following error: error: Assigning the return value of new by reference is deprecated file: /usr/share/pear/Mail.php line: 154 I can't turn the error level down on some servers I use, how can I fix this? Expected result: ---------------- No errors Actual result: -------------- [args] => Array ( [0] => 2048 [1] => Assigning the return value of new by reference is deprecated [2] => /usr/share/pear/Mail.php [3] => 154 [4] => Array


 [2007-09-18 15:07 UTC] chagenbu (Chuck Hagenbuch)
You should be able to turn down the error level by calling the error_reporting function ( This is an E_STRICT error and it will not go away because the Mail package works with PHP 4.
 [2007-09-18 17:41 UTC] dninja (Digi Ninja)
I have the problem with both php4 and 5. I'll see if I can turn the level down though, see if it goes away.
 [2008-04-22 09:24 UTC] hubbitus (Pavel Alexeev)
Ok, why is not just provide error_handler to silently ignore this error on PHP5 if you do not wont fix structure completely? This error very vexatious me too.
 [2008-04-22 22:52 UTC] dninja (Digi Ninja)
I am currently just ignoring the error but I don't like ignoring things like this because the nature of deprecated things is that at some point they will stop working. I would love to have the time to fix the problem but don't, that is why I raised it, to see if anyone had a fix.
 [2009-07-20 01:30 UTC] torrentss (Torrent Azureusovich)
You can use the following workaround: function & ref_new(&$new_statement) { return $new_statement; } So, instead of writing: $o =& new ClassName(); you write: $o =& ref_new(new ClassName()); which gets rid of the warning but still avoids copying under PHP4.
 [2009-08-27 15:55 UTC] shadow_man (Arige Theo)
I wait too. But 1/3 packages was make for PHP5 and lots of package have make since 3 yers ago...
 [2009-12-27 14:54 UTC] magnamel (luca lisotti)
I am very interested to PEAR project but i am a very new user of php language For try, I have removed the ampersand (&) in front off operator 'new' at line 154 of Mail.php file. The error is disappeared What kind of problem missing & can do? Package Mail version 1.1.14 Php version 5.3.0 OS version Mac OS X 10.6 with XAMPP 1.7.2a installed Luca
 [2009-12-27 18:48 UTC] hubbitus (Pavel Alexeev)
magnamel - there no problem removing this ampersand in PHP5 but it breaks backward capability with php4. I can say must be removed for PHP5. In easy way it may be wrapped to oark in both.
 [2009-12-30 21:48 UTC] magnamel (luca lisotti)
Hi hubbitus, thank your for your reply about my question I have tried to call back the parseAddressList method in static manner. I know that this is not correct but with a E_ALL & ~E_NOTICE error level in php.ini the error is disappeared again. The code in Mail.php is now the follow: .. .. //$parser =& new Mail_RFC822(); $addresses = Mail_RFC822::parseAddressList($value, 'localhost', false); .. .. Is this PHP4 compatible? Bye
 [2010-01-08 07:44 UTC] hubbitus (Pavel Alexeev)
In any case call nonstatic methods in static context is bad idea - it will be prohibited in the future versions of PHP.
 [2010-02-02 09:50 UTC] jshpro2 (Josh Ribakoff)
Me too. I installed pear to install phing & phpunit. I am now uninstalling your non-maintained framework for it's failure to keep up with good standards :-)
 [2011-02-02 09:46 UTC] hm2k (James Wade)
-Status: Wont fix +Status: Closed
Appears to have been fixed as per bug #16969...
 [2011-04-08 09:25 UTC] uqwfung (Kenneth Fung)
E_DEPERCATED is something out of E_ALL I guess. The workaround is here: In PHP script, I put this line right before including Mail.php: //Temporarily suppressing PHP 5.3 deprecated error message like Mail::factory assigning the return value of new by reference error_reporting( E_ALL & ~( E_NOTICE | E_STRICT | E_DEPRECATED ) ); require_once "Mail.php"; With dynamic error_reporting() setting within particular PHP script, PHP engine will suppress those messages of deprecated function call while the global error_reporting level remains unchanged for further debugging:)
 [2012-05-30 15:00 UTC] gggeek (Gaetano Giunta)
Bug still valid with pear 1.9.4 Errors generated in Config.php, Registry.php, Installer/Role.php A shame really that this is still happening in 2012