From: rickd at commando-pernod dot net Operating system: Win2000 PHP version: 5.0.3 PHP Bug Type: Zend Engine 2 problem Bug description: OOP singleton instance
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 bug report at http://bugs.php.net/?id=32322&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32322&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32322&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32322&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32322&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32322&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32322&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32322&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32322&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32322&r=support Expected behavior: http://bugs.php.net/fix.php?id=32322&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32322&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32322&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32322&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32322&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32322&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32322&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32322&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32322&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32322&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32322&r=mysqlcfg