helly Mon Apr 3 19:52:02 2006 UTC
Added files:
/php-src/ext/spl/tests array_022.phpt
Modified files:
/php-src/ext/spl spl_array.c
Log:
- Fix issue related to #36941 (when referencing itself)
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_array.c?r1=1.107&r2=1.108&diff_format=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.107 php-src/ext/spl/spl_array.c:1.108
--- php-src/ext/spl/spl_array.c:1.107 Sun Apr 2 15:04:04 2006
+++ php-src/ext/spl/spl_array.c Mon Apr 3 19:52:02 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.107 2006/04/02 15:04:04 helly Exp $ */
+/* $Id: spl_array.c,v 1.108 2006/04/03 19:52:02 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -73,7 +73,9 @@
} spl_array_object;
static inline HashTable *spl_array_get_hash_table(spl_array_object* intern,
int check_std_props TSRMLS_DC) {
- if ((intern->ar_flags & SPL_ARRAY_USE_OTHER) && (check_std_props == 0
|| (intern->ar_flags & SPL_ARRAY_STD_PROP_LIST) == 0)) {
+ if ((intern->ar_flags & SPL_ARRAY_IS_SELF) != 0) {
+ return intern->std.properties;
+ } else if ((intern->ar_flags & SPL_ARRAY_USE_OTHER) && (check_std_props
== 0 || (intern->ar_flags & SPL_ARRAY_STD_PROP_LIST) == 0)) {
spl_array_object *other =
(spl_array_object*)zend_object_store_get_object(intern->array TSRMLS_CC);
return spl_array_get_hash_table(other, check_std_props
TSRMLS_CC);
} else if ((intern->ar_flags & ((check_std_props ?
SPL_ARRAY_STD_PROP_LIST : 0) | SPL_ARRAY_IS_SELF)) != 0) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/array_022.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/array_022.phpt
+++ php-src/ext/spl/tests/array_022.phpt
--TEST--
SPL: ArrayObject/Iterator and reference to self
--FILE--
==ArrayObject===
<?php
class MyArrayObject extends ArrayObject
{
public function __construct()
{
parent::__construct($this);
$this['bar'] = 'baz';
}
}
$a = new MyArrayObject;
$b = clone $a;
$b['baz'] = 'Foo';
var_dump($a);
var_dump($b);
?>
==ArrayIterator===
<?php
class MyArrayIterator extends ArrayIterator
{
public function __construct()
{
parent::__construct($this);
$this['bar'] = 'baz';
}
}
$a = new MyArrayIterator;
$b = clone $a;
$b['baz'] = 'Foo';
var_dump($a);
var_dump($b);
?>
===DONE===
--EXPECTF--
==ArrayObject===
object(MyArrayObject)#%d (1) {
["bar"]=>
string(3) "baz"
}
object(MyArrayObject)#%d (2) {
["bar"]=>
string(3) "baz"
["baz"]=>
string(3) "Foo"
}
==ArrayIterator===
object(MyArrayIterator)#%d (1) {
["bar"]=>
string(3) "baz"
}
object(MyArrayIterator)#%d (2) {
["bar"]=>
string(3) "baz"
["baz"]=>
string(3) "Foo"
}
===DONE===
--UEXPECTF--
==ArrayObject===
object(MyArrayObject)#%d (1) {
[u"bar"]=>
unicode(3) "baz"
}
object(MyArrayObject)#%d (2) {
[u"bar"]=>
unicode(3) "baz"
[u"baz"]=>
unicode(3) "Foo"
}
==ArrayIterator===
object(MyArrayIterator)#%d (1) {
[u"bar"]=>
unicode(3) "baz"
}
object(MyArrayIterator)#%d (2) {
[u"bar"]=>
unicode(3) "baz"
[u"baz"]=>
unicode(3) "Foo"
}
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php