ID: 25831 Updated by: [EMAIL PROTECTED] -Summary: Pass by reference doesn't work with subclasses of DB_DataObject Reported By: viking at dslnorthwest dot net -Status: Open +Status: Verified -Bug Type: PEAR related +Bug Type: Scripting Engine problem -Operating System: Mac OS X 10.2.8 +Operating System: all -PHP Version: 4.3.3 +PHP Version: 4.3.3/4.3.4RC1 New Comment:
simple script to reproduce: <? class no_problem { function pass_by_reference(&$ref) { $ref = "Pass by reference works"; } } class problem { function pass_by_reference(&$ref) { $ref = "Pass by reference works"; } // simple dummy call implementation.. function __call($method,$params,&$return) { if ($method == get_class($this)) { return true; } return false; // not found! } } overload('problem'); $good = &new no_problem; $bad = &new problem; $message = "Pass by reference does not work!"; $good->pass_by_reference($message); print "$message\n"; $message = "Pass by reference does not work!"; $bad->pass_by_reference($message); print "$message\n"; ?> should print Pass by reference works Pass by reference works actually prints Pass by reference works Pass by reference does not work! Previous Comments: ------------------------------------------------------------------------ [2003-10-10 19:30:28] viking at dslnorthwest dot net Description: ------------ When extending the DB_DataObject class using PHP 4.3.3, pass-by-reference calls to class methods don't work. After removing the call to overload() at the bottom of DB_DataObject.php, references work as expected. The following comments at the bottom of DB_DataObject allude to this: // technially 4.3.2RC1 was broken!! // looks like 4.3.3 may have problems too.... if ((phpversion() != '4.3.2-RC1') && (version_compare( phpversion(), "4.3.1") > 0)) { overload('DB_DataObject'); $GLOBALS['_DB_DATAOBJECT']['OVERLOADED'] = true; } Reproduce code: --------------- require_once("DB/DataObject.php"); class no_problem { function pass_by_reference(&$ref) { $ref = "Pass by reference works"; } } class problem extends DB_DataObject { function pass_by_reference(&$ref) { $ref = "Pass by reference works"; } } $good = &new no_problem(); $bad = &new problem(); $message = "Pass by reference does not work!"; $good->pass_by_reference($message); print "$message\n"; $message = "Pass by reference does not work!"; $bad->pass_by_reference($message); print "$message\n"; Expected result: ---------------- Pass by reference works Pass by reference works Actual result: -------------- Pass by reference works Pass by reference does not work! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25831&edit=1