ID: 32322 Updated by: [EMAIL PROTECTED] Reported By: rickd at commando-pernod dot net -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: Win2000 PHP Version: 5.0.3 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Please use support forums to get help with your singleton implementation... Previous Comments: ------------------------------------------------------------------------ [2005-03-15 19:54:01] rickd at commando-pernod dot net Description: ------------ We use a user singleton instance for our cms user authed ids that should not be able to killed from third party addons or worse coders so easily, but accessable from all. But when someone get the instance with reference it can be killed easy with setting the reference var to null, unset dont work. If you put the static $instance holder inside the getinstance() function it seems to be work correct and cant be deleted from setting reference to NULL Reproduce code: --------------- class test { static private $instance = null; static function getinstance() { if ( self::$instance == null ) { return new test(); } return self::$instance; } } $user = &test::getinstance(); $user = null; // destroy singleton instance $user = &test::getinstance(); unset( $user ); // dont destroy instance Expected result: ---------------- singleton not destroying with setting a getted instance with reference to null Actual result: -------------- singleton destroyed ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32322&edit=1