ID: 34937 Updated by: [EMAIL PROTECTED] Reported By: fredrik at demomusic dot nu -Status: Open +Status: Feedback Bug Type: *Programming Data Structures Operating System: Linux & WinXP PHP Version: 5.0.5 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php5-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.0-win32-latest.zip Works fine for me with latest CVS. Previous Comments: ------------------------------------------------------------------------ [2005-10-21 16:24:32] fredrik at demomusic dot nu Reproduce script: http://dev.prylbanken.se/phpbug/php505bug34937.php Source code: http://dev.prylbanken.se/phpbug/php505bug34937.phps Output with php 5.0.4: http://dev.prylbanken.se/phpbug/php505bug34937.php_with_php504.htm ------------------------------------------------------------------------ [2005-10-21 14:20:12] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2005-10-21 13:17:32] fredrik at demomusic dot nu Problem exists in 5.0.6-dev, Build time Oct 21 2005 10:16:08 ------------------------------------------------------------------------ [2005-10-21 08:57:42] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.0-win32-latest.zip ------------------------------------------------------------------------ [2005-10-21 04:22:32] fredrik at demomusic dot nu 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 this bug report at http://bugs.php.net/?id=34937&edit=1