summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UPGRADING2
-rw-r--r--ext/opcache/Optimizer/zend_func_info.c2
-rw-r--r--ext/standard/string.c4
-rw-r--r--ext/standard/tests/strings/quotemeta_basic_1.phpt4
4 files changed, 7 insertions, 5 deletions
diff --git a/UPGRADING b/UPGRADING
index 850f3fc360..1ca0d2af4f 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -148,6 +148,8 @@ PHP 8.0 UPGRADE NOTES
. The 'salt' option of password_hash() is no longer supported. If the 'salt'
option is used a warning is generated, the provided salt is ignored, and a
generated salt is used instead.
+ . The quotemeta() function will now return an empty string if an empty string
+ was passed. Previously false was returned.
- Zlib:
. gzgetss() has been removed.
diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c
index 7298059cb7..70640931e5 100644
--- a/ext/opcache/Optimizer/zend_func_info.c
+++ b/ext/opcache/Optimizer/zend_func_info.c
@@ -340,7 +340,7 @@ static const func_info_t func_infos[] = {
#endif
FN("substr", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
FN("substr_replace", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING),
- F1("quotemeta", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
+ F1("quotemeta", MAY_BE_NULL | MAY_BE_STRING),
FN("ucfirst", MAY_BE_NULL | MAY_BE_STRING),
FN("lcfirst", MAY_BE_NULL | MAY_BE_STRING),
F1("ucwords", MAY_BE_NULL | MAY_BE_STRING),
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 8009889b96..7f12cfae56 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2592,8 +2592,8 @@ PHP_FUNCTION(quotemeta)
old_end = ZSTR_VAL(old) + ZSTR_LEN(old);
- if (ZSTR_VAL(old) == old_end) {
- RETURN_FALSE;
+ if (ZSTR_LEN(old) == 0) {
+ RETURN_EMPTY_STRING();
}
str = zend_string_safe_alloc(2, ZSTR_LEN(old), 0, 0);
diff --git a/ext/standard/tests/strings/quotemeta_basic_1.phpt b/ext/standard/tests/strings/quotemeta_basic_1.phpt
index 4b479a9a60..4d1feb5ae1 100644
--- a/ext/standard/tests/strings/quotemeta_basic_1.phpt
+++ b/ext/standard/tests/strings/quotemeta_basic_1.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test function quotemeta() - using an empty string is given as str.
+Test function quotemeta() - using an empty string is given as str
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
User Group: PHPSP #PHPTestFestBrasil
@@ -9,4 +9,4 @@ $str = "";
var_dump(quotemeta($str));
?>
--EXPECT--
-bool(false)
+string(0) ""