#34937 [NEW]: Fatal error when passing object's return-value as parameter by reference
From: fredrik at demomusic dot nu
Operating system: Linux
PHP version: 5.0.5
PHP Bug Type: *Programming Data Structures
Bug description: Fatal error when passing object's return-value as parameter by reference
Description:
------------
A bug most likely connected with the fixed bug #31525:
PHP-Changelog 5.0.5: -Fixed bug #31525 (object reference being dropped.
$this getting lost). (Stas, Dmitry)
(http://bugs.php.net/bug.php?id=31525)
When passing an object's return-value as parameter by reference I get a
fatal error for code that worked flawlessly in 5.0.4.
Reproduce code:
---------------
I am using the Smarty-framework. This function is from Smarty.php and is
the one involved in the error:
/**
* assigns values to template variables by reference
*
* @param string $tpl_var the template variable name
* @param mixed $value the referenced value to assign
*/
function assign_by_ref($tpl_var, &$value)
{
if ($tpl_var != '')
$this->_tpl_vars[$tpl_var] = &$value; //Lineno 603
}
Code:
$smarty->assign_by_ref ('soldStatus', $object->getSoldStatus ()); //Lineno
341
For clarity, this is the getSoldStatus()-method:
/**
* Get the sold-status of this ad.
* @return int The sold-status of this ad.
*/
public function getSoldStatus () {
return (int) $this->soldStatus;
}
And for yet more clarity, from the top of getSoldStatus's class:
/**
* @var int This' sold-status. 0 for not sold. 1 for sold.
*/
protected $soldStatus;
Expected result:
----------------
Is in PHP 4.0.4 Win32 and Linux, I suspect the "assign_by_ref"-method to
be executed, and, I guess, after bug-fix #31525, I would expect an
E_STRICT error in Smarty.php on line 603 later on.
Conclusivly, as I do not have E_STRICT error_reporting on, I would expect
my code to work as it did in php 5.0.4!
Actual result:
--------------
Fatal error: Only variables can be passed by reference in
/my/path/guiFunctions.php on line 341
--
Edit bug report at http://bugs.php.net/?id=34937&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34937&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34937&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34937&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34937&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34937&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34937&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34937&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34937&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34937&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34937&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=34937&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=34937&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34937&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34937&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34937&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34937&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34937&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34937&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34937&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34937&r=mysqlcfg
Thread (9 messages)
- fredrik at demomusic dot nu