From: Operating system: Windows/Linux PHP version: 5.3.6 Package: SPL related Bug Type: Bug Bug description:ArrayObject creates invalid variable reference
Description: ------------ If ArrayAccess is extended and then the subclass accessed using object notation then unpredicatable results occur. In the test script below an undefined variable $xyz is somehow referencing the ArrayObject subclass Foo. The same result occurs on Linux systems. This came to light when using an unitialised value in the Zend Framework Zend_Registry class, although it is not limited to that. Test script: --------------- <?php class Foo extends ArrayObject{ public function __construct(){ parent::__construct(array(), parent::ARRAY_AS_PROPS); } } $f = new Foo; $f->Foo['bar'] = 1; var_dump($xyz['xyz']); # This should throw a warning then null?? ?> Expected result: ---------------- PHP Notice: Undefined index: Foo in C:\jirasource\ABC\sites\partners.rfp-gener ator.com\web\test.html.php on line 8 PHP Stack trace: PHP 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht ml.php:0 Notice: Undefined index: Foo in C:\jirasource\ABC\sites\partners.rfp-generator. com\web\test.html.php on line 8 Call Stack: 0.0212 60112 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat or.com\web\test.html.php:0 PHP Notice: Undefined variable: xyz in C:\jirasource\ABC\sites\partners.rfp-gen erator.com\web\test.html.php on line 9 PHP Stack trace: PHP 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht ml.php:0 Notice: Undefined variable: xyz in C:\jirasource\ABC\sites\partners.rfp-generato r.com\web\test.html.php on line 9 Call Stack: 0.0212 60112 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat or.com\web\test.html.php:0 PHP Notice: Undefined index: xyz in C:\jirasource\ABC\sites\partners.rfp-gener ator.com\web\test.html.php on line 9 PHP Stack trace: PHP 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht ml.php:0 Notice: Undefined index: xyz in C:\jirasource\ABC\sites\partners.rfp-generator. com\web\test.html.php on line 9 Call Stack: 0.0212 60112 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat or.com\web\test.html.php:0 null Actual result: -------------- PHP Notice: Undefined index: Foo in C:\jirasource\ABC\sites\partners.rfp-gener ator.com\web\test.html.php on line 8 PHP Stack trace: PHP 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht ml.php:0 Notice: Undefined index: Foo in C:\jirasource\ABC\sites\partners.rfp-generator. com\web\test.html.php on line 8 Call Stack: 0.0212 60112 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat or.com\web\test.html.php:0 PHP Notice: Undefined variable: xyz in C:\jirasource\ABC\sites\partners.rfp-gen erator.com\web\test.html.php on line 9 PHP Stack trace: PHP 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht ml.php:0 Notice: Undefined variable: xyz in C:\jirasource\ABC\sites\partners.rfp-generato r.com\web\test.html.php on line 9 Call Stack: 0.0212 60112 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat or.com\web\test.html.php:0 PHP Notice: Undefined index: xyz in C:\jirasource\ABC\sites\partners.rfp-gener ator.com\web\test.html.php on line 9 PHP Stack trace: PHP 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generator.com\web\test.ht ml.php:0 Notice: Undefined index: xyz in C:\jirasource\ABC\sites\partners.rfp-generator. com\web\test.html.php on line 9 Call Stack: 0.0212 60112 1. {main}() C:\jirasource\ABC\sites\partners.rfp-generat or.com\web\test.html.php:0 array(1) { ["bar"]=> int(1) } -- Edit bug report at http://bugs.php.net/bug.php?id=54984&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54984&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54984&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54984&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54984&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54984&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54984&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54984&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54984&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54984&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54984&r=support Expected behavior: http://bugs.php.net/fix.php?id=54984&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54984&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54984&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54984&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54984&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54984&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54984&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54984&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54984&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54984&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54984&r=mysqlcfg