mirror of
https://github.com/php/php-src.git
synced 2025-01-27 06:03:45 +08:00
- Bugfix #36941 (ArrayIterator does not clone itself)
This commit is contained in:
parent
1160f87d1d
commit
ac099ca676
@ -228,6 +228,7 @@ static zend_object_value spl_array_object_clone(zval *zobject TSRMLS_DC)
|
|||||||
spl_array_object *intern;
|
spl_array_object *intern;
|
||||||
|
|
||||||
old_object = zend_objects_get_address(zobject TSRMLS_CC);
|
old_object = zend_objects_get_address(zobject TSRMLS_CC);
|
||||||
|
SEPARATE_ZVAL(&zobject);
|
||||||
new_obj_val = spl_array_object_new_ex(old_object->ce, &intern, zobject TSRMLS_CC);
|
new_obj_val = spl_array_object_new_ex(old_object->ce, &intern, zobject TSRMLS_CC);
|
||||||
new_object = &intern->std;
|
new_object = &intern->std;
|
||||||
|
|
||||||
|
24
ext/spl/tests/bug36941.phpt
Executable file
24
ext/spl/tests/bug36941.phpt
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
--TEST--
|
||||||
|
Bug #36941 (ArrayIterator does not clone itself)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$a = new ArrayIterator();
|
||||||
|
$a[] = 1;
|
||||||
|
|
||||||
|
$b = clone $a;
|
||||||
|
|
||||||
|
var_dump($a[0], $b[0]);
|
||||||
|
$b[0] = $b[0] + 1;
|
||||||
|
var_dump($a[0], $b[0]);
|
||||||
|
$b[0] = 3;
|
||||||
|
var_dump($a[0], $b[0]);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECT--
|
||||||
|
int(1)
|
||||||
|
int(1)
|
||||||
|
int(1)
|
||||||
|
int(2)
|
||||||
|
int(1)
|
||||||
|
int(3)
|
||||||
|
===DONE===
|
Loading…
Reference in New Issue
Block a user