From:             
Operating system: Linux
PHP version:      5.2.14
Package:          *Programming Data Structures
Bug Type:         Bug
Bug description:Setting previously undefined property on an ArrayObject 
triggers weird error

Description:
------------
When assigning a reference to a previously undefined property of an
ArrayObject, 

E_NOTICE is thrown on the assignment itself, and every time that property
is 

accessed after that. Despite the "undefined index" complaints, the code
works as 

expected — $b->test[] = "foo" successfully assigns "foo" to $a[0].



This issue does not occur with assignment by value — no notices are
displayed 

(though the code no longer works as intended, as $a[0] remains undefined).
It also 

does not occur if $b->test is initialized prior to the assignment by
reference 

(e.g. adding a "$b->test = true" row before the assignment) — in this
case the 

assignment by reference also works as intended, and does not emit E_NOTICE.

Test script:
---------------
error_reporting(E_ALL & E_STRICT);

ini_set('display_errors', 1);



$a = array();

$b = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);

$b->test = &$a;

$b->test[] = "foo";

print($a[0]);

Expected result:
----------------
Script should run without notices.

Actual result:
--------------
Script throws "Undefined index: test" notices every time $b->test is
referenced, 

even though everything works correctly otherwise.

-- 
Edit bug report at http://bugs.php.net/bug.php?id=53277&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53277&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53277&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53277&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53277&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53277&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53277&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53277&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53277&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53277&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53277&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53277&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53277&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53277&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53277&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53277&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53277&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53277&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53277&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53277&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53277&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53277&r=mysqlcfg

Reply via email to