Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130285 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id E8A341A00BC for ; Mon, 9 Mar 2026 20:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1773089279; bh=NNfP3tY6MMgoRNbpe03d+6WchZyHZUEYaKETiQU35PM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=e7MrxOgjHeGsiB/qzMr0U9Zs44gPDa0J4fc16I6qOYPQVI4n1BGNdcGKcjQTGMIBM rz4Jw9OISMiPxRBK+YUxmMIGBEnPzqFHfAN26D7XXrGpiqdAkJTLRdTvPoYekzJkvK Op54SSxKrHPqHwxcMN8fbBjla24EjaYRNeCvZ64BkA3+KQ7t5yWfb+uK/jN43i/DyT EKBwXHFwPU0l/gv9nWInFDJotuqsMX3aljBQjdGutW4uP18VmJceOMR/fJe451OTCt r6VhdF+TErH+tLCGgRv8z6hShRhVHbRxNP9yjy57cvW6lkb8qRnJflEQ5EKOldM9yg crwZswSu8k+SQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 62732180077 for ; Mon, 9 Mar 2026 20:47:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FORGED_GMAIL_RCVD,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 9 Mar 2026 20:47:58 +0000 (UTC) Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-89a1c6dd788so100419356d6.0 for ; Mon, 09 Mar 2026 13:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773089272; cv=none; d=google.com; s=arc-20240605; b=JDzbT3WiamJai1jCNlRa8l+veVdBXimxx6arEHYrr+LWvkxeIx0hrVAbBCUzz21rTF AcplDBSn8G9bFFiQj2VGBG47eghOUHRMiXjDVSNfzk3WuuR1FIioUfJOs40LElG/r6DV o0UzEJ/Tq4BjJ1yk51GWTV1xtww3o22nCccFjxIn+znZmkzAg7YlwobynN5mpJuie8cp MTyvnpjksA0xGMHA3rG3ODeEg33U0FyPCSBvCT7X9EFMhTpeAwndTtw0vc3v9GAVDEqX UpvWOvZfVORoGIfJ0GcYm95BagiRfQhqIDv/VeROFxPWbHcEZyXuetMbLmvJyX4xxHW/ XaZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=NNfP3tY6MMgoRNbpe03d+6WchZyHZUEYaKETiQU35PM=; fh=Xr/ogOWGTRFA1d+q7p9CE+6uwwIHZm+lXGw7EES2NUs=; b=GDe7MJ9K7bnBWsy/K/Aom+4f8glWjkFCQCHSpvZY7o6YrSSKJ4vvhhXdIugnRJep/n AFJfrlgvC+g6pXlLnnZani+qKnWpcH1yFtk+hcOEIOtarcGtpqrojDmADlu7zsJ6cjU2 GltkuHLNGPlIBmZ65nQDEkNcf3uTzuco9Zy9xMrfzsGZ3iQ8OAivwYLWZXrO2NynM/Pu Nn1tUIO3esvapWc83P/I6huMoygbQuUVaBDOSZkLAHZasELnxyxWvQDz3BZv3yqXdyHg CDte+2b0xYUMrImGw3lOHd0eIdrfiSygENAD7jNgIw06IoC4GphBu6CYmsq9Shbcb+ev 11zQ==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773089272; x=1773694072; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=NNfP3tY6MMgoRNbpe03d+6WchZyHZUEYaKETiQU35PM=; b=AWzhfZI7KY108eu20SxXBXG+AEGJ5hCmdBQM9qcgOjEBv3eHYwpH2skComFRExaA0h wOnlbBCrcFcGWF7BeAqSPLiWLNbAtvSOUYvtAd2opOc9H9sDW4qdeiBrz1ssyyJjr27l 7xEcZRXJDFakyAAS11N7Fy/Q0zWqa65sCbccc0zu+FGX6RdRb/oGmImchCSw0wrXEUVP yFSFwy5MPkBHcMmGbWoMekzixUFNEdqIUTwacIAVLCYwnwKNtwmY0WviS3UMzqQo+K8Q APE/AweKl3ZAU+O8Z1qpgVkFCcuNJZ6IienGnuPZYJRAGl7MUBwSTj1UKvc9DZaJ/8od jwaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773089272; x=1773694072; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NNfP3tY6MMgoRNbpe03d+6WchZyHZUEYaKETiQU35PM=; b=T1MWX0gwCDNGdku1VaRxzU6eXvGnbKj4hnBiiV8vhALAbXKgGmP8GLnwZbYdNmEQgU 8W1LPRyRNGiSu4Xzz3yjelYRYO2JWefj5Rx9PFc4nO9aTve5P6LZYpenRM1Ile6HnA9N bwSult5a2Ogkc99LaGKdhwRAvwIrZXfBWyuOd3mmJnCxxE0eEfKHimL1fTT9nnkIBKoO D6YQ0ejHyw/hrx7T+LQmBu9leeW4V3leyXZzxPIfzhZpEqJcuE1OCLGHu0ruokWrPVG1 G3u4vfNuK9kbZTbOUxoFYZAtHZCrLU259KlnWToFvp5o4bBcigiKbXFBdxZZ5hZgm69G tC4A== X-Gm-Message-State: AOJu0Yz90ntbk4gE6FNAJbUdIZuHZtx2JlTZ9I0iEnTAIB/kLtPqC8q2 udtVV+RMmDya7NXqXjYy9mK2827vUNpTkz2mwGHiD5oiDJDP2ghtvuNvFKOib4Hg6Pz0obmkAdm iwnWX5YC+8zk/aEajk25RNrzPJcMR+JY= X-Gm-Gg: ATEYQzwuHkE1jTewmCIDkE9OkUnh14eEygVG6oaWMYgXLq28PNspZ2guvjmhwfsXjGk 2Ud2iFWrzSI/ix0/5A2CZEYvR9yHkzThecFh3/9e2ECi5gl/6rpGxrACCVo//8/Iki9g7AH2ib9 e/L6llJyVrekex2T+ScQX/unB/RDBfiNZ7jtxSKTkiMi/i4OVGtuj/wQDo4NPjl6QxcJaPXrZqK ZxNhKlI80L2BJavGrpoqk5D/sCsdv1IMTEDPWp3CdNYOaqpFkaF+3xoKLPaIRQwmXNDOAcE3Pqz PfqGXc8= X-Received: by 2002:ad4:5cc2:0:b0:899:fb3a:9f63 with SMTP id 6a1803df08f44-89a30a66993mr189557726d6.20.1773089272434; Mon, 09 Mar 2026 13:47:52 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 9 Mar 2026 21:47:41 +0100 X-Gm-Features: AaiRm52xUqM3AQdf4bkiPrsPtIyTEO-F5NEp0lQVF-ssAW7N08QWWxWWLHaq3as Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Query Parameter Manipulation Support To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: PHP Internals List Content-Type: multipart/alternative; boundary="0000000000003d130b064c9d842f" From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --0000000000003d130b064c9d842f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Tim, Thank you for the help, I forgot to link the RFC indeed. Let me answer your questions: > > I don't think it is as necessary to make it readonly as it is with the > URI classes, since the query parameters class is likely to be used for > =E2=80=9Clocal modification=E2=80=9D and is less likely to be passed arou= nd as a value > object. If efficient copy-on-write is possible internally, then making > it readonly is the safer choice, of course. > Yes, as far as I know from Ilija, it's possible to optimize modification based on refcount: if a readonly property which is to be modified has a refcount of 1 and there's no weakref, it can be safely updated in-place. > With regard to the RFC text, I've given it a first quick skim and have > the following notes: > > 1. Within the "Relation to the query component" section. > > The `$uri =3D new Uri\Rfc3986\Uri("https://example.com?foo=3Da b");` exam= ple > is invalid. An URI containing a space is not valid and the `Uri` class > will throw an exception. Can you double-check that part of the RFC? > Without looking it up, I suspect that the space should be `%20` for > RFC3986? > Nice catch, I'll review and fix the examples using "a b". It is indeed incorrect, and %20 should be used instead. as you said. > 4. Within the "Supported types" section. > > =E2=80=9CThe above conversion rules work for both UriQueryParams and > UrlQueryParams.=E2=80=9D > > and the examples also use Uri\Rfc3986\UriQueryParams / > Uri\WhatWg\UrlQueryParams. > > This seems like an oversight from the original implementation, since > there are no longer separate classes. Can you double-check the entire > section? > I intentionally haven't updated this section yet: because there's important info about the difference between how WHATWG specification and uriparser handles null, so I didn't want to "lose" this (I know it remains in the changelog). > > 5. Within the "Array API" section. > > This also uses Uri\Rfc3986\UriQueryParams in the examples Same situation as above, but basically the whole section is a big question mark: I couldn't come up with a good enough idea how arrays could be handled efficiently and ergonomically, and in the same time, how to (mostly) confor= m to WHATWG URL. Some of my problems: - How should $params->get("foo[bar]") behave? Should we try to parse the supplied key as an array and return the nested item if it exists? I suppose, we would internally store the query params as an array (just like how $_GET does), so then we would definitely need parsing in order to be able to return item "bar" stored within array "foo". - However, what should a $params->append("foo[bar]") call do when the query param "foo" is already added with a string value? Should it modify the existing item to be an array (but then how?) or we should just add "foo[bar]" to the query params as-is? - How to recompose list parameters? Ideally, we should not append [] to these parameters (e.g. "list=3D1&list=3D2" vs "list[]=3D1&list[]=3D2"), and actually, it is not ne= eded for arrays in the root level, but as far as I understood, it's a must-have for nested lists (e.g. "map[list]=3D1&map[list]=3D2" vs. map[list[]]=3D1&map[list[]]=3D2), otherwise the representation would be ambiguous for lists with 1 item: "map[list]=3D1" would mean that t= he map has a list item with a value of "1". So we either always have to use the [] suffix for lists, or we should make a distinction between root-level and nested lists. I know, most of my questions revolve around parsing the $name parameter, but I would really want to minimize the number of times when the $name param has to be parsed run-time so that the performance is comparable to native array key lookups. I don't have any idea how much the parsing would cost though... So at this point, coming up with a sensible plan is needed, and I can fix most inconsistencies in the RFC afterwards. Regards, M=C3=A1t=C3=A9 --0000000000003d130b064c9d842f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey Tim= ,

Thank you for the help, I forgot to link the RFC indee= d.

Let me answer your questions:

I don't think it is as necessary to make it readonly as it is with the =
URI classes, since the query parameters class is likely to be used for
=E2=80=9Clocal modification=E2=80=9D and is less likely to be passed around= as a value
object. If efficient copy-on-write is possible internally, then making
it readonly is the safer choice, of course.

=
Yes, as far=C2=A0as I know from Ilija, it's possible to optimize m= odification based on
refcount: if a readonly property which is to= be modified has a refcount of 1 and
there's no weakref, it c= an be safely updated in-place.
=C2=A0
With regard to the RFC text, I've given it a first quick skim and have =
the following notes:

1. Within the "Relation to the query component" section.

The `$uri =3D new Uri\Rfc3986\Uri("https://example.com?foo=3Da = b");` example
is invalid. An URI containing a space is not valid and the `Uri` class
will throw an exception. Can you double-check that part of the RFC?
Without looking it up, I suspect that the space should be `%20` for RFC3986= ?

Nice catch, I'll review and fix t= he examples using "a b". It is indeed incorrect,=C2=A0and %20
should be used instead. as you said.
=C2=A0
4. Within the "Supported types" section.

=E2=80=9CThe above conversion rules work for both UriQueryParams and
UrlQueryParams.=E2=80=9D

and the examples also use Uri\Rfc3986\UriQueryParams /
Uri\WhatWg\UrlQueryParams.

This seems like an oversight from the original implementation, since
there are no longer separate classes. Can you double-check the entire
section?

I intentionally haven't up= dated this section yet: because there's important info about
= the difference between how WHATWG specification and uriparser handles null,=
so I didn't want to "lose" this (I know it remains= in the changelog).
=C2=A0

5. Within the "Array API" section.

This also uses Uri\Rfc3986\UriQueryParams in the examples
=
Same situation as above, but basically the whole section is = a big question mark:
I couldn't come up with a good enough id= ea how arrays could be handled
efficiently and ergonomically, and= in the same time, how to (mostly) conform
to WHATWG URL.

Some of my problems:
- How should $params-= >get("foo[bar]") behave? Should we try to parse the supplied k= ey as an array and return the
nested item if it exists? I suppose= , we would internally store the query params as an array (just like how $_G= ET does),
so then we would definitely need parsing in order= to be able to return item "bar" stored within array "foo&qu= ot;.
- However, what should a $params->append("foo[bar]&q= uot;) call do when the query param "foo" is already added with a = string value?
Should it modify the existing item to be an array (= but then how?) or we should=C2=A0just add "foo[bar]" to the query= params as-is?
- How to recompose list parameters? Ideally, we sh= ould not append [] to these parameters (e.g.
"list=3D1&l= ist=3D2" vs "list[]=3D1&list[]=3D2"), and actually, it i= s not needed for arrays in the root level, but as far as I understood,
it's a must-have for nested=C2=A0lists (e.g. "map[list]=3D1&= amp;map[list]=3D2" vs. map[list[]]=3D1&map[list[]]=3D2), otherwise= the representation
would be ambiguous for lists with 1 item: &qu= ot;map[list]=3D1" would mean that the map has a list item with a value= of "1". So
we either always have to use the [] suffix = for lists, or we should make a distinction between root-level and nested li= sts.

I know, most of my questions revolve around p= arsing the $name parameter, but I would really want to minimize the number<= /div>
of times when the $name param has to be parsed run-time so that t= he performance is comparable to native array key
lookups. I don&#= 39;t have any idea how much the parsing would cost though...

=
So at this point, coming up with a sensible plan is needed, and = I can fix most inconsistencies in the RFC afterwards.

<= div>Regards,
M=C3=A1t=C3=A9


--0000000000003d130b064c9d842f--