com php-src: Promote warnings to errors in str_repeat() : ext/mbstring/tests/bug73646.phpt ext/opcach e/tests/bug70207.phpt ext/standard/string.c e
xt/standard/tests/strings/str_repeat.phpt ext/standard/te sts/strings/str_repeat_variation1.phpt
| From: | George Peter Banyard | Date: | Fri, 23 Aug 2019 18:01:19 +0000 |
| Subject: | com php-src: Promote warnings to errors in str_repeat() : ext/mbstring/tests/bug73646.phpt ext/opcach e/tests/bug70207.phpt ext/standard/string.c e xt/standard/tests/strings/str_repeat.phpt ext/standard/te sts/strings/str_repeat_variation1.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108021@lists.php.net to get a copy of this message | ||
Commit: 1059e3dc39b65719c414ec0f31f65a77192034ab
Author: George Peter Banyard <girgias@php.net> Thu, 22 Aug 2019 11:28:22 +0200
Parents: bba7f38c4f8cbdbac391739b0fc905aaa8a09ce9
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1059e3dc39b65719c414ec0f31f65a77192034ab
Log:
Promote warnings to errors in str_repeat()
Changed paths:
M ext/mbstring/tests/bug73646.phpt
M ext/opcache/tests/bug70207.phpt
M ext/standard/string.c
M ext/standard/tests/strings/str_repeat.phpt
A ext/standard/tests/strings/str_repeat_variation1.phpt
Diff:
diff --git a/ext/mbstring/tests/bug73646.phpt b/ext/mbstring/tests/bug73646.phpt
index 7ac824d..ea57017 100644
--- a/ext/mbstring/tests/bug73646.phpt
+++ b/ext/mbstring/tests/bug73646.phpt
@@ -7,10 +7,7 @@ if (!function_exists('mb_ereg')) die('skip mbregex support not
available');
?>
--FILE--
<?php
-
-$v1=str_repeat("#", -1);
-var_dump(mb_ereg_search_init($v1));
+var_dump(mb_ereg_search_init(NULL));
?>
---EXPECTF--
-Warning: str_repeat(): Second argument has to be greater than or equal to 0 in %sbug73646.php on
line %d
+--EXPECT--
bool(true)
diff --git a/ext/opcache/tests/bug70207.phpt b/ext/opcache/tests/bug70207.phpt
index 806ea75..2b6e48a 100644
--- a/ext/opcache/tests/bug70207.phpt
+++ b/ext/opcache/tests/bug70207.phpt
@@ -14,7 +14,9 @@ function bar() {
}
function foo() {
try { return bar(); }
- finally { @str_repeat("foo", -10); }
+ finally {
+ @fopen("non-existent", 'r');
+ }
}
var_dump(foo());
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 97114e8..8b97d07 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -5363,7 +5363,7 @@ PHP_FUNCTION(str_repeat)
ZEND_PARSE_PARAMETERS_END();
if (mult < 0) {
- php_error_docref(NULL, E_WARNING, "Second argument has to be greater than or equal to
0");
+ zend_throw_error(NULL, "Second argument has to be greater than or equal to 0");
return;
}
diff --git a/ext/standard/tests/strings/str_repeat.phpt b/ext/standard/tests/strings/str_repeat.phpt
index 766bea1..6e5f0cf 100644
Binary files a/ext/standard/tests/strings/str_repeat.phpt and
b/ext/standard/tests/strings/str_repeat.phpt differ
diff --git a/ext/standard/tests/strings/str_repeat_variation1.phpt
b/ext/standard/tests/strings/str_repeat_variation1.phpt
new file mode 100644
index 0000000..4740f7c
--- /dev/null
+++ b/ext/standard/tests/strings/str_repeat_variation1.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test str_repeat() function: usage variations - complex strings containing other than 7-bit chars
+--INI--
+precision=14
+--FILE--
+<?php
+$str = chr(0).chr(128).chr(129).chr(234).chr(235).chr(254).chr(255);
+
+$withCodePoint = str_repeat($str, chr(51)); // ASCII value of '3' given
+$explicit = str_repeat($str, 3);
+
+var_dump($withCodePoint === $explicit);
+var_dump( bin2hex( $withCodePoint ) );
+var_dump( bin2hex( $explicit ) );
+
+?>
+DONE
+--EXPECT--
+bool(true)
+string(42) "008081eaebfeff008081eaebfeff008081eaebfeff"
+string(42) "008081eaebfeff008081eaebfeff008081eaebfeff"
+DONE