Bug #54984 [Opn->Wfx]: ArrayObject creates invalid variable reference
| From: | felipe@php.net | Date: | Sat, 11 Jun 2011 23:00:53 +0000 |
| Subject: | Bug #54984 [Opn->Wfx]: ArrayObject creates invalid variable reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161324@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54984&edit=1
ID: 54984
Updated by: felipe@php.net
Reported by: pwharman at gmail dot com
Summary: ArrayObject creates invalid variable reference
-Status: Open
+Status: Wont fix
Type: Bug
Package: SPL related
Operating System: Windows/Linux
PHP Version: 5.2.17
Block user comment: N
Private report: N
New Comment:
Since 5.2.x is not a maintained version, consider using 5.3. :)
Previous Comments:
------------------------------------------------------------------------
[2011-06-04 13:50:16] pwharman at gmail dot com
I agree it makes no sense!
I have just retested using PHP 5.3.6 and can not reproduce this, it seems limited to 5.2.x. I have
just ran the script against 5.2.17 and can confirm the problem exists.
------------------------------------------------------------------------
[2011-06-04 01:25:07] felipe@php.net
This makes no sense, Are you reproducing it just with this posted test script?!
------------------------------------------------------------------------
[2011-06-03 12:49:42] pwharman at gmail dot com
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 this bug report at http://bugs.php.net/bug.php?id=54984&edit=1