From b0aaa31702e8846d0067436bd23f4832954db476 Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Mon, 7 Jul 2025 11:43:07 -0700 Subject: [PATCH 1/7] Remove old exception class getters (#19043) --- UPGRADING.INTERNALS | 3 +++ Zend/zend_exceptions.c | 14 -------------- Zend/zend_exceptions.h | 6 ------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 67c779ea637c8..30b82a3618812 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -43,6 +43,9 @@ PHP 8.5 INTERNALS UPGRADE NOTES . Added the zend_update_exception_properties() function for instantiating Exception child classes. It updates the $message, $code, and $previous properties. + . zend_exception_get_default() was removed, use zend_ce_exception directly. + . zend_get_error_exception() was removed, use zend_ce_error_exception + directly. . ZEND_IS_XDIGIT() macro was removed because it was unused and its name did not match its actual behavior. . zend_register_constant() now returns a pointer to the added constant diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 212fe3cb7ab66..7366eeaa2dd57 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -846,20 +846,6 @@ void zend_register_default_exception(void) /* {{{ */ } /* }}} */ -/* {{{ Deprecated - Use zend_ce_exception directly instead */ -ZEND_API zend_class_entry *zend_exception_get_default(void) -{ - return zend_ce_exception; -} -/* }}} */ - -/* {{{ Deprecated - Use zend_ce_error_exception directly instead */ -ZEND_API zend_class_entry *zend_get_error_exception(void) -{ - return zend_ce_error_exception; -} -/* }}} */ - static zend_object *zend_throw_exception_zstr(zend_class_entry *exception_ce, zend_string *message, zend_long code) /* {{{ */ { zval ex, tmp; diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h index 35f6699559421..5df49dcd6a3a6 100644 --- a/Zend/zend_exceptions.h +++ b/Zend/zend_exceptions.h @@ -50,12 +50,6 @@ void zend_register_default_exception(void); ZEND_API zend_class_entry *zend_get_exception_base(zend_object *object); -/* Deprecated - Use zend_ce_exception directly instead */ -ZEND_API zend_class_entry *zend_exception_get_default(void); - -/* Deprecated - Use zend_ce_error_exception directly instead */ -ZEND_API zend_class_entry *zend_get_error_exception(void); - ZEND_API void zend_register_default_classes(void); /* exception_ce NULL, zend_ce_exception, zend_ce_error, or a derived class From 9225cb45aca741934e293e63357405f903fa3035 Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Mon, 7 Jul 2025 12:23:52 -0700 Subject: [PATCH 2/7] Make `zend_register_*_constant()` functions return pointers, use them (#19029) Have each of the specialized methods for registering a constant return a pointer to the registered constant the same way that the generic `zend_register_constant()` function does, and use those in the generated arginfo files to avoid needing to search for a constant that was just registered in order to add attributes to it. --- UPGRADING.INTERNALS | 8 ++++ Zend/zend_constants.c | 24 ++++++------ Zend/zend_constants.h | 12 +++--- Zend/zend_constants_arginfo.h | 3 +- build/gen_stub.php | 34 +++++++++++----- ext/curl/curl_arginfo.h | 3 +- ext/date/php_date_arginfo.h | 9 ++--- ext/dom/php_dom_arginfo.h | 3 +- ext/enchant/enchant_arginfo.h | 6 +-- ext/filter/filter_arginfo.h | 6 +-- ext/mysqli/mysqli_arginfo.h | 54 +++++++++----------------- ext/pgsql/pgsql_arginfo.h | 3 +- ext/random/random_arginfo.h | 3 +- ext/soap/soap_arginfo.h | 3 +- ext/standard/basic_functions_arginfo.h | 15 +++---- ext/standard/file_arginfo.h | 6 +-- 16 files changed, 89 insertions(+), 103 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 30b82a3618812..d84a59105dcf4 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -50,6 +50,14 @@ PHP 8.5 INTERNALS UPGRADE NOTES did not match its actual behavior. . zend_register_constant() now returns a pointer to the added constant on success and NULL on failure instead of SUCCESS/FAILURE. + The specialized registration methods that previously had void returns + also return pointers to the added constants: + * zend_register_bool_constant() + * zend_register_null_constant() + * zend_register_long_constant() + * zend_register_double_constant() + * zend_register_string_constant() + * zend_register_stringl_constant() ======================== 2. Build system changes diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index db37b9cf76824..cdab1bfced40b 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -136,62 +136,62 @@ void zend_register_standard_constants(void) null_const = zend_hash_str_find_ptr(EG(zend_constants), "NULL", sizeof("NULL")-1); } -ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number) +ZEND_API zend_constant *zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number) { zend_constant c; ZVAL_NULL(&c.value); ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number); c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT); - zend_register_constant(&c); + return zend_register_constant(&c); } -ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number) +ZEND_API zend_constant *zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number) { zend_constant c; ZVAL_BOOL(&c.value, bval); ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number); c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT); - zend_register_constant(&c); + return zend_register_constant(&c); } -ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number) +ZEND_API zend_constant *zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number) { zend_constant c; ZVAL_LONG(&c.value, lval); ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number); c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT); - zend_register_constant(&c); + return zend_register_constant(&c); } -ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number) +ZEND_API zend_constant *zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number) { zend_constant c; ZVAL_DOUBLE(&c.value, dval); ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number); c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT); - zend_register_constant(&c); + return zend_register_constant(&c); } -ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number) +ZEND_API zend_constant *zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number) { zend_constant c; ZVAL_STR(&c.value, zend_string_init_interned(strval, strlen, flags & CONST_PERSISTENT)); ZEND_CONSTANT_SET_FLAGS(&c, flags, module_number); c.name = zend_string_init_interned(name, name_len, flags & CONST_PERSISTENT); - zend_register_constant(&c); + return zend_register_constant(&c); } -ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number) +ZEND_API zend_constant *zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number) { - zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number); + return zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number); } static zend_constant *zend_get_halt_offset_constant(const char *name, size_t name_len) diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 69ea1d9021a83..6bdb19c4d5afc 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -91,12 +91,12 @@ ZEND_API zend_constant *zend_get_constant_ptr(zend_string *name); ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len); ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags); ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags); -ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number); -ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number); -ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number); -ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number); -ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number); -ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number); +ZEND_API zend_constant *zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number); +ZEND_API zend_constant *zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number); +ZEND_API zend_constant *zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number); +ZEND_API zend_constant *zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number); +ZEND_API zend_constant *zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number); +ZEND_API zend_constant *zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number); ZEND_API zend_constant *zend_register_constant(zend_constant *c); void zend_constant_add_attributes(zend_constant *c, HashTable *attributes); #ifdef ZTS diff --git a/Zend/zend_constants_arginfo.h b/Zend/zend_constants_arginfo.h index d381bcf64ee18..f87774dbc3e6e 100644 --- a/Zend/zend_constants_arginfo.h +++ b/Zend/zend_constants_arginfo.h @@ -14,7 +14,7 @@ static void register_zend_constants_symbols(int module_number) REGISTER_LONG_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("E_STRICT", E_STRICT, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_E_STRICT = REGISTER_LONG_CONSTANT("E_STRICT", E_STRICT, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("E_DEPRECATED", E_DEPRECATED, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("E_USER_DEPRECATED", E_USER_DEPRECATED, CONST_PERSISTENT); @@ -27,7 +27,6 @@ static void register_zend_constants_symbols(int module_number) REGISTER_BOOL_CONSTANT("FALSE", false, CONST_PERSISTENT); REGISTER_NULL_CONSTANT("NULL", CONST_PERSISTENT); - zend_constant *const_E_STRICT = zend_hash_str_find_ptr(EG(zend_constants), "E_STRICT", sizeof("E_STRICT") - 1); zend_attribute *attribute_Deprecated_const_E_STRICT_0 = zend_add_global_constant_attribute(const_E_STRICT, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_E_STRICT_0_arg0; diff --git a/build/gen_stub.php b/build/gen_stub.php index a3dd14a562346..8f2ddf10a8b05 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2781,24 +2781,36 @@ private function getGlobalConstDeclaration(EvaluatedValue $value): string if ($this->isDeprecated) { $flags .= " | CONST_DEPRECATED"; } + + $code = "\t"; + if ($this->attributes !== []) { + if ($this->phpVersionIdMinimumCompatibility === null || $this->phpVersionIdMinimumCompatibility >= PHP_85_VERSION_ID) { + // Registration only returns the constant since PHP 8.5, it's + // not worth the bloat to add two different registration blocks + // with conditions for the PHP version + $constVarName = 'const_' . $constName; + $code .= "zend_constant *$constVarName = "; + } + } + if ($value->type->isNull()) { - return "\tREGISTER_NULL_CONSTANT(\"$constName\", $flags);\n"; + return $code . "REGISTER_NULL_CONSTANT(\"$constName\", $flags);\n"; } if ($value->type->isBool()) { - return "\tREGISTER_BOOL_CONSTANT(\"$constName\", " . ($cExpr ?: ($constValue ? "true" : "false")) . ", $flags);\n"; + return $code . "REGISTER_BOOL_CONSTANT(\"$constName\", " . ($cExpr ?: ($constValue ? "true" : "false")) . ", $flags);\n"; } if ($value->type->isInt()) { - return "\tREGISTER_LONG_CONSTANT(\"$constName\", " . ($cExpr ?: (int) $constValue) . ", $flags);\n"; + return $code . "REGISTER_LONG_CONSTANT(\"$constName\", " . ($cExpr ?: (int) $constValue) . ", $flags);\n"; } if ($value->type->isFloat()) { - return "\tREGISTER_DOUBLE_CONSTANT(\"$constName\", " . ($cExpr ?: (float) $constValue) . ", $flags);\n"; + return $code . "REGISTER_DOUBLE_CONSTANT(\"$constName\", " . ($cExpr ?: (float) $constValue) . ", $flags);\n"; } if ($value->type->isString()) { - return "\tREGISTER_STRING_CONSTANT(\"$constName\", " . ($cExpr ?: '"' . addslashes($constValue) . '"') . ", $flags);\n"; + return $code . "REGISTER_STRING_CONSTANT(\"$constName\", " . ($cExpr ?: '"' . addslashes($constValue) . '"') . ", $flags);\n"; } throw new Exception("Unimplemented constant type"); @@ -5307,12 +5319,11 @@ function generateGlobalConstantAttributeInitialization( $isConditional = false; if ($phpVersionIdMinimumCompatibility !== null && $phpVersionIdMinimumCompatibility < PHP_85_VERSION_ID) { $isConditional = true; - $phpVersionIdMinimumCompatibility = PHP_85_VERSION_ID; } $code = generateCodeWithConditions( $constInfos, "", - static function (ConstInfo $constInfo) use ($allConstInfos, $phpVersionIdMinimumCompatibility) { + static function (ConstInfo $constInfo) use ($allConstInfos, $isConditional) { $code = ""; if ($constInfo->attributes === []) { @@ -5321,13 +5332,18 @@ static function (ConstInfo $constInfo) use ($allConstInfos, $phpVersionIdMinimum $constName = str_replace('\\', '\\\\', $constInfo->name->__toString()); $constVarName = 'const_' . $constName; - $code .= "\tzend_constant *$constVarName = zend_hash_str_find_ptr(EG(zend_constants), \"" . $constName . "\", sizeof(\"" . $constName . "\") - 1);\n"; + // The entire attribute block will be conditional if PHP < 8.5 is + // supported, but also if PHP < 8.5 is supported we need to search + // for the constant; see GH-19029 + if ($isConditional) { + $code .= "\tzend_constant *$constVarName = zend_hash_str_find_ptr(EG(zend_constants), \"" . $constName . "\", sizeof(\"" . $constName . "\") - 1);\n"; + } foreach ($constInfo->attributes as $key => $attribute) { $code .= $attribute->generateCode( "zend_add_global_constant_attribute($constVarName", $constVarName . "_$key", $allConstInfos, - $phpVersionIdMinimumCompatibility + PHP_85_VERSION_ID ); } diff --git a/ext/curl/curl_arginfo.h b/ext/curl/curl_arginfo.h index cff18b2916859..433a280e90da6 100644 --- a/ext/curl/curl_arginfo.h +++ b/ext/curl/curl_arginfo.h @@ -228,7 +228,7 @@ static const zend_function_entry ext_functions[] = { static void register_curl_symbols(int module_number) { REGISTER_LONG_CONSTANT("CURLOPT_AUTOREFERER", CURLOPT_AUTOREFERER, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("CURLOPT_BINARYTRANSFER", CURLOPT_BINARYTRANSFER, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_CURLOPT_BINARYTRANSFER = REGISTER_LONG_CONSTANT("CURLOPT_BINARYTRANSFER", CURLOPT_BINARYTRANSFER, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("CURLOPT_BUFFERSIZE", CURLOPT_BUFFERSIZE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CURLOPT_CAINFO", CURLOPT_CAINFO, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CURLOPT_CAPATH", CURLOPT_CAPATH, CONST_PERSISTENT); @@ -974,7 +974,6 @@ static void register_curl_symbols(int module_number) #endif REGISTER_LONG_CONSTANT("CURLOPT_SAFE_UPLOAD", CURLOPT_SAFE_UPLOAD, CONST_PERSISTENT); - zend_constant *const_CURLOPT_BINARYTRANSFER = zend_hash_str_find_ptr(EG(zend_constants), "CURLOPT_BINARYTRANSFER", sizeof("CURLOPT_BINARYTRANSFER") - 1); zend_attribute *attribute_Deprecated_const_CURLOPT_BINARYTRANSFER_0 = zend_add_global_constant_attribute(const_CURLOPT_BINARYTRANSFER, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_CURLOPT_BINARYTRANSFER_0_arg0; diff --git a/ext/date/php_date_arginfo.h b/ext/date/php_date_arginfo.h index 0b249c738f715..e9bdf0fce4546 100644 --- a/ext/date/php_date_arginfo.h +++ b/ext/date/php_date_arginfo.h @@ -808,9 +808,9 @@ static void register_php_date_symbols(int module_number) ZEND_ASSERT(strcmp(DATE_FORMAT_RFC3339_EXTENDED, "Y-m-d\\TH:i:s.vP") == 0); REGISTER_STRING_CONSTANT("DATE_RSS", DATE_FORMAT_RFC1123, CONST_PERSISTENT); REGISTER_STRING_CONSTANT("DATE_W3C", DATE_FORMAT_RFC3339, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SUNFUNCS_RET_TIMESTAMP", SUNFUNCS_RET_TIMESTAMP, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("SUNFUNCS_RET_STRING", SUNFUNCS_RET_STRING, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("SUNFUNCS_RET_DOUBLE", SUNFUNCS_RET_DOUBLE, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_SUNFUNCS_RET_TIMESTAMP = REGISTER_LONG_CONSTANT("SUNFUNCS_RET_TIMESTAMP", SUNFUNCS_RET_TIMESTAMP, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_SUNFUNCS_RET_STRING = REGISTER_LONG_CONSTANT("SUNFUNCS_RET_STRING", SUNFUNCS_RET_STRING, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_SUNFUNCS_RET_DOUBLE = REGISTER_LONG_CONSTANT("SUNFUNCS_RET_DOUBLE", SUNFUNCS_RET_DOUBLE, CONST_PERSISTENT | CONST_DEPRECATED); zend_attribute *attribute_Deprecated_func_strftime_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "strftime", sizeof("strftime") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); @@ -860,7 +860,6 @@ static void register_php_date_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_func_date_sunset_0_arg1, attribute_Deprecated_func_date_sunset_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_func_date_sunset_0->args[1].value, &attribute_Deprecated_func_date_sunset_0_arg1); attribute_Deprecated_func_date_sunset_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_SUNFUNCS_RET_TIMESTAMP = zend_hash_str_find_ptr(EG(zend_constants), "SUNFUNCS_RET_TIMESTAMP", sizeof("SUNFUNCS_RET_TIMESTAMP") - 1); zend_attribute *attribute_Deprecated_const_SUNFUNCS_RET_TIMESTAMP_0 = zend_add_global_constant_attribute(const_SUNFUNCS_RET_TIMESTAMP, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_SUNFUNCS_RET_TIMESTAMP_0_arg0; @@ -873,7 +872,6 @@ static void register_php_date_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_SUNFUNCS_RET_TIMESTAMP_0_arg1, attribute_Deprecated_const_SUNFUNCS_RET_TIMESTAMP_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_SUNFUNCS_RET_TIMESTAMP_0->args[1].value, &attribute_Deprecated_const_SUNFUNCS_RET_TIMESTAMP_0_arg1); attribute_Deprecated_const_SUNFUNCS_RET_TIMESTAMP_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_SUNFUNCS_RET_STRING = zend_hash_str_find_ptr(EG(zend_constants), "SUNFUNCS_RET_STRING", sizeof("SUNFUNCS_RET_STRING") - 1); zend_attribute *attribute_Deprecated_const_SUNFUNCS_RET_STRING_0 = zend_add_global_constant_attribute(const_SUNFUNCS_RET_STRING, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_SUNFUNCS_RET_STRING_0_arg0; @@ -886,7 +884,6 @@ static void register_php_date_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_SUNFUNCS_RET_STRING_0_arg1, attribute_Deprecated_const_SUNFUNCS_RET_STRING_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_SUNFUNCS_RET_STRING_0->args[1].value, &attribute_Deprecated_const_SUNFUNCS_RET_STRING_0_arg1); attribute_Deprecated_const_SUNFUNCS_RET_STRING_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_SUNFUNCS_RET_DOUBLE = zend_hash_str_find_ptr(EG(zend_constants), "SUNFUNCS_RET_DOUBLE", sizeof("SUNFUNCS_RET_DOUBLE") - 1); zend_attribute *attribute_Deprecated_const_SUNFUNCS_RET_DOUBLE_0 = zend_add_global_constant_attribute(const_SUNFUNCS_RET_DOUBLE, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_SUNFUNCS_RET_DOUBLE_0_arg0; diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 922f03240e0f8..be7a5c0713ad4 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1837,7 +1837,7 @@ static void register_php_dom_symbols(int module_number) REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NMTOKENS", XML_ATTRIBUTE_NMTOKENS, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ENUMERATION", XML_ATTRIBUTE_ENUMERATION, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NOTATION", XML_ATTRIBUTE_NOTATION, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM_PHP_ERR", PHP_ERR, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_DOM_PHP_ERR = REGISTER_LONG_CONSTANT("DOM_PHP_ERR", PHP_ERR, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("DOM_INDEX_SIZE_ERR", INDEX_SIZE_ERR, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DOMSTRING_SIZE_ERR", DOMSTRING_SIZE_ERR, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DOM_HIERARCHY_REQUEST_ERR", HIERARCHY_REQUEST_ERR, CONST_PERSISTENT); @@ -1871,7 +1871,6 @@ static void register_php_dom_symbols(int module_number) REGISTER_LONG_CONSTANT("Dom\\VALIDATION_ERR", VALIDATION_ERR, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("Dom\\HTML_NO_DEFAULT_NS", DOM_HTML_NO_DEFAULT_NS, CONST_PERSISTENT); - zend_constant *const_DOM_PHP_ERR = zend_hash_str_find_ptr(EG(zend_constants), "DOM_PHP_ERR", sizeof("DOM_PHP_ERR") - 1); zend_attribute *attribute_Deprecated_const_DOM_PHP_ERR_0 = zend_add_global_constant_attribute(const_DOM_PHP_ERR, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_DOM_PHP_ERR_0_arg0; diff --git a/ext/enchant/enchant_arginfo.h b/ext/enchant/enchant_arginfo.h index 0cd8707e1a172..7015f826a0fb2 100644 --- a/ext/enchant/enchant_arginfo.h +++ b/ext/enchant/enchant_arginfo.h @@ -156,8 +156,8 @@ static const zend_function_entry ext_functions[] = { static void register_enchant_symbols(int module_number) { - REGISTER_LONG_CONSTANT("ENCHANT_MYSPELL", PHP_ENCHANT_MYSPELL, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("ENCHANT_ISPELL", PHP_ENCHANT_ISPELL, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_ENCHANT_MYSPELL = REGISTER_LONG_CONSTANT("ENCHANT_MYSPELL", PHP_ENCHANT_MYSPELL, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_ENCHANT_ISPELL = REGISTER_LONG_CONSTANT("ENCHANT_ISPELL", PHP_ENCHANT_ISPELL, CONST_PERSISTENT | CONST_DEPRECATED); #if defined(HAVE_ENCHANT_GET_VERSION) REGISTER_STRING_CONSTANT("LIBENCHANT_VERSION", PHP_ENCHANT_GET_VERSION, CONST_PERSISTENT); #endif @@ -224,7 +224,6 @@ static void register_enchant_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_func_enchant_dict_is_in_session_0_arg1, attribute_Deprecated_func_enchant_dict_is_in_session_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_func_enchant_dict_is_in_session_0->args[1].value, &attribute_Deprecated_func_enchant_dict_is_in_session_0_arg1); attribute_Deprecated_func_enchant_dict_is_in_session_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_ENCHANT_MYSPELL = zend_hash_str_find_ptr(EG(zend_constants), "ENCHANT_MYSPELL", sizeof("ENCHANT_MYSPELL") - 1); zend_attribute *attribute_Deprecated_const_ENCHANT_MYSPELL_0 = zend_add_global_constant_attribute(const_ENCHANT_MYSPELL, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_ENCHANT_MYSPELL_0_arg0; @@ -237,7 +236,6 @@ static void register_enchant_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_ENCHANT_MYSPELL_0_arg1, attribute_Deprecated_const_ENCHANT_MYSPELL_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_ENCHANT_MYSPELL_0->args[1].value, &attribute_Deprecated_const_ENCHANT_MYSPELL_0_arg1); attribute_Deprecated_const_ENCHANT_MYSPELL_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_ENCHANT_ISPELL = zend_hash_str_find_ptr(EG(zend_constants), "ENCHANT_ISPELL", sizeof("ENCHANT_ISPELL") - 1); zend_attribute *attribute_Deprecated_const_ENCHANT_ISPELL_0 = zend_add_global_constant_attribute(const_ENCHANT_ISPELL, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_ENCHANT_ISPELL_0_arg0; diff --git a/ext/filter/filter_arginfo.h b/ext/filter/filter_arginfo.h index 8cc562e5de236..34c4a6b449af0 100644 --- a/ext/filter/filter_arginfo.h +++ b/ext/filter/filter_arginfo.h @@ -81,8 +81,8 @@ static void register_filter_symbols(int module_number) REGISTER_LONG_CONSTANT("FILTER_VALIDATE_MAC", FILTER_VALIDATE_MAC, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_DEFAULT", FILTER_DEFAULT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_UNSAFE_RAW", FILTER_UNSAFE_RAW, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRING", FILTER_SANITIZE_STRING, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRIPPED", FILTER_SANITIZE_STRING, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_FILTER_SANITIZE_STRING = REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRING", FILTER_SANITIZE_STRING, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_FILTER_SANITIZE_STRIPPED = REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRIPPED", FILTER_SANITIZE_STRING, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("FILTER_SANITIZE_ENCODED", FILTER_SANITIZE_ENCODED, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_SANITIZE_SPECIAL_CHARS", FILTER_SANITIZE_SPECIAL_CHARS, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_SANITIZE_FULL_SPECIAL_CHARS", FILTER_SANITIZE_FULL_SPECIAL_CHARS, CONST_PERSISTENT); @@ -115,7 +115,6 @@ static void register_filter_symbols(int module_number) REGISTER_LONG_CONSTANT("FILTER_FLAG_HOSTNAME", FILTER_FLAG_HOSTNAME, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_FLAG_EMAIL_UNICODE", FILTER_FLAG_EMAIL_UNICODE, CONST_PERSISTENT); - zend_constant *const_FILTER_SANITIZE_STRING = zend_hash_str_find_ptr(EG(zend_constants), "FILTER_SANITIZE_STRING", sizeof("FILTER_SANITIZE_STRING") - 1); zend_attribute *attribute_Deprecated_const_FILTER_SANITIZE_STRING_0 = zend_add_global_constant_attribute(const_FILTER_SANITIZE_STRING, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_FILTER_SANITIZE_STRING_0_arg0; @@ -128,7 +127,6 @@ static void register_filter_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_FILTER_SANITIZE_STRING_0_arg1, attribute_Deprecated_const_FILTER_SANITIZE_STRING_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_FILTER_SANITIZE_STRING_0->args[1].value, &attribute_Deprecated_const_FILTER_SANITIZE_STRING_0_arg1); attribute_Deprecated_const_FILTER_SANITIZE_STRING_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_FILTER_SANITIZE_STRIPPED = zend_hash_str_find_ptr(EG(zend_constants), "FILTER_SANITIZE_STRIPPED", sizeof("FILTER_SANITIZE_STRIPPED") - 1); zend_attribute *attribute_Deprecated_const_FILTER_SANITIZE_STRIPPED_0 = zend_add_global_constant_attribute(const_FILTER_SANITIZE_STRIPPED, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_FILTER_SANITIZE_STRIPPED_0_arg0; diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h index 43dba58417f36..3402936e9ea03 100644 --- a/ext/mysqli/mysqli_arginfo.h +++ b/ext/mysqli/mysqli_arginfo.h @@ -1059,7 +1059,7 @@ static void register_mysqli_symbols(int module_number) REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT", MYSQLI_STORE_RESULT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_USE_RESULT", MYSQLI_USE_RESULT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_ASYNC", MYSQLI_ASYNC, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT_COPY_DATA", MYSQLI_STORE_RESULT_COPY_DATA, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_STORE_RESULT_COPY_DATA = REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT_COPY_DATA", MYSQLI_STORE_RESULT_COPY_DATA, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("MYSQLI_ASSOC", MYSQLI_ASSOC, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_NUM", MYSQLI_NUM, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_BOTH", MYSQLI_BOTH, CONST_PERSISTENT); @@ -1114,28 +1114,28 @@ static void register_mysqli_symbols(int module_number) REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NEWDECIMAL", FIELD_TYPE_NEWDECIMAL, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_TYPE_BIT", FIELD_TYPE_BIT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_SET_CHARSET_NAME", MYSQL_SET_CHARSET_NAME, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_NO_DATA", MYSQL_NO_DATA, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_DATA_TRUNCATED", MYSQL_DATA_TRUNCATED, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_NO_DATA = REGISTER_LONG_CONSTANT("MYSQLI_NO_DATA", MYSQL_NO_DATA, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_DATA_TRUNCATED = REGISTER_LONG_CONSTANT("MYSQLI_DATA_TRUNCATED", MYSQL_DATA_TRUNCATED, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("MYSQLI_REPORT_INDEX", MYSQLI_REPORT_INDEX, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ERROR", MYSQLI_REPORT_ERROR, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_REPORT_STRICT", MYSQLI_REPORT_STRICT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ALL", MYSQLI_REPORT_ALL, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_REPORT_OFF", MYSQLI_REPORT_OFF, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_DEBUG_TRACE_ENABLED", MYSQLND_DBG_ENABLED, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED", SERVER_QUERY_NO_GOOD_INDEX_USED, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_NO_INDEX_USED", SERVER_QUERY_NO_INDEX_USED, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_WAS_SLOW", SERVER_QUERY_WAS_SLOW, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_SERVER_PS_OUT_PARAMS", SERVER_PS_OUT_PARAMS, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_GRANT", REFRESH_GRANT, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_LOG", REFRESH_LOG, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_TABLES", REFRESH_TABLES, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_HOSTS", REFRESH_HOSTS, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_STATUS", REFRESH_STATUS, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_THREADS", REFRESH_THREADS, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_REPLICA", REFRESH_SLAVE, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_SLAVE", REFRESH_SLAVE, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_MASTER", REFRESH_MASTER, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_BACKUP_LOG", REFRESH_BACKUP_LOG, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED = REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED", SERVER_QUERY_NO_GOOD_INDEX_USED, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_SERVER_QUERY_NO_INDEX_USED = REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_NO_INDEX_USED", SERVER_QUERY_NO_INDEX_USED, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_SERVER_QUERY_WAS_SLOW = REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_WAS_SLOW", SERVER_QUERY_WAS_SLOW, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_SERVER_PS_OUT_PARAMS = REGISTER_LONG_CONSTANT("MYSQLI_SERVER_PS_OUT_PARAMS", SERVER_PS_OUT_PARAMS, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_GRANT = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_GRANT", REFRESH_GRANT, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_LOG = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_LOG", REFRESH_LOG, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_TABLES = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_TABLES", REFRESH_TABLES, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_HOSTS = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_HOSTS", REFRESH_HOSTS, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_STATUS = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_STATUS", REFRESH_STATUS, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_THREADS = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_THREADS", REFRESH_THREADS, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_REPLICA = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_REPLICA", REFRESH_SLAVE, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_SLAVE = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_SLAVE", REFRESH_SLAVE, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_MASTER = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_MASTER", REFRESH_MASTER, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_REFRESH_BACKUP_LOG = REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_BACKUP_LOG", REFRESH_BACKUP_LOG, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT", TRANS_START_WITH_CONSISTENT_SNAPSHOT, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_READ_WRITE", TRANS_START_READ_WRITE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_TRANS_START_READ_ONLY", TRANS_START_READ_ONLY, CONST_PERSISTENT); @@ -1143,7 +1143,7 @@ static void register_mysqli_symbols(int module_number) REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_AND_NO_CHAIN", TRANS_COR_AND_NO_CHAIN, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_RELEASE", TRANS_COR_RELEASE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MYSQLI_TRANS_COR_NO_RELEASE", TRANS_COR_NO_RELEASE, CONST_PERSISTENT); - REGISTER_BOOL_CONSTANT("MYSQLI_IS_MARIADB", false, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MYSQLI_IS_MARIADB = REGISTER_BOOL_CONSTANT("MYSQLI_IS_MARIADB", false, CONST_PERSISTENT | CONST_DEPRECATED); zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "mysqli_change_user", sizeof("mysqli_change_user") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); @@ -1187,7 +1187,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_func_mysqli_refresh_0_arg1, attribute_Deprecated_func_mysqli_refresh_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_func_mysqli_refresh_0->args[1].value, &attribute_Deprecated_func_mysqli_refresh_0_arg1); attribute_Deprecated_func_mysqli_refresh_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_STORE_RESULT_COPY_DATA = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_STORE_RESULT_COPY_DATA", sizeof("MYSQLI_STORE_RESULT_COPY_DATA") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_STORE_RESULT_COPY_DATA_0 = zend_add_global_constant_attribute(const_MYSQLI_STORE_RESULT_COPY_DATA, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_STORE_RESULT_COPY_DATA_0_arg0; @@ -1200,7 +1199,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_STORE_RESULT_COPY_DATA_0_arg1, attribute_Deprecated_const_MYSQLI_STORE_RESULT_COPY_DATA_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_STORE_RESULT_COPY_DATA_0->args[1].value, &attribute_Deprecated_const_MYSQLI_STORE_RESULT_COPY_DATA_0_arg1); attribute_Deprecated_const_MYSQLI_STORE_RESULT_COPY_DATA_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_NO_DATA = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_NO_DATA", sizeof("MYSQLI_NO_DATA") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_NO_DATA_0 = zend_add_global_constant_attribute(const_MYSQLI_NO_DATA, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_NO_DATA_0_arg0; @@ -1213,7 +1211,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_NO_DATA_0_arg1, attribute_Deprecated_const_MYSQLI_NO_DATA_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_NO_DATA_0->args[1].value, &attribute_Deprecated_const_MYSQLI_NO_DATA_0_arg1); attribute_Deprecated_const_MYSQLI_NO_DATA_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_DATA_TRUNCATED = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_DATA_TRUNCATED", sizeof("MYSQLI_DATA_TRUNCATED") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_DATA_TRUNCATED_0 = zend_add_global_constant_attribute(const_MYSQLI_DATA_TRUNCATED, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_DATA_TRUNCATED_0_arg0; @@ -1226,7 +1223,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_DATA_TRUNCATED_0_arg1, attribute_Deprecated_const_MYSQLI_DATA_TRUNCATED_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_DATA_TRUNCATED_0->args[1].value, &attribute_Deprecated_const_MYSQLI_DATA_TRUNCATED_0_arg1); attribute_Deprecated_const_MYSQLI_DATA_TRUNCATED_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED", sizeof("MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED_0 = zend_add_global_constant_attribute(const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED_0_arg0; @@ -1239,7 +1235,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED_0_arg1, attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED_0->args[1].value, &attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED_0_arg1); attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_SERVER_QUERY_NO_INDEX_USED = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_SERVER_QUERY_NO_INDEX_USED", sizeof("MYSQLI_SERVER_QUERY_NO_INDEX_USED") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_INDEX_USED_0 = zend_add_global_constant_attribute(const_MYSQLI_SERVER_QUERY_NO_INDEX_USED, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_INDEX_USED_0_arg0; @@ -1252,7 +1247,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_INDEX_USED_0_arg1, attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_INDEX_USED_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_INDEX_USED_0->args[1].value, &attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_INDEX_USED_0_arg1); attribute_Deprecated_const_MYSQLI_SERVER_QUERY_NO_INDEX_USED_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_SERVER_QUERY_WAS_SLOW = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_SERVER_QUERY_WAS_SLOW", sizeof("MYSQLI_SERVER_QUERY_WAS_SLOW") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_SERVER_QUERY_WAS_SLOW_0 = zend_add_global_constant_attribute(const_MYSQLI_SERVER_QUERY_WAS_SLOW, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_SERVER_QUERY_WAS_SLOW_0_arg0; @@ -1265,7 +1259,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_SERVER_QUERY_WAS_SLOW_0_arg1, attribute_Deprecated_const_MYSQLI_SERVER_QUERY_WAS_SLOW_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_SERVER_QUERY_WAS_SLOW_0->args[1].value, &attribute_Deprecated_const_MYSQLI_SERVER_QUERY_WAS_SLOW_0_arg1); attribute_Deprecated_const_MYSQLI_SERVER_QUERY_WAS_SLOW_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_SERVER_PS_OUT_PARAMS = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_SERVER_PS_OUT_PARAMS", sizeof("MYSQLI_SERVER_PS_OUT_PARAMS") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_SERVER_PS_OUT_PARAMS_0 = zend_add_global_constant_attribute(const_MYSQLI_SERVER_PS_OUT_PARAMS, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_SERVER_PS_OUT_PARAMS_0_arg0; @@ -1278,7 +1271,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_SERVER_PS_OUT_PARAMS_0_arg1, attribute_Deprecated_const_MYSQLI_SERVER_PS_OUT_PARAMS_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_SERVER_PS_OUT_PARAMS_0->args[1].value, &attribute_Deprecated_const_MYSQLI_SERVER_PS_OUT_PARAMS_0_arg1); attribute_Deprecated_const_MYSQLI_SERVER_PS_OUT_PARAMS_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_GRANT = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_GRANT", sizeof("MYSQLI_REFRESH_GRANT") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_GRANT_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_GRANT, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_GRANT_0_arg0; @@ -1291,7 +1283,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_GRANT_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_GRANT_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_GRANT_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_GRANT_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_GRANT_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_LOG = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_LOG", sizeof("MYSQLI_REFRESH_LOG") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_LOG_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_LOG, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_LOG_0_arg0; @@ -1304,7 +1295,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_LOG_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_LOG_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_LOG_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_LOG_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_LOG_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_TABLES = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_TABLES", sizeof("MYSQLI_REFRESH_TABLES") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_TABLES_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_TABLES, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_TABLES_0_arg0; @@ -1317,7 +1307,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_TABLES_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_TABLES_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_TABLES_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_TABLES_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_TABLES_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_HOSTS = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_HOSTS", sizeof("MYSQLI_REFRESH_HOSTS") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_HOSTS_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_HOSTS, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_HOSTS_0_arg0; @@ -1330,7 +1319,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_HOSTS_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_HOSTS_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_HOSTS_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_HOSTS_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_HOSTS_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_STATUS = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_STATUS", sizeof("MYSQLI_REFRESH_STATUS") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_STATUS_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_STATUS, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_STATUS_0_arg0; @@ -1343,7 +1331,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_STATUS_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_STATUS_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_STATUS_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_STATUS_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_STATUS_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_THREADS = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_THREADS", sizeof("MYSQLI_REFRESH_THREADS") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_THREADS_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_THREADS, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_THREADS_0_arg0; @@ -1356,7 +1343,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_THREADS_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_THREADS_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_THREADS_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_THREADS_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_THREADS_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_REPLICA = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_REPLICA", sizeof("MYSQLI_REFRESH_REPLICA") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_REPLICA_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_REPLICA, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_REPLICA_0_arg0; @@ -1369,7 +1355,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_REPLICA_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_REPLICA_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_REPLICA_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_REPLICA_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_REPLICA_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_SLAVE = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_SLAVE", sizeof("MYSQLI_REFRESH_SLAVE") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_SLAVE_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_SLAVE, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_SLAVE_0_arg0; @@ -1382,7 +1367,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_SLAVE_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_SLAVE_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_SLAVE_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_SLAVE_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_SLAVE_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_MASTER = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_MASTER", sizeof("MYSQLI_REFRESH_MASTER") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_MASTER_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_MASTER, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_MASTER_0_arg0; @@ -1395,7 +1379,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_MASTER_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_MASTER_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_MASTER_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_MASTER_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_MASTER_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_REFRESH_BACKUP_LOG = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_REFRESH_BACKUP_LOG", sizeof("MYSQLI_REFRESH_BACKUP_LOG") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_REFRESH_BACKUP_LOG_0 = zend_add_global_constant_attribute(const_MYSQLI_REFRESH_BACKUP_LOG, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_REFRESH_BACKUP_LOG_0_arg0; @@ -1408,7 +1391,6 @@ static void register_mysqli_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_MYSQLI_REFRESH_BACKUP_LOG_0_arg1, attribute_Deprecated_const_MYSQLI_REFRESH_BACKUP_LOG_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_MYSQLI_REFRESH_BACKUP_LOG_0->args[1].value, &attribute_Deprecated_const_MYSQLI_REFRESH_BACKUP_LOG_0_arg1); attribute_Deprecated_const_MYSQLI_REFRESH_BACKUP_LOG_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MYSQLI_IS_MARIADB = zend_hash_str_find_ptr(EG(zend_constants), "MYSQLI_IS_MARIADB", sizeof("MYSQLI_IS_MARIADB") - 1); zend_attribute *attribute_Deprecated_const_MYSQLI_IS_MARIADB_0 = zend_add_global_constant_attribute(const_MYSQLI_IS_MARIADB, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MYSQLI_IS_MARIADB_0_arg0; diff --git a/ext/pgsql/pgsql_arginfo.h b/ext/pgsql/pgsql_arginfo.h index e42723eef6dd9..f286ee0385686 100644 --- a/ext/pgsql/pgsql_arginfo.h +++ b/ext/pgsql/pgsql_arginfo.h @@ -757,7 +757,7 @@ static const zend_function_entry ext_functions[] = { static void register_pgsql_symbols(int module_number) { REGISTER_STRING_CONSTANT("PGSQL_LIBPQ_VERSION", pgsql_libpq_version, CONST_PERSISTENT); - REGISTER_STRING_CONSTANT("PGSQL_LIBPQ_VERSION_STR", pgsql_libpq_version, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_PGSQL_LIBPQ_VERSION_STR = REGISTER_STRING_CONSTANT("PGSQL_LIBPQ_VERSION_STR", pgsql_libpq_version, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("PGSQL_CONNECT_FORCE_NEW", PGSQL_CONNECT_FORCE_NEW, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PGSQL_CONNECT_ASYNC", PGSQL_CONNECT_ASYNC, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PGSQL_ASSOC", PGSQL_ASSOC, CONST_PERSISTENT); @@ -1153,7 +1153,6 @@ static void register_pgsql_symbols(int module_number) attribute_Deprecated_func_pg_clientencoding_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "pg_change_password", sizeof("pg_change_password") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); - zend_constant *const_PGSQL_LIBPQ_VERSION_STR = zend_hash_str_find_ptr(EG(zend_constants), "PGSQL_LIBPQ_VERSION_STR", sizeof("PGSQL_LIBPQ_VERSION_STR") - 1); zend_attribute *attribute_Deprecated_const_PGSQL_LIBPQ_VERSION_STR_0 = zend_add_global_constant_attribute(const_PGSQL_LIBPQ_VERSION_STR, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_PGSQL_LIBPQ_VERSION_STR_0_arg0; diff --git a/ext/random/random_arginfo.h b/ext/random/random_arginfo.h index 0d7ba3c96524b..4f2f6a71035af 100644 --- a/ext/random/random_arginfo.h +++ b/ext/random/random_arginfo.h @@ -226,7 +226,7 @@ static const zend_function_entry class_Random_Randomizer_methods[] = { static void register_random_symbols(int module_number) { REGISTER_LONG_CONSTANT("MT_RAND_MT19937", MT_RAND_MT19937, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MT_RAND_PHP", MT_RAND_PHP, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_MT_RAND_PHP = REGISTER_LONG_CONSTANT("MT_RAND_PHP", MT_RAND_PHP, CONST_PERSISTENT | CONST_DEPRECATED); zend_attribute *attribute_Deprecated_func_lcg_value_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "lcg_value", sizeof("lcg_value") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); @@ -240,7 +240,6 @@ static void register_random_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_func_lcg_value_0_arg1, attribute_Deprecated_func_lcg_value_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_func_lcg_value_0->args[1].value, &attribute_Deprecated_func_lcg_value_0_arg1); attribute_Deprecated_func_lcg_value_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_MT_RAND_PHP = zend_hash_str_find_ptr(EG(zend_constants), "MT_RAND_PHP", sizeof("MT_RAND_PHP") - 1); zend_attribute *attribute_Deprecated_const_MT_RAND_PHP_0 = zend_add_global_constant_attribute(const_MT_RAND_PHP, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_MT_RAND_PHP_0_arg0; diff --git a/ext/soap/soap_arginfo.h b/ext/soap/soap_arginfo.h index c4ce5bf1e58b7..8aff24f75cbef 100644 --- a/ext/soap/soap_arginfo.h +++ b/ext/soap/soap_arginfo.h @@ -238,7 +238,7 @@ static void register_soap_symbols(int module_number) REGISTER_LONG_CONSTANT("SOAP_1_2", SOAP_1_2, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOAP_PERSISTENCE_SESSION", SOAP_PERSISTENCE_SESSION, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOAP_PERSISTENCE_REQUEST", SOAP_PERSISTENCE_REQUEST, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SOAP_FUNCTIONS_ALL", SOAP_FUNCTIONS_ALL, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_SOAP_FUNCTIONS_ALL = REGISTER_LONG_CONSTANT("SOAP_FUNCTIONS_ALL", SOAP_FUNCTIONS_ALL, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("SOAP_ENCODED", SOAP_ENCODED, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOAP_LITERAL", SOAP_LITERAL, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOAP_RPC", SOAP_RPC, CONST_PERSISTENT); @@ -316,7 +316,6 @@ static void register_soap_symbols(int module_number) REGISTER_LONG_CONSTANT("SOAP_SSL_METHOD_SSLv3", SOAP_SSL_METHOD_SSLv3, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOAP_SSL_METHOD_SSLv23", SOAP_SSL_METHOD_SSLv23, CONST_PERSISTENT); - zend_constant *const_SOAP_FUNCTIONS_ALL = zend_hash_str_find_ptr(EG(zend_constants), "SOAP_FUNCTIONS_ALL", sizeof("SOAP_FUNCTIONS_ALL") - 1); zend_attribute *attribute_Deprecated_const_SOAP_FUNCTIONS_ALL_0 = zend_add_global_constant_attribute(const_SOAP_FUNCTIONS_ALL, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_SOAP_FUNCTIONS_ALL_0_arg0; diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index a3d965ad99667..8655941fe4ce7 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -3518,11 +3518,11 @@ static void register_basic_functions_symbols(int module_number) REGISTER_LONG_CONSTANT("COUNT_RECURSIVE", PHP_COUNT_RECURSIVE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ARRAY_FILTER_USE_BOTH", ARRAY_FILTER_USE_BOTH, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("ARRAY_FILTER_USE_KEY", ARRAY_FILTER_USE_KEY, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("ASSERT_ACTIVE", PHP_ASSERT_ACTIVE, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("ASSERT_CALLBACK", PHP_ASSERT_CALLBACK, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("ASSERT_BAIL", PHP_ASSERT_BAIL, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("ASSERT_WARNING", PHP_ASSERT_WARNING, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("ASSERT_EXCEPTION", PHP_ASSERT_EXCEPTION, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_ASSERT_ACTIVE = REGISTER_LONG_CONSTANT("ASSERT_ACTIVE", PHP_ASSERT_ACTIVE, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_ASSERT_CALLBACK = REGISTER_LONG_CONSTANT("ASSERT_CALLBACK", PHP_ASSERT_CALLBACK, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_ASSERT_BAIL = REGISTER_LONG_CONSTANT("ASSERT_BAIL", PHP_ASSERT_BAIL, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_ASSERT_WARNING = REGISTER_LONG_CONSTANT("ASSERT_WARNING", PHP_ASSERT_WARNING, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_ASSERT_EXCEPTION = REGISTER_LONG_CONSTANT("ASSERT_EXCEPTION", PHP_ASSERT_EXCEPTION, CONST_PERSISTENT | CONST_DEPRECATED); REGISTER_LONG_CONSTANT("CONNECTION_ABORTED", PHP_CONNECTION_ABORTED, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CONNECTION_NORMAL", PHP_CONNECTION_NORMAL, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CONNECTION_TIMEOUT", PHP_CONNECTION_TIMEOUT, CONST_PERSISTENT); @@ -3940,7 +3940,6 @@ static void register_basic_functions_symbols(int module_number) zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "password_hash", sizeof("password_hash") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "password_verify", sizeof("password_verify") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); - zend_constant *const_ASSERT_ACTIVE = zend_hash_str_find_ptr(EG(zend_constants), "ASSERT_ACTIVE", sizeof("ASSERT_ACTIVE") - 1); zend_attribute *attribute_Deprecated_const_ASSERT_ACTIVE_0 = zend_add_global_constant_attribute(const_ASSERT_ACTIVE, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_ASSERT_ACTIVE_0_arg0; @@ -3953,7 +3952,6 @@ static void register_basic_functions_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_ASSERT_ACTIVE_0_arg1, attribute_Deprecated_const_ASSERT_ACTIVE_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_ASSERT_ACTIVE_0->args[1].value, &attribute_Deprecated_const_ASSERT_ACTIVE_0_arg1); attribute_Deprecated_const_ASSERT_ACTIVE_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_ASSERT_CALLBACK = zend_hash_str_find_ptr(EG(zend_constants), "ASSERT_CALLBACK", sizeof("ASSERT_CALLBACK") - 1); zend_attribute *attribute_Deprecated_const_ASSERT_CALLBACK_0 = zend_add_global_constant_attribute(const_ASSERT_CALLBACK, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_ASSERT_CALLBACK_0_arg0; @@ -3966,7 +3964,6 @@ static void register_basic_functions_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_ASSERT_CALLBACK_0_arg1, attribute_Deprecated_const_ASSERT_CALLBACK_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_ASSERT_CALLBACK_0->args[1].value, &attribute_Deprecated_const_ASSERT_CALLBACK_0_arg1); attribute_Deprecated_const_ASSERT_CALLBACK_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_ASSERT_BAIL = zend_hash_str_find_ptr(EG(zend_constants), "ASSERT_BAIL", sizeof("ASSERT_BAIL") - 1); zend_attribute *attribute_Deprecated_const_ASSERT_BAIL_0 = zend_add_global_constant_attribute(const_ASSERT_BAIL, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_ASSERT_BAIL_0_arg0; @@ -3979,7 +3976,6 @@ static void register_basic_functions_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_ASSERT_BAIL_0_arg1, attribute_Deprecated_const_ASSERT_BAIL_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_ASSERT_BAIL_0->args[1].value, &attribute_Deprecated_const_ASSERT_BAIL_0_arg1); attribute_Deprecated_const_ASSERT_BAIL_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_ASSERT_WARNING = zend_hash_str_find_ptr(EG(zend_constants), "ASSERT_WARNING", sizeof("ASSERT_WARNING") - 1); zend_attribute *attribute_Deprecated_const_ASSERT_WARNING_0 = zend_add_global_constant_attribute(const_ASSERT_WARNING, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_ASSERT_WARNING_0_arg0; @@ -3992,7 +3988,6 @@ static void register_basic_functions_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_ASSERT_WARNING_0_arg1, attribute_Deprecated_const_ASSERT_WARNING_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_ASSERT_WARNING_0->args[1].value, &attribute_Deprecated_const_ASSERT_WARNING_0_arg1); attribute_Deprecated_const_ASSERT_WARNING_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_ASSERT_EXCEPTION = zend_hash_str_find_ptr(EG(zend_constants), "ASSERT_EXCEPTION", sizeof("ASSERT_EXCEPTION") - 1); zend_attribute *attribute_Deprecated_const_ASSERT_EXCEPTION_0 = zend_add_global_constant_attribute(const_ASSERT_EXCEPTION, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_ASSERT_EXCEPTION_0_arg0; diff --git a/ext/standard/file_arginfo.h b/ext/standard/file_arginfo.h index 276419b9abaa7..00d63edf27a89 100644 --- a/ext/standard/file_arginfo.h +++ b/ext/standard/file_arginfo.h @@ -108,8 +108,8 @@ static void register_file_symbols(int module_number) REGISTER_LONG_CONSTANT("FILE_SKIP_EMPTY_LINES", PHP_FILE_SKIP_EMPTY_LINES, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILE_APPEND", PHP_FILE_APPEND, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILE_NO_DEFAULT_CONTEXT", PHP_FILE_NO_DEFAULT_CONTEXT, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FILE_TEXT", 0, CONST_PERSISTENT | CONST_DEPRECATED); - REGISTER_LONG_CONSTANT("FILE_BINARY", 0, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_FILE_TEXT = REGISTER_LONG_CONSTANT("FILE_TEXT", 0, CONST_PERSISTENT | CONST_DEPRECATED); + zend_constant *const_FILE_BINARY = REGISTER_LONG_CONSTANT("FILE_BINARY", 0, CONST_PERSISTENT | CONST_DEPRECATED); #if defined(HAVE_FNMATCH) REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FNM_PATHNAME", FNM_PATHNAME, CONST_PERSISTENT); @@ -119,7 +119,6 @@ static void register_file_symbols(int module_number) REGISTER_LONG_CONSTANT("FNM_CASEFOLD", FNM_CASEFOLD, CONST_PERSISTENT); #endif - zend_constant *const_FILE_TEXT = zend_hash_str_find_ptr(EG(zend_constants), "FILE_TEXT", sizeof("FILE_TEXT") - 1); zend_attribute *attribute_Deprecated_const_FILE_TEXT_0 = zend_add_global_constant_attribute(const_FILE_TEXT, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_FILE_TEXT_0_arg0; @@ -132,7 +131,6 @@ static void register_file_symbols(int module_number) ZVAL_STR(&attribute_Deprecated_const_FILE_TEXT_0_arg1, attribute_Deprecated_const_FILE_TEXT_0_arg1_str); ZVAL_COPY_VALUE(&attribute_Deprecated_const_FILE_TEXT_0->args[1].value, &attribute_Deprecated_const_FILE_TEXT_0_arg1); attribute_Deprecated_const_FILE_TEXT_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_constant *const_FILE_BINARY = zend_hash_str_find_ptr(EG(zend_constants), "FILE_BINARY", sizeof("FILE_BINARY") - 1); zend_attribute *attribute_Deprecated_const_FILE_BINARY_0 = zend_add_global_constant_attribute(const_FILE_BINARY, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); zval attribute_Deprecated_const_FILE_BINARY_0_arg0; From 45d948f2da78ede961bef7a13ef28d34db3df895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 7 Jul 2025 21:30:13 +0200 Subject: [PATCH 3/7] Zend: Add `zend_check_method_accessible()` to DRY method visibility checks (#18995) * Zend: Add `zend_check_method_accessible()` to DRY method visibility checks * Zend: Add assertions verifying flags didn't change before `zend_check_method_accessible()` * Try `zend_always_inline` for `zend_check_method_accessible` --- Zend/zend_API.c | 28 ++++++++---------- Zend/zend_ast.c | 21 +++++-------- Zend/zend_builtin_functions.c | 19 +++--------- Zend/zend_object_handlers.c | 30 ++++++++----------- Zend/zend_objects.c | 56 ++++++++++------------------------- Zend/zend_objects_API.h | 11 +++++++ Zend/zend_vm_def.h | 14 ++++----- Zend/zend_vm_execute.h | 50 +++++++++++++------------------ 8 files changed, 90 insertions(+), 139 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index e05422395ec19..5daff69a60b0a 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -4021,13 +4021,11 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ ((fcc->object && fcc->calling_scope->__call) || (!fcc->object && fcc->calling_scope->__callstatic)))) { scope = get_scope(frame); - if (fcc->function_handler->common.scope != scope) { - if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PRIVATE) - || !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) { - retval = 0; - fcc->function_handler = NULL; - goto get_function_via_handler; - } + ZEND_ASSERT(!(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(fcc->function_handler, scope)) { + retval = 0; + fcc->function_handler = NULL; + goto get_function_via_handler; } } } else { @@ -4086,17 +4084,15 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ if (retval && !(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC)) { scope = get_scope(frame); - if (fcc->function_handler->common.scope != scope) { - if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PRIVATE) - || (!zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope))) { - if (error) { - if (*error) { - efree(*error); - } - zend_spprintf(error, 0, "cannot access %s method %s::%s()", zend_visibility_string(fcc->function_handler->common.fn_flags), ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name)); + ZEND_ASSERT(!(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(fcc->function_handler, scope)) { + if (error) { + if (*error) { + efree(*error); } - retval = 0; + zend_spprintf(error, 0, "cannot access %s method %s::%s()", zend_visibility_string(fcc->function_handler->common.fn_flags), ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name)); } + retval = 0; } } } diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 728695bd9e930..0e403329264c4 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -1098,21 +1098,14 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner( } else { fptr = zend_hash_find_ptr_lc(&ce->function_table, method_name); if (fptr) { - if (!(fptr->common.fn_flags & ZEND_ACC_PUBLIC)) { - if (UNEXPECTED(fptr->common.scope != scope)) { - if ( - UNEXPECTED(fptr->op_array.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(fptr), scope)) - ) { - if (ce->__callstatic) { - zend_throw_error(NULL, "Creating a callable for the magic __callStatic() method is not supported in constant expressions"); - } else { - zend_bad_method_call(fptr, method_name, scope); - } - - return FAILURE; - } + if (!zend_check_method_accessible(fptr, scope)) { + if (ce->__callstatic) { + zend_throw_error(NULL, "Creating a callable for the magic __callStatic() method is not supported in constant expressions"); + } else { + zend_bad_method_call(fptr, method_name, scope); } + + return FAILURE; } } else { if (ce->__callstatic) { diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 48e0e86d3b2f8..256f08e05d6a6 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -89,14 +89,9 @@ ZEND_FUNCTION(clone) RETURN_THROWS(); } - if (clone && !(clone->common.fn_flags & ZEND_ACC_PUBLIC)) { - if (clone->common.scope != scope) { - if (UNEXPECTED(clone->common.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) { - zend_bad_method_call(clone, clone->common.function_name, scope); - RETURN_THROWS(); - } - } + if (clone && !zend_check_method_accessible(clone, scope)) { + zend_bad_method_call(clone, clone->common.function_name, scope); + RETURN_THROWS(); } zend_object *cloned; @@ -953,13 +948,7 @@ ZEND_FUNCTION(get_class_methods) scope = zend_get_executed_scope(); ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, mptr) { - if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC) - || (scope && - (((mptr->common.fn_flags & ZEND_ACC_PROTECTED) && - zend_check_protected(mptr->common.scope, scope)) - || ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) && - scope == mptr->common.scope))) - ) { + if (zend_check_method_accessible(mptr, scope)) { ZVAL_STR_COPY(&method_name, mptr->common.function_name); zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name); } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 971df5a7f232a..df58906881fd3 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1949,17 +1949,15 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st zval *func = zend_hash_find(&ce->function_table, lc_function_name); if (EXPECTED(func)) { fbc = Z_FUNC_P(func); - if (!(fbc->op_array.fn_flags & ZEND_ACC_PUBLIC)) { + if (!(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) { zend_class_entry *scope = zend_get_executed_scope(); - if (UNEXPECTED(fbc->common.scope != scope)) { - if (UNEXPECTED(fbc->op_array.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(fbc), scope))) { - zend_function *fallback_fbc = get_static_method_fallback(ce, function_name); - if (!fallback_fbc) { - zend_bad_method_call(fbc, function_name, scope); - } - fbc = fallback_fbc; + ZEND_ASSERT(!(fbc->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(fbc, scope)) { + zend_function *fallback_fbc = get_static_method_fallback(ce, function_name); + if (!fallback_fbc) { + zend_bad_method_call(fbc, function_name, scope); } + fbc = fallback_fbc; } } } else { @@ -2115,15 +2113,13 @@ ZEND_API zend_function *zend_std_get_constructor(zend_object *zobj) /* {{{ */ zend_function *constructor = zobj->ce->constructor; if (constructor) { - if (UNEXPECTED(!(constructor->op_array.fn_flags & ZEND_ACC_PUBLIC))) { + if (UNEXPECTED(!(constructor->common.fn_flags & ZEND_ACC_PUBLIC))) { zend_class_entry *scope = get_fake_or_executed_scope(); - if (UNEXPECTED(constructor->common.scope != scope)) { - if (UNEXPECTED(constructor->op_array.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(constructor), scope))) { - zend_bad_constructor_call(constructor, scope); - zend_object_store_ctor_failed(zobj); - constructor = NULL; - } + ZEND_ASSERT(!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(constructor, scope)) { + zend_bad_constructor_call(constructor, scope); + zend_object_store_ctor_failed(zobj); + constructor = NULL; } } } diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index fd0e97c5f4131..45bbc60cdb33f 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -123,49 +123,25 @@ ZEND_API void zend_objects_destroy_object(zend_object *object) zend_object *old_exception; const zend_op *old_opline_before_exception; - if (destructor->op_array.fn_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) { - if (destructor->op_array.fn_flags & ZEND_ACC_PRIVATE) { - /* Ensure that if we're calling a private function, we're allowed to do so. - */ - if (EG(current_execute_data)) { - zend_class_entry *scope = zend_get_executed_scope(); - - if (object->ce != scope) { - zend_throw_error(NULL, - "Call to private %s::__destruct() from %s%s", - ZSTR_VAL(object->ce->name), - scope ? "scope " : "global scope", - scope ? ZSTR_VAL(scope->name) : "" - ); - return; - } - } else { - zend_error(E_WARNING, - "Call to private %s::__destruct() from global scope during shutdown ignored", - ZSTR_VAL(object->ce->name)); + if (destructor->common.fn_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) { + if (EG(current_execute_data)) { + zend_class_entry *scope = zend_get_executed_scope(); + /* Ensure that if we're calling a protected or private function, we're allowed to do so. */ + ZEND_ASSERT(!(destructor->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(destructor, scope)) { + zend_throw_error(NULL, + "Call to %s %s::__destruct() from %s%s", + zend_visibility_string(destructor->common.fn_flags), ZSTR_VAL(object->ce->name), + scope ? "scope " : "global scope", + scope ? ZSTR_VAL(scope->name) : "" + ); return; } } else { - /* Ensure that if we're calling a protected function, we're allowed to do so. - */ - if (EG(current_execute_data)) { - zend_class_entry *scope = zend_get_executed_scope(); - - if (!zend_check_protected(zend_get_function_root_class(destructor), scope)) { - zend_throw_error(NULL, - "Call to protected %s::__destruct() from %s%s", - ZSTR_VAL(object->ce->name), - scope ? "scope " : "global scope", - scope ? ZSTR_VAL(scope->name) : "" - ); - return; - } - } else { - zend_error(E_WARNING, - "Call to protected %s::__destruct() from global scope during shutdown ignored", - ZSTR_VAL(object->ce->name)); - return; - } + zend_error(E_WARNING, + "Call to %s %s::__destruct() from global scope during shutdown ignored", + zend_visibility_string(destructor->common.fn_flags), ZSTR_VAL(object->ce->name)); + return; } } diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h index 242bf212ba9c6..86c3a49f8c8c5 100644 --- a/Zend/zend_objects_API.h +++ b/Zend/zend_objects_API.h @@ -137,5 +137,16 @@ static inline zend_property_info *zend_get_typed_property_info_for_slot(zend_obj return NULL; } +static zend_always_inline bool zend_check_method_accessible(const zend_function *fn, const zend_class_entry *scope) +{ + if (!(fn->common.fn_flags & ZEND_ACC_PUBLIC) + && fn->common.scope != scope + && (UNEXPECTED(fn->common.fn_flags & ZEND_ACC_PRIVATE) + || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(fn), scope)))) { + return false; + } + + return true; +} #endif /* ZEND_OBJECTS_H */ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9f7042386a152..c0e05aef470ae 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6043,14 +6043,12 @@ ZEND_VM_COLD_CONST_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY) if (clone && !(clone->common.fn_flags & ZEND_ACC_PUBLIC)) { scope = EX(func)->op_array.scope; - if (clone->common.scope != scope) { - if (UNEXPECTED(clone->common.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) { - zend_bad_method_call(clone, clone->common.function_name, scope); - FREE_OP1(); - ZVAL_UNDEF(EX_VAR(opline->result.var)); - HANDLE_EXCEPTION(); - } + ZEND_ASSERT(!(clone->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(clone, scope)) { + zend_bad_method_call(clone, clone->common.function_name, scope); + FREE_OP1(); + ZVAL_UNDEF(EX_VAR(opline->result.var)); + HANDLE_EXCEPTION(); } } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index cb2af9e49dd64..e79d843e6abf9 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -5217,14 +5217,12 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CONST_ if (clone && !(clone->common.fn_flags & ZEND_ACC_PUBLIC)) { scope = EX(func)->op_array.scope; - if (clone->common.scope != scope) { - if (UNEXPECTED(clone->common.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) { - zend_bad_method_call(clone, clone->common.function_name, scope); + ZEND_ASSERT(!(clone->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(clone, scope)) { + zend_bad_method_call(clone, clone->common.function_name, scope); - ZVAL_UNDEF(EX_VAR(opline->result.var)); - HANDLE_EXCEPTION(); - } + ZVAL_UNDEF(EX_VAR(opline->result.var)); + HANDLE_EXCEPTION(); } } @@ -15466,14 +15464,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_TMPVAR_HANDLER(ZEND if (clone && !(clone->common.fn_flags & ZEND_ACC_PUBLIC)) { scope = EX(func)->op_array.scope; - if (clone->common.scope != scope) { - if (UNEXPECTED(clone->common.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) { - zend_bad_method_call(clone, clone->common.function_name, scope); - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); - ZVAL_UNDEF(EX_VAR(opline->result.var)); - HANDLE_EXCEPTION(); - } + ZEND_ASSERT(!(clone->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(clone, scope)) { + zend_bad_method_call(clone, clone->common.function_name, scope); + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); + ZVAL_UNDEF(EX_VAR(opline->result.var)); + HANDLE_EXCEPTION(); } } @@ -33563,14 +33559,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND if (clone && !(clone->common.fn_flags & ZEND_ACC_PUBLIC)) { scope = EX(func)->op_array.scope; - if (clone->common.scope != scope) { - if (UNEXPECTED(clone->common.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) { - zend_bad_method_call(clone, clone->common.function_name, scope); + ZEND_ASSERT(!(clone->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(clone, scope)) { + zend_bad_method_call(clone, clone->common.function_name, scope); - ZVAL_UNDEF(EX_VAR(opline->result.var)); - HANDLE_EXCEPTION(); - } + ZVAL_UNDEF(EX_VAR(opline->result.var)); + HANDLE_EXCEPTION(); } } @@ -41084,14 +41078,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPC if (clone && !(clone->common.fn_flags & ZEND_ACC_PUBLIC)) { scope = EX(func)->op_array.scope; - if (clone->common.scope != scope) { - if (UNEXPECTED(clone->common.fn_flags & ZEND_ACC_PRIVATE) - || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) { - zend_bad_method_call(clone, clone->common.function_name, scope); + ZEND_ASSERT(!(clone->common.fn_flags & ZEND_ACC_PUBLIC)); + if (!zend_check_method_accessible(clone, scope)) { + zend_bad_method_call(clone, clone->common.function_name, scope); - ZVAL_UNDEF(EX_VAR(opline->result.var)); - HANDLE_EXCEPTION(); - } + ZVAL_UNDEF(EX_VAR(opline->result.var)); + HANDLE_EXCEPTION(); } } From 45215d0e78db6de25041ac01db324142def3f6cd Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Mon, 7 Jul 2025 12:33:36 -0700 Subject: [PATCH 4/7] php_spl.c: fix typo in `spl_classes()` description [skip ci] --- ext/spl/php_spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 1149be29bd46e..e6134c94b721d 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -213,7 +213,7 @@ PHP_FUNCTION(class_uses) SPL_ADD_CLASS(UnderflowException, z_list, sub, allow, ce_flags); \ SPL_ADD_CLASS(UnexpectedValueException, z_list, sub, allow, ce_flags); \ -/* {{{ Return an array containing the names of all clsses and interfaces defined in SPL */ +/* {{{ Return an array containing the names of all classes and interfaces defined in SPL */ PHP_FUNCTION(spl_classes) { if (zend_parse_parameters_none() == FAILURE) { From 6cc21c4ee655e7e5be29fcae95eb542f01a98832 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 8 May 2025 23:13:32 +0200 Subject: [PATCH 5/7] Optimize pack() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of using lookup tables, we can use a combination of shifts and byte swapping to achieve the same thing in less cycles and with less code. Benchmark files --------------- pack1.php: ```php for ($i = 0; $i < 10_000_000; ++$i) { pack("J", 0x7FFFFFFFFFFFFFFF); } ``` pack2.php: ```php for ($i = 0; $i < 4000000; ++$i) { pack("nvc*", 0x1234, 0x5678, 65, 66); } ``` On an i7-4790: ``` Benchmark 1: ./sapi/cli/php pack1.php Time (mean ± σ): 408.8 ms ± 3.4 ms [User: 406.1 ms, System: 1.6 ms] Range (min … max): 403.6 ms … 413.6 ms 10 runs Benchmark 2: ./sapi/cli/php_old pack1.php Time (mean ± σ): 451.7 ms ± 7.7 ms [User: 448.5 ms, System: 2.0 ms] Range (min … max): 442.8 ms … 461.2 ms 10 runs Summary ./sapi/cli/php pack1.php ran 1.11 ± 0.02 times faster than ./sapi/cli/php_old pack1.php Benchmark 1: ./sapi/cli/php pack2.php Time (mean ± σ): 239.3 ms ± 6.0 ms [User: 236.2 ms, System: 2.3 ms] Range (min … max): 233.2 ms … 256.8 ms 12 runs Benchmark 2: ./sapi/cli/php_old pack2.php Time (mean ± σ): 271.9 ms ± 3.3 ms [User: 269.7 ms, System: 1.3 ms] Range (min … max): 267.4 ms … 279.0 ms 11 runs Summary ./sapi/cli/php pack2.php ran 1.14 ± 0.03 times faster than ./sapi/cli/php_old pack2.php ``` On an i7-1185G7: ``` Benchmark 1: ./sapi/cli/php pack1.php Time (mean ± σ): 263.7 ms ± 1.8 ms [User: 262.6 ms, System: 0.9 ms] Range (min … max): 261.5 ms … 268.2 ms 11 runs Benchmark 2: ./sapi/cli/php_old pack1.php Time (mean ± σ): 303.3 ms ± 6.5 ms [User: 300.7 ms, System: 2.3 ms] Range (min … max): 297.4 ms … 318.1 ms 10 runs Summary ./sapi/cli/php pack1.php ran 1.15 ± 0.03 times faster than ./sapi/cli/php_old pack1.php Benchmark 1: ./sapi/cli/php pack2.php Time (mean ± σ): 156.7 ms ± 2.9 ms [User: 154.7 ms, System: 1.7 ms] Range (min … max): 151.6 ms … 164.7 ms 19 runs Benchmark 2: ./sapi/cli/php_old pack2.php Time (mean ± σ): 174.6 ms ± 3.3 ms [User: 171.9 ms, System: 2.3 ms] Range (min … max): 170.7 ms … 180.4 ms 17 runs Summary ./sapi/cli/php pack2.php ran 1.11 ± 0.03 times faster than ./sapi/cli/php_old pack2.php ``` Closes GH-18524. Co-authored-by: divinity76 --- NEWS | 3 + UPGRADING | 1 + ext/standard/basic_functions.c | 1 - ext/standard/pack.c | 219 +++++++-------------------------- ext/standard/pack.h | 22 ---- ext/standard/php_standard.h | 1 - 6 files changed, 47 insertions(+), 200 deletions(-) delete mode 100644 ext/standard/pack.h diff --git a/NEWS b/NEWS index 391593dc0c965..9cdd584528ae9 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.5.0alpha2 +- Standard: + . Optimized pack(). (nielsdos, divinity76) + - URI: . Return the singleton UrlValidationErrorType instances from Uri\WhatWg\Url instead of creating new objects that are different from the singleton. diff --git a/UPGRADING b/UPGRADING index 5491d85f529d8..06e48c3f12be7 100644 --- a/UPGRADING +++ b/UPGRADING @@ -619,6 +619,7 @@ PHP 8.5 UPGRADE NOTES . Improved performance of urlencode() and rawurlencode(). . Improved unpack() performance with nameless repetitions by avoiding creating temporary strings and reparsing them. + . Improved pack() performance. - XMLReader: . Improved property access performance. diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index f26bef3daa4e7..ea2f8884bdef6 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -299,7 +299,6 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */ BASIC_MINIT_SUBMODULE(var) BASIC_MINIT_SUBMODULE(file) - BASIC_MINIT_SUBMODULE(pack) BASIC_MINIT_SUBMODULE(browscap) BASIC_MINIT_SUBMODULE(standard_filters) BASIC_MINIT_SUBMODULE(user_filters) diff --git a/ext/standard/pack.c b/ext/standard/pack.c index bcac949d56329..55da64897a2e7 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -19,7 +19,6 @@ #include #include #include -#include "pack.h" #define INC_OUTPUTPOS(a,b) \ if ((a) < 0 || ((INT_MAX - outputpos)/((int)b)) < (a)) { \ @@ -30,10 +29,23 @@ } \ outputpos += (a)*(b); +typedef enum { + PHP_LITTLE_ENDIAN, + PHP_BIG_ENDIAN, +} php_pack_endianness; + #ifdef WORDS_BIGENDIAN -#define MACHINE_LITTLE_ENDIAN 0 +# define MACHINE_LITTLE_ENDIAN 0 +# define PHP_MACHINE_ENDIAN PHP_BIG_ENDIAN #else -#define MACHINE_LITTLE_ENDIAN 1 +# define MACHINE_LITTLE_ENDIAN 1 +# define PHP_MACHINE_ENDIAN PHP_LITTLE_ENDIAN +#endif + +#ifdef ZEND_ENABLE_ZVAL_LONG64 +# define PHP_LONG_BSWAP(u) ZEND_BYTES_SWAP64(u) +#else +# define PHP_LONG_BSWAP(u) ZEND_BYTES_SWAP32(u) #endif typedef ZEND_SET_ALIGNED(1, uint16_t unaligned_uint16_t); @@ -42,41 +54,23 @@ typedef ZEND_SET_ALIGNED(1, uint64_t unaligned_uint64_t); typedef ZEND_SET_ALIGNED(1, unsigned int unaligned_uint); typedef ZEND_SET_ALIGNED(1, int unaligned_int); -/* Mapping of byte from char (8bit) to long for machine endian */ -static int byte_map[1]; - -/* Mappings of bytes from int (machine dependent) to int for machine endian */ -static int int_map[sizeof(int)]; - -/* Mappings of bytes from shorts (16bit) for all endian environments */ -static int machine_endian_short_map[2]; -static int big_endian_short_map[2]; -static int little_endian_short_map[2]; - -/* Mappings of bytes from longs (32bit) for all endian environments */ -static int machine_endian_long_map[4]; -static int big_endian_long_map[4]; -static int little_endian_long_map[4]; - -#if SIZEOF_ZEND_LONG > 4 -/* Mappings of bytes from quads (64bit) for all endian environments */ -static int machine_endian_longlong_map[8]; -static int big_endian_longlong_map[8]; -static int little_endian_longlong_map[8]; -#endif - /* {{{ php_pack */ -static void php_pack(zval *val, size_t size, int *map, char *output) +static void php_pack(const zval *val, size_t size, php_pack_endianness endianness, char *output) { - size_t i; - char *v; - - convert_to_long(val); - v = (char *) &Z_LVAL_P(val); + zend_ulong zl = zval_get_long(val); - for (i = 0; i < size; i++) { - *output++ = v[map[i]]; + if ((endianness == PHP_LITTLE_ENDIAN) != MACHINE_LITTLE_ENDIAN) { + zl = PHP_LONG_BSWAP(zl); +#if MACHINE_LITTLE_ENDIAN + zl >>= (sizeof(zl) - size) * 8; +#endif + } else { +#if !MACHINE_LITTLE_ENDIAN + zl <<= (sizeof(zl) - size) * 8; +#endif } + + memcpy(output, (const char *) &zl, size); } /* }}} */ @@ -88,10 +82,7 @@ ZEND_ATTRIBUTE_CONST static inline uint16_t php_pack_reverse_int16(uint16_t arg) /* {{{ php_pack_reverse_int32 */ ZEND_ATTRIBUTE_CONST static inline uint32_t php_pack_reverse_int32(uint32_t arg) { - uint32_t result; - result = ((arg & 0xFF) << 24) | ((arg & 0xFF00) << 8) | ((arg >> 8) & 0xFF00) | ((arg >> 24) & 0xFF); - - return result; + return ZEND_BYTES_SWAP32(arg); } /* }}} */ @@ -509,7 +500,7 @@ PHP_FUNCTION(pack) case 'c': case 'C': while (arg-- > 0) { - php_pack(&argv[currentarg++], 1, byte_map, &ZSTR_VAL(output)[outputpos]); + php_pack(&argv[currentarg++], 1, PHP_MACHINE_ENDIAN, &ZSTR_VAL(output)[outputpos]); outputpos++; } break; @@ -518,16 +509,16 @@ PHP_FUNCTION(pack) case 'S': case 'n': case 'v': { - int *map = machine_endian_short_map; + php_pack_endianness endianness = PHP_MACHINE_ENDIAN; if (code == 'n') { - map = big_endian_short_map; + endianness = PHP_BIG_ENDIAN; } else if (code == 'v') { - map = little_endian_short_map; + endianness = PHP_LITTLE_ENDIAN; } while (arg-- > 0) { - php_pack(&argv[currentarg++], 2, map, &ZSTR_VAL(output)[outputpos]); + php_pack(&argv[currentarg++], 2, endianness, &ZSTR_VAL(output)[outputpos]); outputpos += 2; } break; @@ -536,7 +527,7 @@ PHP_FUNCTION(pack) case 'i': case 'I': while (arg-- > 0) { - php_pack(&argv[currentarg++], sizeof(int), int_map, &ZSTR_VAL(output)[outputpos]); + php_pack(&argv[currentarg++], sizeof(int), PHP_MACHINE_ENDIAN, &ZSTR_VAL(output)[outputpos]); outputpos += sizeof(int); } break; @@ -545,16 +536,16 @@ PHP_FUNCTION(pack) case 'L': case 'N': case 'V': { - int *map = machine_endian_long_map; + php_pack_endianness endianness = PHP_MACHINE_ENDIAN; if (code == 'N') { - map = big_endian_long_map; + endianness = PHP_BIG_ENDIAN; } else if (code == 'V') { - map = little_endian_long_map; + endianness = PHP_LITTLE_ENDIAN; } while (arg-- > 0) { - php_pack(&argv[currentarg++], 4, map, &ZSTR_VAL(output)[outputpos]); + php_pack(&argv[currentarg++], 4, endianness, &ZSTR_VAL(output)[outputpos]); outputpos += 4; } break; @@ -565,16 +556,16 @@ PHP_FUNCTION(pack) case 'Q': case 'J': case 'P': { - int *map = machine_endian_longlong_map; + php_pack_endianness endianness = PHP_MACHINE_ENDIAN; if (code == 'J') { - map = big_endian_longlong_map; + endianness = PHP_BIG_ENDIAN; } else if (code == 'P') { - map = little_endian_longlong_map; + endianness = PHP_LITTLE_ENDIAN; } while (arg-- > 0) { - php_pack(&argv[currentarg++], 8, map, &ZSTR_VAL(output)[outputpos]); + php_pack(&argv[currentarg++], 8, endianness, &ZSTR_VAL(output)[outputpos]); outputpos += 8; } break; @@ -1178,127 +1169,3 @@ PHP_FUNCTION(unpack) } } /* }}} */ - -/* {{{ PHP_MINIT_FUNCTION */ -PHP_MINIT_FUNCTION(pack) -{ - int i; - - if (MACHINE_LITTLE_ENDIAN) { - /* Where to get lo to hi bytes from */ - byte_map[0] = 0; - - for (i = 0; i < (int)sizeof(int); i++) { - int_map[i] = i; - } - - machine_endian_short_map[0] = 0; - machine_endian_short_map[1] = 1; - big_endian_short_map[0] = 1; - big_endian_short_map[1] = 0; - little_endian_short_map[0] = 0; - little_endian_short_map[1] = 1; - - machine_endian_long_map[0] = 0; - machine_endian_long_map[1] = 1; - machine_endian_long_map[2] = 2; - machine_endian_long_map[3] = 3; - big_endian_long_map[0] = 3; - big_endian_long_map[1] = 2; - big_endian_long_map[2] = 1; - big_endian_long_map[3] = 0; - little_endian_long_map[0] = 0; - little_endian_long_map[1] = 1; - little_endian_long_map[2] = 2; - little_endian_long_map[3] = 3; - -#if SIZEOF_ZEND_LONG > 4 - machine_endian_longlong_map[0] = 0; - machine_endian_longlong_map[1] = 1; - machine_endian_longlong_map[2] = 2; - machine_endian_longlong_map[3] = 3; - machine_endian_longlong_map[4] = 4; - machine_endian_longlong_map[5] = 5; - machine_endian_longlong_map[6] = 6; - machine_endian_longlong_map[7] = 7; - big_endian_longlong_map[0] = 7; - big_endian_longlong_map[1] = 6; - big_endian_longlong_map[2] = 5; - big_endian_longlong_map[3] = 4; - big_endian_longlong_map[4] = 3; - big_endian_longlong_map[5] = 2; - big_endian_longlong_map[6] = 1; - big_endian_longlong_map[7] = 0; - little_endian_longlong_map[0] = 0; - little_endian_longlong_map[1] = 1; - little_endian_longlong_map[2] = 2; - little_endian_longlong_map[3] = 3; - little_endian_longlong_map[4] = 4; - little_endian_longlong_map[5] = 5; - little_endian_longlong_map[6] = 6; - little_endian_longlong_map[7] = 7; -#endif - } - else { - zval val; - int size = sizeof(Z_LVAL(val)); - Z_LVAL(val)=0; /*silence a warning*/ - - /* Where to get hi to lo bytes from */ - byte_map[0] = size - 1; - - for (i = 0; i < (int)sizeof(int); i++) { - int_map[i] = size - (sizeof(int) - i); - } - - machine_endian_short_map[0] = size - 2; - machine_endian_short_map[1] = size - 1; - big_endian_short_map[0] = size - 2; - big_endian_short_map[1] = size - 1; - little_endian_short_map[0] = size - 1; - little_endian_short_map[1] = size - 2; - - machine_endian_long_map[0] = size - 4; - machine_endian_long_map[1] = size - 3; - machine_endian_long_map[2] = size - 2; - machine_endian_long_map[3] = size - 1; - big_endian_long_map[0] = size - 4; - big_endian_long_map[1] = size - 3; - big_endian_long_map[2] = size - 2; - big_endian_long_map[3] = size - 1; - little_endian_long_map[0] = size - 1; - little_endian_long_map[1] = size - 2; - little_endian_long_map[2] = size - 3; - little_endian_long_map[3] = size - 4; - -#if SIZEOF_ZEND_LONG > 4 - machine_endian_longlong_map[0] = size - 8; - machine_endian_longlong_map[1] = size - 7; - machine_endian_longlong_map[2] = size - 6; - machine_endian_longlong_map[3] = size - 5; - machine_endian_longlong_map[4] = size - 4; - machine_endian_longlong_map[5] = size - 3; - machine_endian_longlong_map[6] = size - 2; - machine_endian_longlong_map[7] = size - 1; - big_endian_longlong_map[0] = size - 8; - big_endian_longlong_map[1] = size - 7; - big_endian_longlong_map[2] = size - 6; - big_endian_longlong_map[3] = size - 5; - big_endian_longlong_map[4] = size - 4; - big_endian_longlong_map[5] = size - 3; - big_endian_longlong_map[6] = size - 2; - big_endian_longlong_map[7] = size - 1; - little_endian_longlong_map[0] = size - 1; - little_endian_longlong_map[1] = size - 2; - little_endian_longlong_map[2] = size - 3; - little_endian_longlong_map[3] = size - 4; - little_endian_longlong_map[4] = size - 5; - little_endian_longlong_map[5] = size - 6; - little_endian_longlong_map[6] = size - 7; - little_endian_longlong_map[7] = size - 8; -#endif - } - - return SUCCESS; -} -/* }}} */ diff --git a/ext/standard/pack.h b/ext/standard/pack.h deleted file mode 100644 index 5e12d55e0bc63..0000000000000 --- a/ext/standard/pack.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Copyright (c) The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | https://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Rasmus Lerdorf | - +----------------------------------------------------------------------+ -*/ - -#ifndef PACK_H -#define PACK_H - -PHP_MINIT_FUNCTION(pack); - -#endif /* PACK_H */ diff --git a/ext/standard/php_standard.h b/ext/standard/php_standard.h index 78eba25f11a58..5bc792362bbd2 100644 --- a/ext/standard/php_standard.h +++ b/ext/standard/php_standard.h @@ -29,7 +29,6 @@ #include "php_ext_syslog.h" #include "php_filestat.h" #include "php_browscap.h" -#include "pack.h" #include "url.h" #include "pageinfo.h" #include "fsock.h" From d8577d9bfbb89bc2924b0bcb60a8e7fb5fd5267a Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Mon, 7 Jul 2025 14:31:13 -0700 Subject: [PATCH 6/7] Deprecate returning non-string values from a user output handler (#18932) https://wiki.php.net/rfc/deprecations_php_8_4 --- UPGRADING | 7 + Zend/tests/concat/bug79836.phpt | 1 + Zend/tests/concat/bug79836_1.phpt | 1 + Zend/tests/concat/bug79836_2.phpt | 1 + Zend/tests/declare/gh18033_2.phpt | 1 + Zend/tests/gh11189.phpt | 1 + Zend/tests/gh11189_1.phpt | 1 + Zend/tests/gh16408.phpt | 1 + .../tests/user_session_module/bug61728.phpt | 2 +- main/output.c | 81 ++++++++-- sapi/cli/tests/gh8827-002.phpt | 1 + sapi/cli/tests/gh8827-003.phpt | 1 + tests/output/bug60768.phpt | 2 +- tests/output/ob_start_basic_002.phpt | 9 +- .../exception_handler.phpt | 147 ++++++++++++++++++ .../exception_handler_nested.phpt | 143 +++++++++++++++++ .../handler_false_removed.phpt | 23 +++ .../handler_is_stringable_removed.phpt | 30 ++++ .../handler_non_stringable_removed.phpt | 32 ++++ .../handler_true_removed.phpt | 23 +++ .../handler_zero_removed.phpt | 23 +++ .../multiple_handlers.phpt | 89 +++++++++++ 22 files changed, 603 insertions(+), 17 deletions(-) create mode 100644 tests/output/ob_start_callback_bad_return/exception_handler.phpt create mode 100644 tests/output/ob_start_callback_bad_return/exception_handler_nested.phpt create mode 100644 tests/output/ob_start_callback_bad_return/handler_false_removed.phpt create mode 100644 tests/output/ob_start_callback_bad_return/handler_is_stringable_removed.phpt create mode 100644 tests/output/ob_start_callback_bad_return/handler_non_stringable_removed.phpt create mode 100644 tests/output/ob_start_callback_bad_return/handler_true_removed.phpt create mode 100644 tests/output/ob_start_callback_bad_return/handler_zero_removed.phpt create mode 100644 tests/output/ob_start_callback_bad_return/multiple_handlers.phpt diff --git a/UPGRADING b/UPGRADING index 06e48c3f12be7..7b264b0703bc1 100644 --- a/UPGRADING +++ b/UPGRADING @@ -259,6 +259,13 @@ PHP 8.5 UPGRADE NOTES 4. Deprecated Functionality ======================================== +- Core: + . Returning a non-string from a user output handler is deprecated. The + deprecation warning will bypass the handler with the bad return to ensure + it is visible; if there are nested output handlers the next one will still + be used. + RFC: https://wiki.php.net/rfc/deprecations_php_8_4 + - Hash: . The MHASH_* constants have been deprecated. These have been overlooked when the mhash*() function family has been deprecated per diff --git a/Zend/tests/concat/bug79836.phpt b/Zend/tests/concat/bug79836.phpt index 5fb07396762f5..87db276337098 100644 --- a/Zend/tests/concat/bug79836.phpt +++ b/Zend/tests/concat/bug79836.phpt @@ -8,6 +8,7 @@ $counter = 0; ob_start(function ($buffer) use (&$c, &$counter) { $c = 0; ++$counter; + return ''; }, 1); $c .= []; $c .= []; diff --git a/Zend/tests/concat/bug79836_1.phpt b/Zend/tests/concat/bug79836_1.phpt index 86e7f47671849..972b387235698 100644 --- a/Zend/tests/concat/bug79836_1.phpt +++ b/Zend/tests/concat/bug79836_1.phpt @@ -7,6 +7,7 @@ opcache.optimization_level = 0x7FFEBFFF & ~0x400 $x = 'non-empty'; ob_start(function () use (&$c) { $c = 0; + return ''; }, 1); $c = []; $x = $c . $x; diff --git a/Zend/tests/concat/bug79836_2.phpt b/Zend/tests/concat/bug79836_2.phpt index b02fcc13ea11b..de528e5c42fac 100644 --- a/Zend/tests/concat/bug79836_2.phpt +++ b/Zend/tests/concat/bug79836_2.phpt @@ -6,6 +6,7 @@ $c = str_repeat("abcd", 10); ob_start(function () use (&$c) { $c = 0; + return ''; }, 1); class X { diff --git a/Zend/tests/declare/gh18033_2.phpt b/Zend/tests/declare/gh18033_2.phpt index 8fdcff1b51e6c..39fb46144eed5 100644 --- a/Zend/tests/declare/gh18033_2.phpt +++ b/Zend/tests/declare/gh18033_2.phpt @@ -11,6 +11,7 @@ ob_start(function() { register_tick_function( function() { } ); + return ''; }); ?> --EXPECT-- diff --git a/Zend/tests/gh11189.phpt b/Zend/tests/gh11189.phpt index adbc3ce487c95..9f8202b6102b3 100644 --- a/Zend/tests/gh11189.phpt +++ b/Zend/tests/gh11189.phpt @@ -18,6 +18,7 @@ ob_start(function() { $a[] = 2; } fwrite(STDOUT, "Success"); + return ''; }); $a = []; diff --git a/Zend/tests/gh11189_1.phpt b/Zend/tests/gh11189_1.phpt index 17b9967bc3182..d5b4ee92b62d6 100644 --- a/Zend/tests/gh11189_1.phpt +++ b/Zend/tests/gh11189_1.phpt @@ -18,6 +18,7 @@ ob_start(function() { $a[] = 2; } fwrite(STDOUT, "Success"); + return ''; }); $a = ["not packed" => 1]; diff --git a/Zend/tests/gh16408.phpt b/Zend/tests/gh16408.phpt index f28c6435bfe73..09d9e8cbb5249 100644 --- a/Zend/tests/gh16408.phpt +++ b/Zend/tests/gh16408.phpt @@ -6,6 +6,7 @@ $counter = 0; ob_start(function ($buffer) use (&$c, &$counter) { $c = 0; ++$counter; + return ''; }, 1); $c .= []; $c .= []; diff --git a/ext/session/tests/user_session_module/bug61728.phpt b/ext/session/tests/user_session_module/bug61728.phpt index fd79fa6b2bce4..152cf9f42beef 100644 --- a/ext/session/tests/user_session_module/bug61728.phpt +++ b/ext/session/tests/user_session_module/bug61728.phpt @@ -5,7 +5,7 @@ session --FILE-- in) && !context->op) { context->op = original_op; @@ -948,6 +949,7 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl if (handler->flags & PHP_OUTPUT_HANDLER_USER) { zval ob_args[2]; zval retval; + ZVAL_UNDEF(&retval); /* ob_data */ ZVAL_STRINGL(&ob_args[0], handler->buffer.data, handler->buffer.used); @@ -959,17 +961,48 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl handler->func.user->fci.params = ob_args; handler->func.user->fci.retval = &retval; -#define PHP_OUTPUT_USER_SUCCESS(retval) ((Z_TYPE(retval) != IS_UNDEF) && !(Z_TYPE(retval) == IS_FALSE)) - if (SUCCESS == zend_call_function(&handler->func.user->fci, &handler->func.user->fcc) && PHP_OUTPUT_USER_SUCCESS(retval)) { - /* user handler may have returned TRUE */ - status = PHP_OUTPUT_HANDLER_NO_DATA; - if (Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) { - convert_to_string(&retval); - if (Z_STRLEN(retval)) { - context->out.data = estrndup(Z_STRVAL(retval), Z_STRLEN(retval)); - context->out.used = Z_STRLEN(retval); - context->out.free = 1; - status = PHP_OUTPUT_HANDLER_SUCCESS; + if (SUCCESS == zend_call_function(&handler->func.user->fci, &handler->func.user->fcc) && Z_TYPE(retval) != IS_UNDEF) { + if (Z_TYPE(retval) != IS_STRING) { + // Make sure that we don't get lost in the current output buffer + // by disabling it + handler->flags |= PHP_OUTPUT_HANDLER_DISABLED; + php_error_docref( + NULL, + E_DEPRECATED, + "Returning a non-string result from user output handler %s is deprecated", + ZSTR_VAL(handler->name) + ); + // Check if the handler is still in the list of handlers to + // determine if the PHP_OUTPUT_HANDLER_DISABLED flag can + // be removed + still_have_handler = false; + int handler_count = php_output_get_level(); + if (handler_count) { + php_output_handler **handlers = (php_output_handler **) zend_stack_base(&OG(handlers)); + for (int handler_num = 0; handler_num < handler_count; ++handler_num) { + php_output_handler *curr_handler = handlers[handler_num]; + if (curr_handler == handler) { + handler->flags &= (~PHP_OUTPUT_HANDLER_DISABLED); + still_have_handler = true; + break; + } + } + } + } + if (Z_TYPE(retval) == IS_FALSE) { + /* call failed, pass internal buffer along */ + status = PHP_OUTPUT_HANDLER_FAILURE; + } else { + /* user handler may have returned TRUE */ + status = PHP_OUTPUT_HANDLER_NO_DATA; + if (Z_TYPE(retval) != IS_FALSE && Z_TYPE(retval) != IS_TRUE) { + convert_to_string(&retval); + if (Z_STRLEN(retval)) { + context->out.data = estrndup(Z_STRVAL(retval), Z_STRLEN(retval)); + context->out.used = Z_STRLEN(retval); + context->out.free = 1; + status = PHP_OUTPUT_HANDLER_SUCCESS; + } } } } else { @@ -996,10 +1029,17 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl status = PHP_OUTPUT_HANDLER_FAILURE; } } - handler->flags |= PHP_OUTPUT_HANDLER_STARTED; + if (still_have_handler) { + handler->flags |= PHP_OUTPUT_HANDLER_STARTED; + } OG(running) = NULL; } + if (!still_have_handler) { + // Handler and context will have both already been freed + return status; + } + switch (status) { case PHP_OUTPUT_HANDLER_FAILURE: /* disable this handler */ @@ -1225,6 +1265,19 @@ static int php_output_stack_pop(int flags) } php_output_handler_op(orphan, &context); } + // If it isn't still in the stack, cannot free it + bool still_have_handler = false; + int handler_count = php_output_get_level(); + if (handler_count) { + php_output_handler **handlers = (php_output_handler **) zend_stack_base(&OG(handlers)); + for (int handler_num = 0; handler_num < handler_count; ++handler_num) { + php_output_handler *curr_handler = handlers[handler_num]; + if (curr_handler == orphan) { + still_have_handler = true; + break; + } + } + } /* pop it off the stack */ zend_stack_del_top(&OG(handlers)); @@ -1240,7 +1293,9 @@ static int php_output_stack_pop(int flags) } /* destroy the handler (after write!) */ - php_output_handler_free(&orphan); + if (still_have_handler) { + php_output_handler_free(&orphan); + } php_output_context_dtor(&context); return 1; diff --git a/sapi/cli/tests/gh8827-002.phpt b/sapi/cli/tests/gh8827-002.phpt index 00fd5cfa78f74..712d3e54e509f 100644 --- a/sapi/cli/tests/gh8827-002.phpt +++ b/sapi/cli/tests/gh8827-002.phpt @@ -18,6 +18,7 @@ $stderr = fopen('php://stderr', 'r'); ob_start(function ($buffer) use ($stdout) { fwrite($stdout, $buffer); + return ''; }, 1); print "STDIN:\n"; diff --git a/sapi/cli/tests/gh8827-003.phpt b/sapi/cli/tests/gh8827-003.phpt index 11f7880770ed9..12b6798a57c27 100644 --- a/sapi/cli/tests/gh8827-003.phpt +++ b/sapi/cli/tests/gh8827-003.phpt @@ -34,6 +34,7 @@ file_put_contents('php://fd/2', "Goes to stderrFile\n"); ob_start(function ($buffer) use ($stdoutStream) { fwrite($stdoutStream, $buffer); + return ''; }, 1); print "stdoutFile:\n"; diff --git a/tests/output/bug60768.phpt b/tests/output/bug60768.phpt index 4de7fbd69ff4b..1ab702fa64681 100644 --- a/tests/output/bug60768.phpt +++ b/tests/output/bug60768.phpt @@ -5,7 +5,7 @@ Bug #60768 Output buffer not discarded global $storage; -ob_start(function($buffer) use (&$storage) { $storage .= $buffer; }, 20); +ob_start(function($buffer) use (&$storage) { $storage .= $buffer; return ''; }, 20); echo str_repeat("0", 20); // fill in the buffer diff --git a/tests/output/ob_start_basic_002.phpt b/tests/output/ob_start_basic_002.phpt index 700dab5d3c381..e9af2b5e1904c 100644 --- a/tests/output/ob_start_basic_002.phpt +++ b/tests/output/ob_start_basic_002.phpt @@ -35,19 +35,24 @@ foreach ($callbacks as $callback) { } ?> ---EXPECT-- +--EXPECTF-- --> Use callback 'return_empty_string': --> Use callback 'return_false': + +Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_false is deprecated in %s on line %d My output. --> Use callback 'return_null': +Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated in %s on line %d + --> Use callback 'return_string': I stole your output. --> Use callback 'return_zero': -0 +Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated in %s on line %d +0 diff --git a/tests/output/ob_start_callback_bad_return/exception_handler.phpt b/tests/output/ob_start_callback_bad_return/exception_handler.phpt new file mode 100644 index 0000000000000..3a3ace427bbe0 --- /dev/null +++ b/tests/output/ob_start_callback_bad_return/exception_handler.phpt @@ -0,0 +1,147 @@ +--TEST-- +ob_start(): Check behaviour with deprecation converted to exception +--FILE-- +val; + } +} + +$log = []; + +set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { + throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); +}); + +function return_null($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return null; +} + +function return_false($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return false; +} + +function return_true($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return true; +} + +function return_zero($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return 0; +} + +function return_non_stringable($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return new NotStringable($string); +} + +function return_stringable($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return new IsStringable($string); +} + +$cases = [ + 'return_null', + 'return_false', + 'return_true', + 'return_zero', + 'return_non_stringable', + 'return_stringable', +]; +foreach ($cases as $case) { + $log = []; + echo "\n\nTesting: $case\n"; + ob_start($case); + echo "Inside of $case\n"; + try { + ob_end_flush(); + } catch (\ErrorException $e) { + echo $e . "\n"; + } + echo "\nEnd of $case, log was:\n"; + echo implode("\n", $log); +} + +?> +--EXPECTF-- +Testing: return_null +ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated in %s:%d +Stack trace: +#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) +#1 %s(%d): ob_end_flush() +#2 {main} + +End of return_null, log was: +return_null: <<>> + +Testing: return_false +Inside of return_false +ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_false is deprecated in %s:%d +Stack trace: +#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) +#1 %s(%d): ob_end_flush() +#2 {main} + +End of return_false, log was: +return_false: <<>> + +Testing: return_true +ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_true is deprecated in %s:%d +Stack trace: +#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) +#1 %s(%d): ob_end_flush() +#2 {main} + +End of return_true, log was: +return_true: <<>> + +Testing: return_zero +0ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated in %s:%d +Stack trace: +#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, %d) +#1 %s(%d): ob_end_flush() +#2 {main} + +End of return_zero, log was: +return_zero: <<>> + +Testing: return_non_stringable +ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_non_stringable is deprecated in %s:%d +Stack trace: +#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, 69) +#1 %s(%d): ob_end_flush() +#2 {main} + +End of return_non_stringable, log was: +return_non_stringable: <<>> + +Testing: return_stringable +ErrorException: ob_end_flush(): Returning a non-string result from user output handler return_stringable is deprecated in %s:%d +Stack trace: +#0 [internal function]: {closure:%s:%d}(8192, 'ob_end_flush():...', %s, 69) +#1 %s(%d): ob_end_flush() +#2 {main} + +End of return_stringable, log was: +return_stringable: <<>> diff --git a/tests/output/ob_start_callback_bad_return/exception_handler_nested.phpt b/tests/output/ob_start_callback_bad_return/exception_handler_nested.phpt new file mode 100644 index 0000000000000..fcc58ba1cc5f4 --- /dev/null +++ b/tests/output/ob_start_callback_bad_return/exception_handler_nested.phpt @@ -0,0 +1,143 @@ +--TEST-- +ob_start(): Check behaviour with deprecation converted to exception +--FILE-- +val; + } +} + +$log = []; + +set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) { + throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); +}); + +function return_null($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return null; +} + +function return_false($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return false; +} + +function return_true($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return true; +} + +function return_zero($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return 0; +} + +function return_non_stringable($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return new NotStringable($string); +} + +function return_stringable($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return new IsStringable($string); +} + +ob_start('return_null'); +ob_start('return_false'); +ob_start('return_true'); +ob_start('return_zero'); +ob_start('return_non_stringable'); +ob_start('return_stringable'); + +echo "In all of them\n\n"; +try { + ob_end_flush(); +} catch (\ErrorException $e) { + echo $e->getMessage() . "\n"; +} +echo "Ended return_stringable handler\n\n"; + +try { + ob_end_flush(); +} catch (\ErrorException $e) { + echo $e->getMessage() . "\n"; +} +echo "Ended return_non_stringable handler\n\n"; + +try { + ob_end_flush(); +} catch (\ErrorException $e) { + echo $e->getMessage() . "\n"; +} +echo "Ended return_zero handler\n\n"; + +try { + ob_end_flush(); +} catch (\ErrorException $e) { + echo $e->getMessage() . "\n"; +} +echo "Ended return_true handler\n\n"; + +try { + ob_end_flush(); +} catch (\ErrorException $e) { + echo $e->getMessage() . "\n"; +} +echo "Ended return_false handler\n\n"; + +try { + ob_end_flush(); +} catch (\ErrorException $e) { + echo $e->getMessage() . "\n"; +} +echo "Ended return_null handler\n\n"; + +echo "All handlers are over\n\n"; +echo implode("\n", $log); + +?> +--EXPECT-- +ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated +Ended return_null handler + +All handlers are over + +return_stringable: <<>> +return_non_stringable: <<>> +return_zero: <<>> +return_true: <<<0ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated +Ended return_zero handler + +>>> +return_false: <<>> +return_null: <<>> diff --git a/tests/output/ob_start_callback_bad_return/handler_false_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_false_removed.phpt new file mode 100644 index 0000000000000..32702a58fcc14 --- /dev/null +++ b/tests/output/ob_start_callback_bad_return/handler_false_removed.phpt @@ -0,0 +1,23 @@ +--TEST-- +ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns false) +--INI-- +memory_limit=2M +--FILE-- + +--EXPECTF-- +Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d + +Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/handler_is_stringable_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_is_stringable_removed.phpt new file mode 100644 index 0000000000000..0d87358da1b9d --- /dev/null +++ b/tests/output/ob_start_callback_bad_return/handler_is_stringable_removed.phpt @@ -0,0 +1,30 @@ +--TEST-- +ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns stringable object) +--INI-- +memory_limit=2M +--FILE-- +val; + } +} + +ob_start(function() { + // We are out of memory, now trigger a deprecation + return new IsStringable(""); +}); + +$a = []; +// trigger OOM in a resize operation +while (1) { + $a[] = 1; +} + +?> +--EXPECTF-- +Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d + +Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/handler_non_stringable_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_non_stringable_removed.phpt new file mode 100644 index 0000000000000..65d8ccfbcba61 --- /dev/null +++ b/tests/output/ob_start_callback_bad_return/handler_non_stringable_removed.phpt @@ -0,0 +1,32 @@ +--TEST-- +ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns non-stringable object) +--INI-- +memory_limit=2M +--FILE-- + +--EXPECTF-- +Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d + +Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d + +Fatal error: Uncaught Error: Object of class NotStringable could not be converted to string in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/handler_true_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_true_removed.phpt new file mode 100644 index 0000000000000..5ad19826c4ac7 --- /dev/null +++ b/tests/output/ob_start_callback_bad_return/handler_true_removed.phpt @@ -0,0 +1,23 @@ +--TEST-- +ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns true) +--INI-- +memory_limit=2M +--FILE-- + +--EXPECTF-- +Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d + +Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/handler_zero_removed.phpt b/tests/output/ob_start_callback_bad_return/handler_zero_removed.phpt new file mode 100644 index 0000000000000..1bc7279c71d35 --- /dev/null +++ b/tests/output/ob_start_callback_bad_return/handler_zero_removed.phpt @@ -0,0 +1,23 @@ +--TEST-- +ob_start(): Check behaviour with deprecation when OOM triggers handler removal (handler returns zero) +--INI-- +memory_limit=2M +--FILE-- + +--EXPECTF-- +Deprecated: main(): Returning a non-string result from user output handler {closure:%s:%d} is deprecated in %s on line %d + +Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/tests/output/ob_start_callback_bad_return/multiple_handlers.phpt b/tests/output/ob_start_callback_bad_return/multiple_handlers.phpt new file mode 100644 index 0000000000000..fef8daf8783a2 --- /dev/null +++ b/tests/output/ob_start_callback_bad_return/multiple_handlers.phpt @@ -0,0 +1,89 @@ +--TEST-- +ob_start(): Check behaviour with multiple nested handlers with had return values +--FILE-- +>>"; + return $string; +} + +function return_empty_string($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return ""; +} + +function return_false($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return false; +} + +function return_true($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return true; +} + +function return_null($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return null; +} + +function return_string($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return "I stole your output."; +} + +function return_zero($string) { + global $log; + $log[] = __FUNCTION__ . ": <<<" . $string . ">>>"; + return 0; +} + +ob_start('return_given_string'); +ob_start('return_empty_string'); +ob_start('return_false'); +ob_start('return_true'); +ob_start('return_null'); +ob_start('return_string'); +ob_start('return_zero'); + +echo "Testing..."; + +ob_end_flush(); +ob_end_flush(); +ob_end_flush(); +ob_end_flush(); +ob_end_flush(); +ob_end_flush(); +ob_end_flush(); + +echo "\n\nLog:\n"; +echo implode("\n", $log); +?> +--EXPECTF-- +Log: +return_zero: <<>> +return_string: <<< +Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_zero is deprecated in %s on line %d +0>>> +return_null: <<>> +return_true: <<< +Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_null is deprecated in %s on line %d +>>> +return_false: <<< +Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_true is deprecated in %s on line %d +>>> +return_empty_string: <<< +Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_false is deprecated in %s on line %d + +Deprecated: ob_end_flush(): Returning a non-string result from user output handler return_true is deprecated in %s on line %d +>>> +return_given_string: <<<>>> From 64e2832bc8065f24c4d273075608f33826c71fd8 Mon Sep 17 00:00:00 2001 From: DanielEScherzer Date: Mon, 7 Jul 2025 14:53:59 -0700 Subject: [PATCH 7/7] Remove old zend_string compatibility aliases (#19034) --- UPGRADING.INTERNALS | 7 +++++++ Zend/zend_string.h | 9 --------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index d84a59105dcf4..f59e5165d0842 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -48,6 +48,13 @@ PHP 8.5 INTERNALS UPGRADE NOTES directly. . ZEND_IS_XDIGIT() macro was removed because it was unused and its name did not match its actual behavior. + . The following zend_string-related legacy aliases were removed: + * IS_INTERNED() - use ZSTR_IS_INTERNED() + * STR_EMPTY_ALLOC() - use ZSTR_EMPTY_ALLOC() + * _STR_HEADER_SIZE - use _ZSTR_HEADER_SIZE + * STR_ALLOCA_ALLOC() - use ZSTR_ALLOCA_ALLOC() + * STR_ALLOCA_INIT() - use ZSTR_ALLOCA_INIT() + * STR_ALLOCA_FREE() - use ZSTR_ALLOCA_FREE() . zend_register_constant() now returns a pointer to the added constant on success and NULL on failure instead of SUCCESS/FAILURE. The specialized registration methods that previously had void returns diff --git a/Zend/zend_string.h b/Zend/zend_string.h index f60e4dec4e71f..ac9a7465c8767 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -70,15 +70,6 @@ END_EXTERN_C() #define ZSTR_H(zstr) (zstr)->h #define ZSTR_HASH(zstr) zend_string_hash_val(zstr) -/* Compatibility macros */ - -#define IS_INTERNED(s) ZSTR_IS_INTERNED(s) -#define STR_EMPTY_ALLOC() ZSTR_EMPTY_ALLOC() -#define _STR_HEADER_SIZE _ZSTR_HEADER_SIZE -#define STR_ALLOCA_ALLOC(str, _len, use_heap) ZSTR_ALLOCA_ALLOC(str, _len, use_heap) -#define STR_ALLOCA_INIT(str, s, len, use_heap) ZSTR_ALLOCA_INIT(str, s, len, use_heap) -#define STR_ALLOCA_FREE(str, use_heap) ZSTR_ALLOCA_FREE(str, use_heap) - /*---*/ #define ZSTR_IS_INTERNED(s) (GC_FLAGS(s) & IS_STR_INTERNED)