mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
(robin_fernandes at uk dot ibm dot com)
This commit is contained in:
parent
42df01cf6e
commit
1064f9721b
@ -1461,18 +1461,13 @@ PHP_FUNCTION(extract)
|
||||
if (extract_refs) {
|
||||
zval **orig_var;
|
||||
|
||||
if (zend_u_hash_find(EG(active_symbol_table), Z_TYPE(final_name), Z_UNIVAL(final_name), Z_UNILEN(final_name) + 1, (void **) &orig_var) == SUCCESS) {
|
||||
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
|
||||
zval_add_ref(entry);
|
||||
|
||||
if (zend_u_hash_find(EG(active_symbol_table), Z_TYPE(final_name), Z_UNIVAL(final_name), Z_UNILEN(final_name) + 1, (void **) &orig_var) == SUCCESS) {
|
||||
zval_ptr_dtor(orig_var);
|
||||
*orig_var = *entry;
|
||||
} else {
|
||||
if (Z_REFCOUNT_P(var_array) > 1 || *entry == EG(uninitialized_zval_ptr)) {
|
||||
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
|
||||
} else {
|
||||
Z_SET_ISREF_PP(entry);
|
||||
}
|
||||
zval_add_ref(entry);
|
||||
zend_u_hash_update(EG(active_symbol_table), Z_TYPE(final_name), Z_UNIVAL(final_name), Z_UNILEN(final_name) + 1, (void **) entry, sizeof(zval *), NULL);
|
||||
}
|
||||
} else {
|
||||
|
13
ext/standard/tests/array/extract_variation10.phpt
Normal file
13
ext/standard/tests/array/extract_variation10.phpt
Normal file
@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
Test extract() function - ensure EXTR_REFS doesn't mess with isRef flag on COW references to array elements.
|
||||
--FILE--
|
||||
<?php
|
||||
$a = array('foo' => 'original.foo');
|
||||
$nonref = $a['foo'];
|
||||
$ref = &$a;
|
||||
extract($a, EXTR_REFS);
|
||||
$a['foo'] = 'changed.foo';
|
||||
var_dump($nonref);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%unicode|string%(12) "original.foo"
|
13
ext/standard/tests/array/extract_variation11.phpt
Normal file
13
ext/standard/tests/array/extract_variation11.phpt
Normal file
@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
Test extract() function - ensure EXTR_REFS works when array is referenced and keys clash with variables in current scope.
|
||||
--FILE--
|
||||
<?php
|
||||
$a = array('foo' => 'original.foo');
|
||||
$ref = &$a;
|
||||
$foo = 'test';
|
||||
extract($a, EXTR_OVERWRITE|EXTR_REFS);
|
||||
$foo = 'changed.foo';
|
||||
var_dump($a['foo']);
|
||||
?>
|
||||
--EXPECTF--
|
||||
%unicode|string%(11) "changed.foo"
|
Loading…
Reference in New Issue
Block a user