#38866 [NEW]: Nesting level too deep Error when Object Contains Self Reference

From: Date: Mon, 18 Sep 2006 14:37:19 +0000
Subject: #38866 [NEW]: Nesting level too deep Error when Object Contains Self Reference
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102332@lists.php.net to get a copy of this message
From: adam at sccode dot com Operating system: Windows 2000 PHP version: 5CVS-2006-09-18 (snap) PHP Bug Type: Class/Object related Bug description: Nesting level too deep Error when Object Contains Self Reference Description: ------------ Attempting to compare two variables containing a reference to an object instance which in turn contains a property static or otherwise, referring back to itself produces a "Nesting level too deep" fatal error. One example where a self references may be necessary is a singleton: in PHP 5.1.6 the reproduce code works as expected. A feature, or a bug? Reproduce code: --------------- $obj = Singleton::instance(); $obj2 = $obj; var_dump($obj != $obj2); class Singleton { private static $instance; private function __construct() { $this->me = $this; } public static function instance() { if (! self::$instance) { self::$instance = new Singleton; } return self::$instance; } } Expected result: ---------------- bool(false) Actual result: -------------- Fatal error: Nesting level too deep - recursive dependency? in crash-test.php on line 5 -- Edit bug report at http://bugs.php.net/?id=38866&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38866&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38866&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38866&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38866&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38866&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38866&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38866&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38866&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38866&r=support Expected behavior: http://bugs.php.net/fix.php?id=38866&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38866&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38866&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38866&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38866&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38866&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38866&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38866&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38866&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38866&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38866&r=mysqlcfg

« previous php.bugs (#102332) next »