ID: 33643 Comment by: sonick at sonick dot com Reported By: Jason at hybd dot net Status: Assigned Bug Type: Scripting Engine problem PHP Version: 5.1.0b2 Assigned To: derick New Comment:
PHP: 4.4.0 OS: Linux 2.6.12.2 Apache: 2.0.54 "Condition" reproduced with 4.4.0 stock php.ini-dist while calling coppermine1.3.3 ./coppermine/include/init.inc.php: "[error] PHP Fatal error: Only variables can be passed by reference in /path/to/coppermine/include/init.inc.php" No extraordinary build or environmental circumstances involved. Identical config known good under PHP4.3.11 and PHP4.3.10 Previous Comments: ------------------------------------------------------------------------ [2005-07-14 16:37:02] [EMAIL PROTECTED] This sort of thing needs to throw an error in any version of PHP I think: function foo() { return "blah"; } function bar(&$arg) { $arg = 1; } bar(foo()); While this should work: function & foo() { static $a; return $a; } function bar(&$arg) { $arg = 1; } bar(foo()); And it does in PHP5.1 at least. The first case indicates a clear bug in the code that we really should be catching. I suppose we could compromise and throw a warning in PHP4 and then fall back to passing the argument by value, but that is changing the actual workings of the script and is likely going to be wrong. I think this needs to be part of the reference fixes in PHP4.4. Sucks that it wasn't caught before the 4.4.0 release, but that's the way it goes. ------------------------------------------------------------------------ [2005-07-14 14:15:08] [EMAIL PROTECTED] Let's take this to [EMAIL PROTECTED] I'll write a mail later ------------------------------------------------------------------------ [2005-07-14 13:06:00] [EMAIL PROTECTED] The "Fatal error:" in HEAD and PHP_5_0 occurs because of fix for bug #33257. The patch was not applied into PHP 4.4 because it wasn't affected by this bug (PHP 4 doesn't allow static properties). Now I found reproducable case for PHP_4_4. :( <?php $x = array('foo'); function foo() { return $GLOBALS['x']; } function bar() { static $x = array('bar'); return $x; } echo array_pop(foo())."\n"; echo array_pop(foo())."\n"; /* BUG */ echo array_pop(bar())."\n"; echo array_pop(bar())."\n"; ?> Expected result: ---------------- Fatal error: Only variables can be passed by reference Or: --- foo foo bar bar Actual result: -------------- foo bar bar The current behavoir of HEAD is proper from my point of view. PHP_4_4 may be fixed but it will break BC again. Derick, Andi? ------------------------------------------------------------------------ [2005-07-14 11:16:56] [EMAIL PROTECTED] I think we need to discuss this a bit more, PHP 4.4 indeed gives no warning or notice on this. Andi, Dmitry? ------------------------------------------------------------------------ [2005-07-14 11:01:13] [EMAIL PROTECTED] Actual result (4.x after removing "public static"): 4.3.10: No error 4.4.0: No error 5.0.4: No error 5.1.0: Fatal error Is this really the expected result? I thought 4.4.0 should produce something too. In which cases 4.4.0 produces errors? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/33643 -- Edit this bug report at http://bugs.php.net/?id=33643&edit=1