From: php at thoftware dot de
Operating system: Windows
PHP version: 4.3.9
PHP Bug Type: Compile Failure
Bug description: array_pop doesn't work correctly
Description:
------------
array_pop() removes data from objects via a method.
Reproduce code:
---------------
class foobar {
var $cache = array();
function cache($j) {
if (!isset($this->cache[$j])) {
$this->cache[$j] = array(
'wert' => $j,
'text' => 'value: '.$j.'<br>',
'time' => 'set at '.date('h:i:s').'<br>',
);
}
return($this->cache[$j]);
}
}
$foobar =& new foobar();
$v = $foobar->cache(3);
echo $v['time'];
$v = $foobar->cache(3);
echo $v['time'];
$v = $foobar->cache(3);
echo $v['time'];
$v = $foobar->cache(3);
echo $v['time'];
/* returns as expected
set at 02:19:11
set at 02:19:11
set at 02:19:11
set at 02:19:11
*/
$foobar =& new foobar();
echo array_pop($foobar->cache(3));
/* returns as desired
set at 02:19:11
*/
$foobar =& new foobar();
echo array_pop($foobar->cache(3));
echo array_pop($foobar->cache(3));
echo array_pop($foobar->cache(3));
echo array_pop($foobar->cache(3));
/* returns as not desired
set at 02:19:11
value: 3
3
*/
$foobar =& new foobar();
$v = $foobar->cache(3);
echo $v['time'];
echo array_pop($foobar->cache(3));
/* returns as it should
set at 02:19:11
Fatal error: Only variables can be passed by reference in ...
*/
Seems that the first call with a method isn't recognized as being not a
variable =8-0.
Expected result:
----------------
see above
Actual result:
--------------
see above
--
Edit bug report at http://bugs.php.net/?id=32789&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32789&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=32789&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=32789&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32789&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32789&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32789&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32789&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32789&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32789&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32789&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=32789&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=32789&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32789&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32789&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32789&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32789&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32789&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32789&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32789&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32789&r=mysqlcfg