From 6b93f5f1899a13be14f6ba3021ffc9ec93f2d9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 10 Jun 2026 22:46:47 +0200 Subject: [PATCH 1/3] Mark the value param with const modifier in the ext/uri write handler --- ext/uri/php_uri_common.h | 2 +- ext/uri/uri_parser_rfc3986.c | 12 ++++++------ ext/uri/uri_parser_whatwg.c | 26 +++++++++++++------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ext/uri/php_uri_common.h b/ext/uri/php_uri_common.h index f83327690dd4..b79d092ae726 100644 --- a/ext/uri/php_uri_common.h +++ b/ext/uri/php_uri_common.h @@ -45,7 +45,7 @@ typedef enum php_uri_component_read_mode { typedef zend_result (*php_uri_property_handler_read)(void *uri, php_uri_component_read_mode read_mode, zval *retval); -typedef zend_result (*php_uri_property_handler_write)(void *uri, zval *value, zval *errors); +typedef zend_result (*php_uri_property_handler_write)(void *uri, const zval *value, zval *errors); typedef enum php_uri_property_name { PHP_URI_PROPERTY_NAME_SCHEME, diff --git a/ext/uri/uri_parser_rfc3986.c b/ext/uri/uri_parser_rfc3986.c index 4e2c5656aa77..0b1c8970f473 100644 --- a/ext/uri/uri_parser_rfc3986.c +++ b/ext/uri/uri_parser_rfc3986.c @@ -153,7 +153,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_scheme_read(voi return SUCCESS; } -static zend_result php_uri_parser_rfc3986_scheme_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_rfc3986_scheme_write(void *uri, const zval *value, zval *errors) { UriUriA *uriparser_uri = get_uri_for_writing(uri); int result; @@ -305,7 +305,7 @@ ZEND_ATTRIBUTE_NONNULL void php_uri_parser_rfc3986_host_type_read(php_uri_parser ZVAL_OBJ_COPY(retval, zend_enum_get_case_cstr(php_uri_ce_rfc3986_uri_host_type, type)); } -static zend_result php_uri_parser_rfc3986_host_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_rfc3986_host_write(void *uri, const zval *value, zval *errors) { UriUriA *uriparser_uri = get_uri_for_writing(uri); int result; @@ -366,7 +366,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_port_read(void return SUCCESS; } -static zend_result php_uri_parser_rfc3986_port_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_rfc3986_port_write(void *uri, const zval *value, zval *errors) { UriUriA *uriparser_uri = get_uri_for_writing(uri); int result; @@ -439,7 +439,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_path_read(void return SUCCESS; } -static zend_result php_uri_parser_rfc3986_path_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_rfc3986_path_write(void *uri, const zval *value, zval *errors) { UriUriA *uriparser_uri = get_uri_for_writing(uri); int result; @@ -476,7 +476,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_query_read(void return SUCCESS; } -static zend_result php_uri_parser_rfc3986_query_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_rfc3986_query_write(void *uri, const zval *value, zval *errors) { UriUriA *uriparser_uri = get_uri_for_writing(uri); int result; @@ -513,7 +513,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_fragment_read(v return SUCCESS; } -static zend_result php_uri_parser_rfc3986_fragment_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_rfc3986_fragment_write(void *uri, const zval *value, zval *errors) { UriUriA *uriparser_uri = get_uri_for_writing(uri); int result; diff --git a/ext/uri/uri_parser_whatwg.c b/ext/uri/uri_parser_whatwg.c index f4e148704004..fe24dd9c3875 100644 --- a/ext/uri/uri_parser_whatwg.c +++ b/ext/uri/uri_parser_whatwg.c @@ -28,7 +28,7 @@ ZEND_TLS lxb_unicode_idna_t lexbor_idna = {0}; static const size_t lexbor_mraw_byte_size = 8192; -static zend_always_inline void zval_string_or_null_to_lexbor_str(zval *value, lexbor_str_t *lexbor_str) +static zend_always_inline void zval_string_or_null_to_lexbor_str(const zval *value, lexbor_str_t *lexbor_str) { if (Z_TYPE_P(value) == IS_STRING && Z_STRLEN_P(value) > 0) { lexbor_str->data = (lxb_char_t *) Z_STRVAL_P(value); @@ -40,12 +40,12 @@ static zend_always_inline void zval_string_or_null_to_lexbor_str(zval *value, le } } -static zend_always_inline void zval_long_or_null_to_lexbor_str(zval *value, lexbor_str_t *lexbor_str) +static zend_always_inline void zval_long_or_null_to_lexbor_str(const zval *value, lexbor_str_t *lexbor_str) { if (Z_TYPE_P(value) == IS_LONG) { - ZVAL_STR(value, zend_long_to_str(Z_LVAL_P(value))); - lexbor_str_init_append(lexbor_str, lexbor_parser.mraw, (const lxb_char_t *) Z_STRVAL_P(value), Z_STRLEN_P(value)); - zval_ptr_dtor_str(value); + zend_string *tmp = zend_long_to_str(Z_LVAL_P(value)); + lexbor_str_init_append(lexbor_str, lexbor_parser.mraw, (const lxb_char_t *) ZSTR_VAL(tmp), ZSTR_LEN(tmp)); + zend_string_release(tmp); } else { ZEND_ASSERT(Z_ISNULL_P(value)); lexbor_str->data = (lxb_char_t *) ""; @@ -257,7 +257,7 @@ static zend_result php_uri_parser_whatwg_scheme_read(void *uri, php_uri_componen return SUCCESS; } -static zend_result php_uri_parser_whatwg_scheme_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_whatwg_scheme_write(void *uri, const zval *value, zval *errors) { lxb_url_t *lexbor_uri = uri; lexbor_str_t str = {0}; @@ -297,7 +297,7 @@ static zend_result php_uri_parser_whatwg_username_read(void *uri, php_uri_compon return SUCCESS; } -static zend_result php_uri_parser_whatwg_username_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_whatwg_username_write(void *uri, const zval *value, zval *errors) { lxb_url_t *lexbor_uri = uri; lexbor_str_t str = {0}; @@ -326,7 +326,7 @@ static zend_result php_uri_parser_whatwg_password_read(void *uri, php_uri_compon return SUCCESS; } -static zend_result php_uri_parser_whatwg_password_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_whatwg_password_write(void *uri, const zval *value, zval *errors) { lxb_url_t *lexbor_uri = uri; lexbor_str_t str = {0}; @@ -411,7 +411,7 @@ ZEND_ATTRIBUTE_NONNULL void php_uri_parser_whatwg_host_type_read(const lxb_url_t } } -static zend_result php_uri_parser_whatwg_host_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_whatwg_host_write(void *uri, const zval *value, zval *errors) { lxb_url_t *lexbor_uri = uri; lexbor_str_t str = {0}; @@ -440,7 +440,7 @@ static zend_result php_uri_parser_whatwg_port_read(void *uri, php_uri_component_ return SUCCESS; } -static zend_result php_uri_parser_whatwg_port_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_whatwg_port_write(void *uri, const zval *value, zval *errors) { lxb_url_t *lexbor_uri = uri; lexbor_str_t str = {0}; @@ -469,7 +469,7 @@ static zend_result php_uri_parser_whatwg_path_read(void *uri, php_uri_component_ return SUCCESS; } -static zend_result php_uri_parser_whatwg_path_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_whatwg_path_write(void *uri, const zval *value, zval *errors) { lxb_url_t *lexbor_uri = uri; lexbor_str_t str = {0}; @@ -498,7 +498,7 @@ static zend_result php_uri_parser_whatwg_query_read(void *uri, php_uri_component return SUCCESS; } -static zend_result php_uri_parser_whatwg_query_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_whatwg_query_write(void *uri, const zval *value, zval *errors) { lxb_url_t *lexbor_uri = uri; lexbor_str_t str = {0}; @@ -527,7 +527,7 @@ static zend_result php_uri_parser_whatwg_fragment_read(void *uri, php_uri_compon return SUCCESS; } -static zend_result php_uri_parser_whatwg_fragment_write(void *uri, zval *value, zval *errors) +static zend_result php_uri_parser_whatwg_fragment_write(void *uri, const zval *value, zval *errors) { lxb_url_t *lexbor_uri = uri; lexbor_str_t str = {0}; From 762ac9a1062b1430f88aaf052dd36811d67afbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sat, 13 Jun 2026 14:09:55 +0200 Subject: [PATCH 2/3] Constify php_uri_property_write_helper --- ext/uri/php_uri_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/uri/php_uri_common.c b/ext/uri/php_uri_common.c index 5d87b7847b34..0644afda3105 100644 --- a/ext/uri/php_uri_common.c +++ b/ext/uri/php_uri_common.c @@ -55,7 +55,7 @@ void php_uri_property_read_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property } } -static void php_uri_property_write_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, zval *property_zv) +static void php_uri_property_write_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, const zval *property_zv) { php_uri_object *old_uri_object = Z_URI_OBJECT_P(ZEND_THIS); ZEND_ASSERT(old_uri_object->uri != NULL); From a8415fda886f9dc3482fd21dabd68c036d41911f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sat, 13 Jun 2026 14:49:08 +0200 Subject: [PATCH 3/3] Update UPGRADING.INTERNALS --- UPGRADING.INTERNALS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index c340ba64833c..ec83f1bca596 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -180,6 +180,11 @@ PHP 8.6 INTERNALS UPGRADE NOTES . _php_error_log_ex() has been removed. . php_mail()'s extra_cmd parameter is now a zend_string*. +- ext/uri: + . The value parameter of the php_uri_property_handler_write callback is now + const zval * instead of zval *, reflecting that write handlers must + not modify the input zval. + - ext/xml: . Removed the XML_ExpatVersion() libxml compatibility wrapper, as it was unused.