lbarnaud Wed Nov 26 01:00:37 2008 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/array extract_variation10.phpt
extract_variation11.phpt
Modified files:
/php-src/ext/standard array.c
/php-src NEWS
Log:
MFH: Fixed bugs #44181 & #44182 (extract() and references)
(robin_fernandes at uk dot ibm dot com)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.58&r2=1.308.2.21.2.59&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.58
php-src/ext/standard/array.c:1.308.2.21.2.59
--- php-src/ext/standard/array.c:1.308.2.21.2.58 Thu Jun 19 12:09:21 2008
+++ php-src/ext/standard/array.c Wed Nov 26 01:00:36 2008
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: array.c,v 1.308.2.21.2.58 2008/06/19 12:09:21 dmitry Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.59 2008/11/26 01:00:36 lbarnaud Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -1466,20 +1466,13 @@
if (extract_refs) {
zval **orig_var;
+ SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
+ zval_add_ref(entry);
+
if
(zend_hash_find(EG(active_symbol_table), final_name.c, final_name.len+1, (void
**) &orig_var) == SUCCESS) {
-
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
- zval_add_ref(entry);
-
zval_ptr_dtor(orig_var);
-
*orig_var = *entry;
} else {
- if ((*var_array)->refcount > 1
|| *entry == EG(uninitialized_zval_ptr)) {
-
SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);
- } else {
- (*entry)->is_ref = 1;
- }
- zval_add_ref(entry);
zend_hash_update(EG(active_symbol_table), final_name.c, final_name.len+1, (void
**) entry, sizeof(zval *), NULL);
}
} else {
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1329&r2=1.2027.2.547.2.1330&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1329 php-src/NEWS:1.2027.2.547.2.1330
--- php-src/NEWS:1.2027.2.547.2.1329 Mon Nov 24 21:23:45 2008
+++ php-src/NEWS Wed Nov 26 01:00:36 2008
@@ -8,6 +8,10 @@
inconsistent results). (Arnaud)
- Fixed bug #46626 (mb_convert_case does not handle apostrophe correctly).
(Ilia)
+- Fixed bug #44182 (extract($a, EXTR_REFS) can fail to split copy-on-write
+ references). (robin_fernandes at uk dot ibm dot com)
+- Fixed bug #44181 (extract($a, EXTR_OVERWRITE|EXTR_REFS) can fail to create
+ references to $a). (robin_fernandes at uk dot ibm dot com)
20 Nov 2008, PHP 5.2.7RC4
- Added logging option for error_log to send directly to SAPI. (Stas)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation10.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/extract_variation10.phpt
+++ php-src/ext/standard/tests/array/extract_variation10.phpt
--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"
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/extract_variation11.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/extract_variation11.phpt
+++ php-src/ext/standard/tests/array/extract_variation11.phpt
--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"
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php