From:             dcousineau at gmail dot com
Operating system: Windows
PHP version:      5.2.9
PHP Bug Type:     SPL related
Bug description:  ArrayObject::ARRAY_AS_PROPS setting does not serialize

Description:
------------
By default (for some reason) SPL's ArrayObject does not allow accessing
members like object properties. In order to enable this behavior you must
use the **UNDOCUMENTED** technique of `$arrayobject = new
ArrayObject($array, ArrayObject::ARRAY_AS_PROPS);`.

However this setting is not saved during serialization, so when
unserializing the ArrayObject it reverts to it's default behavior (throwing
errors when trying to perform a `$arrayobject->key;`).

I believe given that since this is a mapping of an array to an object (and
not arrayaccess), ARRAY_AS_PROPS should be default behavior.

However, if one is paranoid about BC breaks, at least update ArrayObject
to store the ARRAY_AS_PROPS flag to support serialization.

Reproduce code:
---------------
<?php
$arrayobject = new ArrayObject(array('key'=>'value'),
ArrayObject::ARRAY_AS_PROPS);

echo $arrayobject->key;

$arrayobject = serialize($arrayobject);
$arrayobject = unserialize($arrayobject);

echo $arrayobject->key;

Expected result:
----------------
'value'
'value'

Actual result:
--------------
An error is raise on the last line trying to access a nonexistant
property.

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

Reply via email to