Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129654 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 2728C1A00BC for ; Thu, 18 Dec 2025 21:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1766094378; bh=zmuWwRB/le/wz1NHBk4qdLoZLZm1YdT2dBDENI090F4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SJ6fV3UYFCML8Giv1l8AIclk0xf7VMP1wFQ2TfeC904teq1VZi6SvWBVGxwoxO/RB jea6t9yfwo7OZ2SPNRQ7ypVDoS+VSjfe2HaZjNQtXiHNjmpKEKaCs/a8D1d/OI4fhd s13Pq5gkpik3KJ7Qjhf0mBQR7XtcMsasa5cCwlQdAhkL0bZ/t62B8a4hhr6W87NXt+ TFNmSkAc9Y4z9dAZtecvWKUb6IZjqmKO79eBSsZY2/sAOS/Rw1wXsigk9Q16iIZaWt 8ddwlaH5DXNMyPXA1UkhD4FRUwvBZ231cojhw2Dx65KL6dS2Xc7ZI6SpCgtHf6bduD WzBVbbowXUoIA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D3704180055 for ; Thu, 18 Dec 2025 21:46:17 +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=0.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 ; Thu, 18 Dec 2025 21:46:17 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-4ee2014c228so6566831cf.2 for ; Thu, 18 Dec 2025 13:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766094372; x=1766699172; 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=LZiodEdONOS0L/LFvCfiENdNNyW2SKblEheRTWoETuo=; b=QYCd8SFVha4izQkiOQGYOA3DBjKxY98/xwMonhUeAVkFOXxNKOAPjSCupghlkdcn6n 09Tqo9XUCRoT0O2PJ0SovYjLTU+lsokcVJFn2ZGfZBbDK7UypbUyDSVecjllXvhwDXLq oUX7/z2So30k7PaL6u8D37WvemskkkOExPJ87dEbasYyiR7AWUfE/4Js4hrc57nWNFR0 WdvJphhhKVzLHsBp2MzL7EGk/3aBkSUT2252TGljP7C7uhPley6cOr6TjN1C+bNwk3/I 1LJA2kRR3fm8m9i4iVKtpC1kCcKUGlMxgWINGyu6UYU/vWaR/fZ/pR7jsSOaT3Xbx5Ai 3Ocg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766094372; x=1766699172; 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=LZiodEdONOS0L/LFvCfiENdNNyW2SKblEheRTWoETuo=; b=sGVbYFp7cv1wCGOi4DOCC0Z8G0E3mWCTH8+qTHCOt1CNefvx9FwwSqU2tBm9z8+/Hb 0HeH0KI01z9cjbaqMgA3KRVwa3pumo7lfExZbJgoNGvV3M3+o21dxOt0CQkFXzQOwvJC E0zrv7yXWoyysLVTeYx2vF0geliOqeeW6FisJJF2z2Lm1iVMKXdB1TpWDEh9RAoa81JZ GNPCvz17F7lCnjs/ws1ww31b3PH53edz+QzkJlLqesmkJRvNjI29Gx5Sl13NYX3Ucu54 BGfry1NA/OBXm23R+cg4kGiWPMYJi9ntCZqZcF7FlMHTbzCEWRBTU8QqP0NLnje+PHC6 pGWQ== X-Forwarded-Encrypted: i=1; AJvYcCW6YpAIJDnuRLKX7PUELf8pSBMu/stmJ9/qsGnZuDJncj8E8UvCX+8yo350F0Zxyvn0G0Vl1GnVv6M=@lists.php.net X-Gm-Message-State: AOJu0YzNaDswEcrzPuWUMdUKxvXb0+5nHVjtvL85oL9MCUxGr1w5DZF6 mDMDQ3ajOAvclQlMu63FXkc8b0L9b3wtmKbq4YL9CXaLFqJWSyVSl398Zp6QslVEo0VF0O21Fqr qw7CiO+1saxTMpjJxTK5W7CCwNFjwbZs= X-Gm-Gg: AY/fxX547ykmXdzMfQDK9PIja3zeQ2gSmS75rsC1EkbJ+Xv0HLm4DcJ2ZpASLDWrBxx H2ZL79927PbYjb65VpRndcf7PqhesPrpqodaJA+G/q8l9tLiBSuNysVLPa+T7IE0FwFVjxVFnnR 0KgN8096czT18Z7kzFz1fOBcVCxtkTREHZjZ5+cO1Rkw79cniRNyni85qxd5aHvJG9SXXaZ56Wv tVB5wBcLMtnkE6cDw6z5nxpVG1nGibLXDqDNGpgkKwKmQpAkLAOin3L/dUuMDztIqheB/c= X-Google-Smtp-Source: AGHT+IGtguKg2AMNT2lfQkFbKgbVHuUOyo/UwOxZdY3hJmLIA/pEMZDZcHNlX5Iqujt92oN1blSTNf3304y4o16tnoM= X-Received: by 2002:a05:622a:180b:b0:4f3:58e4:a35a with SMTP id d75a77b69052e-4f4abde3e12mr11558501cf.76.1766094371710; Thu, 18 Dec 2025 13:46:11 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <83238ad3-c844-4457-dfb3-11321787e022@php.net> In-Reply-To: Date: Thu, 18 Dec 2025 22:45:59 +0100 X-Gm-Features: AQt7F2omjCv6AJi6r7r1Bs0N0kG21PzOdu0EnpYq5-_5p-Edb3r9nPJx_Qel89o Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Followup Improvements for ext/uri To: ignace nyamagana butera Cc: Juris Evertovskis , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000aa6b4d064640e374" From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --000000000000aa6b4d064640e374 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, The WHATWG URL living standard does the following: > > let url =3D new URL('https://example.com?debug&foo=3Dbar&debug=3D'); > console.log( > url.searchParams.toString(), //returns debug=3D&foo=3Dbar&debug=3D' > ); > > the pair gets converted to ['debug' =3D> '']. The roundtrip does not > conserve the query string as is but all key/pair (tuples) are present. > Yes, confirmed. Unfortunately, WHATWG URL only supports string values, so there's no way to support query parameters without a key (e.g. ?debug) in the RFC implementation either. :( On the other hand, the RFC 3986 implementation supports this notion, even uriparser calls this out in its documentation: https://uriparser.github.io/doc/api/latest/index.html#querystrings. However, there are a few other problems which came up when I was updating my implementation. 1.) Yesterday, I wrote that name mangling of the query params shouldn't happen. However, as I realized, it is still needed for non-list arrays, because the [..] suffix must be added to their name: $params =3D new Uri\Rfc3986\UriQueryParams() ->append("foo", [2 =3D> "bar", 4 =3D> "baz"]); echo $params->toRfc3986String(); // foo%5B2%5D=3Dbar&foo%5B4%5D=3Dbaz var_dump($params->getFirst("foo")); // NULL Even though I appended params with the name "foo", no items can be returned when calling getFirst(), because of name mangling. 2.) I'm not really sure how empty arrays should be represented? PHP doesn't retain them, and they are simply skipped. But should we do the same thing? I can't really come up with any other sensible behavior. $params =3D new Uri\Rfc3986\UriQueryParams() ->append("foo", []); echo $params->toRfc3986String(); // ??? 3.) We wrote earlier that objects shouldn't be supported when creating the query string from variables. But what about backed enums? Support for them in http_build_query() was added not long ago: https://github.com/php/php-src/pull/15650 Should we support them, right? Regards, M=C3=A1t=C3=A9 --000000000000aa6b4d064640e374 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

The WHATWG URL living standard d= oes the following:
let url =3D new URL('htt=
ps://example.com?debug&foo=3Dbar&debug=3D');
console
.log(
url= .searchParams.toString(), //returns debug=3D&foo=3Dbar&= ;debug=3D'
);
the pair gets converted to ['= debug' =3D> '']. The roundtrip does not conserve the query s= tring as is but all key/pair (tuples) are present.
=

Yes, confirmed. Unfortunately, WHATWG URL = only supports string values, so there's no way to support
que= ry parameters without a key (e.g. ?debug) in the RFC implementation either.= :(

On the other hand, the RFC 3986 implementation= supports this notion,=C2=A0even uriparser calls this out
=C2=A0
However, there are a few other p= roblems which came up when I was updating my implementation.

=
1.) Yesterday, I wrote that name mangling of the query params sh= ouldn't happen. However, as I realized,
it is still needed fo= r non-list arrays, because the [..] suffix must be added to their name:

$params =3D new Uri\Rfc3986\UriQueryParams()
=C2= =A0 =C2=A0 ->append("foo", [2 =3D> "bar", 4 =3D&g= t; "baz"]);

echo $params->toRfc3986String();=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // foo%5= B2%5D=3Dbar&foo%5B4%5D=3Dbaz

var_dump($params-= >getFirst("foo"));=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0// NULL

Even though I a= ppended params with the name "foo", no items can be returned when= calling getFirst(),
because of name mangling.

2.) I'm not really sure how empty arrays should=C2=A0be represen= ted? PHP doesn't retain them, and they are
simply skipped. Bu= t should we do the same thing? I can't really come up with any other se= nsible behavior.

$params =3D new Uri\Rfc3986\UriQu= eryParams()
=C2=A0 =C2=A0 ->append("foo", []);

echo = $params->toRfc3986String();=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // ???

3.) We wrot= e earlier that objects shouldn't be supported when creating the=C2=A0qu= ery string from variables. But what about
backed enums? Support f= or them in http_build_query() was added not long ago: https://github.com/php/php-src/pull/15650<= /a>


--000000000000aa6b4d064640e374--