. Fixed bug #71735 (Double-free in SplDoublyLinkedList::offsetSet). (Stas)
- Standard:
+ . Fixed bug #71969 (str_replace returns an incorrect resulting array after
+ a foreach by reference). (Laruence)
. Fixed bug #71827 (substr_replace bug, string length). (krakjoe)
. Fixed bug #71891 (header_register_callback() and
register_shutdown_function()). (Laruence)
/* For each subject entry, convert it to string, then perform replacement
and add the result to the return_value array. */
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(subject), num_key, string_key, subject_entry) {
+ ZVAL_DEREF(subject_entry);
if (Z_TYPE_P(subject_entry) != IS_ARRAY && Z_TYPE_P(subject_entry) != IS_OBJECT) {
count += php_str_replace_in_subject(search, replace, subject_entry, &result, case_sensitivity);
} else {
--- /dev/null
+--TEST--
+Bug #71969 (str_replace returns an incorrect resulting array after a foreach by reference)
+--FILE--
+<?php
+$a = array(
+ array("one" => array("a"=>"0000", "b"=>"1111")),
+);
+
+//foreach by reference, changing the array value
+foreach($a as &$record)
+{
+ $record["one"]["a"] = "2222";
+}
+var_dump(str_replace("2", "3", $a));
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ array(1) {
+ ["one"]=>
+ array(2) {
+ ["a"]=>
+ string(4) "2222"
+ ["b"]=>
+ string(4) "1111"
+ }
+ }
+}