|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-08-03 14:35 UTC] derick@php.net
[2005-08-03 17:14 UTC] kulakov74 at yandex dot ru
[2005-08-03 17:26 UTC] tony2001@php.net
[2005-08-03 18:40 UTC] kulakov74 at yandex dot ru
[2005-08-03 20:12 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Mar 25 04:00:01 2026 UTC |
Description: ------------ Our hosting has upgraded to 4.4.0 and we got the famous notice on returning variable reference. But after fixing my code to comply weith the notice I found it is still displayed at certain circumstances. Unfortunately, I could not isolate the code that behaves this way because of the scripts complexity so I cannot provide a simple code that reproduces it. While trying to figure out what was the reason I found that many minor changes, apparently absolutely not relating to the problem, could prevent the notice from beaing displayed, while otherwise it is displayed. It could be simple output directly before or even anywhere in the script, changing the value of the dummy variable that is returned instead of false, for ex. $oNewNode=null; //... return $oNewNode; produced the notice while $oNewNode=0; with the same code did not. Logging to a file, changing the line at which the dummy assignment is done and a lot of other changes randomly toggle the irrelevant notice off. I have a script that generates pages html and the same code works with some pages but displays the notice with others; then changing it results in the contrary thing. Finally, I found one bug-proof solution that worked everywhere: $oNewNode=&$oNewNode; return $oNewNode; but overall working around the problem in the 4.4.0 release has left a very unpleasant feeling of a buggy system. Reproduce code: --------------- This does not reproduce the problem - it's just the piece of code I worked with and I added all the lines I tried to prevent the notice. function &add($mixKey, $mixVal=array()){ //Add: either a pair $mixKey=>$mixVal, //or a node $mixKey with values $mixVal, or an array of pairs $mixKey //WORKED BUT NOT ALWAYS $oNewNode=null; $oNewNode=false; //WORKED ALMOST ALWAYS $oNewNode=0; $oNewNode=1; //array if (is_array($mixKey)){ foreach($mixKey as $n => $v) $this->add($n, $v); //WORKED NOT ALWAYS $oNewNode=0; } //string or a simple array else if (!is_array($mixVal) || key($mixVal)===0){ $this->hashValues[$mixKey]=$mixVal; //WORKED NOT ALWAYS $oNewNode=0; } //node else{ $oNewNode=&new Node($mixVal, $this->bCleanup); if (!@$this->aNodeGroups[$mixKey]){ $this->aNodeGroups[$mixKey]=array(); } $this->aNodeGroups[$mixKey][]=&$oNewNode; //THIS FOR A REASON RESULTED IN EVEN MORE NOTICES UNLIKE THE COMMON RETURN! return $oNewNode; } //NO EFFECT FOR A REASON if (!isset($oNewNode)) $oNewNode=0; //THE SOLUTION $oNewNode=&$oNewNode; return $oNewNode; } Expected result: ---------------- No notices Actual result: -------------- A few notices for some pages, none for others