Skip to content

Implement Query Parameter Manipulation Support RFC#22551

Draft
kocsismate wants to merge 1 commit into
php:masterfrom
kocsismate:query-params
Draft

Implement Query Parameter Manipulation Support RFC#22551
kocsismate wants to merge 1 commit into
php:masterfrom
kocsismate:query-params

Conversation

@kocsismate

Copy link
Copy Markdown
Member

RFC: https://wiki.php.net/rfc/query_params

Early preview yet -> a few leaks are to be fixed.

@kocsismate kocsismate requested a review from ndossche July 2, 2026 12:17
@kocsismate kocsismate requested a review from TimWolla as a code owner July 2, 2026 12:17
@kocsismate kocsismate marked this pull request as draft July 2, 2026 12:18
@kocsismate kocsismate changed the title Implement Qquery Parameter Manipulation Support RFC Implement Query Parameter Manipulation Support RFC Jul 2, 2026

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments without trying to understand the logic.

Comment on lines +697 to +700
zend_string *result = zend_string_alloc(str_length, false);

memcpy(ZSTR_VAL(result), str, str_length);
ZSTR_VAL(result)[str_length] = '\0';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can also just be zend_string_init().

}

if (UNEXPECTED(str_length == 0)) {
return zend_empty_string;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZSTR_EMPTY_ALLOC

}
} ZEND_HASH_FOREACH_END();

return buf.s != NULL ? smart_str_extract(&buf) : ZSTR_EMPTY_ALLOC();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This optimization is handled automatically:

if (str->s) {
zend_string *res;
smart_str_0(str);
smart_str_trim_to_size_ex(str, persistent);
res = str->s;
str->s = NULL;
return res;
} else {
return ZSTR_EMPTY_ALLOC();
}

Comment thread ext/uri/php_uri_query.c
options->parsing_max_param_count = parsing_max_param_count;

if (true_value == NULL) {
options->true_value = zend_string_init(ZEND_STRL("1"), false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZSTR_CHAR

Comment thread ext/uri/php_uri_query.c
Comment on lines +55 to +59
if (true_value == NULL) {
options->true_value = zend_string_init(ZEND_STRL("1"), false);
} else {
options->true_value = true_value;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this is more readable.

Suggested change
if (true_value == NULL) {
options->true_value = zend_string_init(ZEND_STRL("1"), false);
} else {
options->true_value = true_value;
}
if (true_value == NULL) {
true_value = ZSTR_CHAR('1');
}
options->true_value = true_value;

Comment thread ext/uri/php_uri_query.c
case IS_RESOURCE:
zend_argument_value_error(2, "must not contain a resource");
return NULL;
case IS_ARRAY: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very inconsistent use of braces. They are not needed in the majority of cases.

Comment thread ext/uri/php_uri_query.c
return NULL;
}
case IS_OBJECT:
if (Z_OBJCE_P(zv)->ce_flags & ZEND_ACC_ENUM && Z_OBJCE_P(zv)->enum_backing_type != IS_UNDEF) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (Z_OBJCE_P(zv)->ce_flags & ZEND_ACC_ENUM && Z_OBJCE_P(zv)->enum_backing_type != IS_UNDEF) {
if ((Z_OBJCE_P(zv)->ce_flags & ZEND_ACC_ENUM) && Z_OBJCE_P(zv)->enum_backing_type != IS_UNDEF) {

Comment thread ext/uri/php_uri_query.c

if (
(value == NULL && list_entry->value == NULL) ||
(value != NULL && list_entry->value != NULL && zend_string_equal_content(value, list_entry->value))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this isn't just?

Suggested change
(value != NULL && list_entry->value != NULL && zend_string_equal_content(value, list_entry->value))
(value != NULL && list_entry->value != NULL && zend_string_equal(value, list_entry->value))

Comment thread ext/uri/php_uri_query.c
return NULL;
}

php_uri_query_params_iterator *iterator = emalloc(sizeof(php_uri_query_params_iterator));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
php_uri_query_params_iterator *iterator = emalloc(sizeof(php_uri_query_params_iterator));
php_uri_query_params_iterator *iterator = emalloc(sizeof(*iterator));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants