str_replace counts fail to accumulate with arrays
commit65bdcabe8e564806f1468566a38372e04906be12
authorBrandon DuRette <brandond@alum.mit.edu>
Fri, 20 Dec 2013 19:25:54 +0000 (20 11:25 -0800)
committerSara Golemon <sgolemon@fb.com>
Tue, 24 Dec 2013 22:10:53 +0000 (24 14:10 -0800)
treeec6d94bc9e2e5f044abe00c7bc43f73e59436bda
parent6c277e96c7ba58c17c897f3a651c21e485a46a6f
str_replace counts fail to accumulate with arrays

The $count parameter of str_replace is supposed to return the total
number of string replacements performed. This was only working correctly
when both $search and $subject were strings. When either or both are
arrays, the counts need to accumulate across all replacements. The code,
as written, was only returning the replacement count for the last pair
of values.

Closes #1383

Reviewed By: @ptarjan

Differential Revision: D1106935

Pulled By: @scannell
hphp/runtime/ext/ext_string.cpp
hphp/test/quick/string_replace.php [new file with mode: 0644]
hphp/test/quick/string_replace.php.expect [new file with mode: 0644]
hphp/test/zend/good/ext/standard/tests/strings/str_replace_variation1.php [moved from hphp/test/zend/bad/ext/standard/tests/strings/str_replace_variation1.php with 88% similarity]
hphp/test/zend/good/ext/standard/tests/strings/str_replace_variation1.php.expectf [moved from hphp/test/zend/bad/ext/standard/tests/strings/str_replace_variation1.php.expectf with 100% similarity]
hphp/test/zend/good/ext/standard/tests/strings/str_replace_variation1.php.ini [moved from hphp/test/zend/bad/ext/standard/tests/strings/str_replace_variation1.php.ini with 100% similarity]
hphp/test/zend/good/ext/standard/tests/strings/str_replace_variation3.php [moved from hphp/test/zend/bad/ext/standard/tests/strings/str_replace_variation3.php with 84% similarity]
hphp/test/zend/good/ext/standard/tests/strings/str_replace_variation3.php.expectf [moved from hphp/test/zend/bad/ext/standard/tests/strings/str_replace_variation3.php.expectf with 100% similarity]
hphp/test/zend/good/ext/standard/tests/strings/str_replace_variation3.php.ini [moved from hphp/test/zend/bad/ext/standard/tests/strings/str_replace_variation3.php.ini with 100% similarity]