Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119292 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59809 invoked from network); 17 Jan 2023 14:59:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jan 2023 14:59:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4604D180504 for ; Tue, 17 Jan 2023 06:59:57 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 17 Jan 2023 06:59:56 -0800 (PST) Received: by mail-pf1-f181.google.com with SMTP id y5so23674310pfe.2 for ; Tue, 17 Jan 2023 06:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=nH3B+VGQjBiRJnzs/Lj5LDleeDLBQlrmgXYP5fj4b6o=; b=oo7QU6KlfRUsYzWZjqD+x9s8fFTJ87U/e054ePnJ0Vvh2S+QPAqnCLrt17zS4/TCyk 5Sw4AWkqSedsR8c6ZDUks7WJpjpGDPih8XkAel27ACleYSmvLTMRQWfpk14yrGlgbsV0 kKwb0GjwXn6UNnlGOsHa4W2y/O4fFFCobBYOPEbZrf49IGSpy7ah/GP79SW/8oTKkufd 58N5md/Pu9VAk0IotFw6KtsUfWq0auxTzzLN9sAZwY/lFGN3aV645pP9e6rtC8AaQb0E u7iZdq2Uj/US/I9mh9BkZQW77p8owEdaDELCdESR/yGXApi/ffYOcgt76tn/f+wm6Sg3 IiHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nH3B+VGQjBiRJnzs/Lj5LDleeDLBQlrmgXYP5fj4b6o=; b=qkzj6edybNF8D3m06nwuC4cWV7Zuv3XiJVDxI0dv/9wGd3DJXRBTSb2QMfTx9t8v9P WzBd6OuQkZiHmdgN+NuMy3p3gBo6WFio3AGk7vtaKl/rpFQCn+DTHsHDlu/2cizaq0PB 7yFDGd6FOpnHsUxMhxecNq+/bWU7oLf9/PR+6XIiLg8RuqV+r0T45EAmDMS6yejn4h5p xP0XPXBnxhUs70kITZphNNAcmWzxYmIXupgTHb0OT+vlD9KAsUXxuiuBGGj0gqXH44AY hJmDYp5YwhLgFMvaz2HknRZ0XkApBOSizf0ukFzeWtsVVj7bZXCRKULoe1P5pK7tcNNV nCyQ== X-Gm-Message-State: AFqh2kp7gly+HLpBgL5SacewAZczkt1SW0gnwuGoCqnATtG2UIJO7kE9 Y3C7596/95/Oi2RM4IK8O78+25csrePSSjFmxW4ON2WNn5g= X-Google-Smtp-Source: AMrXdXugi4JOpPwHqzjHe3KDltUk/siq0NoYkpRDpRN8zrTu1vGhruCUM+7dKJJsCc7bvZYUcgnyzPo00WOuaXTT6rA= X-Received: by 2002:a63:a42:0:b0:4cd:2ebd:324b with SMTP id z2-20020a630a42000000b004cd2ebd324bmr263684pgk.560.1673967595714; Tue, 17 Jan 2023 06:59:55 -0800 (PST) MIME-Version: 1.0 References: <22D992B7-62B3-4A4F-934F-17D53058FD35@cschneid.com> In-Reply-To: <22D992B7-62B3-4A4F-934F-17D53058FD35@cschneid.com> Date: Tue, 17 Jan 2023 14:59:44 +0000 Message-ID: To: Christian Schneider Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000e87e5d05f276f34c" Subject: Re: [PHP-DEV] [RFC] Add SameSite cookie attribute parameter From: george.banyard@gmail.com ("G. P. B.") --000000000000e87e5d05f276f34c Content-Type: text/plain; charset="UTF-8" On Mon, 16 Jan 2023 at 15:36, Christian Schneider wrote: > Am 16.01.2023 um 14:39 schrieb G. P. B. : > > On Sun, 15 Jan 2023 at 20:58, Christian Schneider > wrote: > > Some comments: > > - I am not convinced that we should introduce a third way of providing > parameters to setcookie(). I don't think this function is used often enough > in common code to add yet another iteration of the API. Assuming there is 1 > to 2 places in your framework using this I don't think many bugs will go > unnoticed. Adding a warning to illegal 'samesite' values in $options would > IMHO be enough if stricter checking is wished for. > > > > How is this providing a third way of providing parameters to > setcookie()? As it is, if I want to use named arguments and the typed > parameters, I cannot set the SameSite attribute. > > I've heard multiple people waste time due to a SameSite bug because they > made a typo, and it took them way too long to figure out the issue as they > thought they had a server configuration problem. > > Adding a warning for invalid values is effectively turning that option > into an Enum, which at this point one might as well have a proper Enum. > > Maybe third API was misleading, what I mean is that we had the (old) way > of positional arguments for options which did not include something like > samesite and the (new) way with the options array. So I would assume most > code was migrated to $options. > Now you are suggesting of updating the old API with an additional > positional argument which would mean changing the array-form back to > positional. > Is your plan to deprecate the $options-API at some point in the future? > Having two APIs offering the same functionality seems a bit confusing to me. > I personally don't plan on deprecating the array $options API. If two APIs that provide the same functionality are too confusing, then the current incomplete way of passing parameters should be deprecated at some point. However, until then, having symmetry between both APIs is better for people who prefer to have parameters and use named arguments than the $options array. > Alternatively the 'samesite' option in $options could accept > SameSite::Lax. This would accomplish (almost) the same with a smaller > change. Disclosure: I like arrays for options as they allow for array > addition etc. Something similar can be done with ...$options, true :-) > That is actually a good idea to add support for the array version to accept the new enum, I'll amend the implementation. > Side-Note: Isn't SameSite a very generic name in the global namespace? I'm > not sure what the PHP policy is here. > AFAIK the global namespace is "owned" by PHP so that shouldn't be an issue per the usual policy. > > - I don't like the camelCase of $sameSite as this is different from > all the other parameters, e.g. $expires_or_options (yes, this is a > pseudo-parameter name, I know) and $httponly. Looking at a couple of > functions in the standard PHP set I didn't see any $camelCase. > > > > ACK, it should probably be in snake case and be $same_site > > Looking at $httponly I would have expected $samesite. > I suppose it can be either or, but trying to improve the name of a not yet existing parameter seems better than following the weird naming scheme. But I'm not hard set on the name here. > > - A more generic question: How are Enums handled concerning future > additions of values vs. BC compatibility? What is the migration plan there > if one wants to support both old and new PHP versions? > > > > The parameter is optional, so I don't understand what migration plan you > need? > > If in the, unlikely, event that a new value is added this should be > added as a case in the enum in the next minor version of PHP. > > In the, again unlikely, event that a value is deprecated, the > corresponding enum case should also be deprecated following the normal PHP > deprecation process. > > > > I only decided to make this an enum because I deem it very unlikely for > a new valid attribute value to be introduced, the new IETF RFC clarifies > and amends the behaviour of the 3 valid attribute values that have always > been the same since 2016. > > I was talking about extending Enums, not the parameter and not SameSite > specifically. > Are there any Enums in core PHP APIs where new values could be added in > the future and how is the plan for code supporting multiple PHP version > there? This was just something which crossed my mind when thinking about > APIs with Enums. This is not really related to this RFC so I understand if > you want to ignore this part :-) > I might be again misunderstanding, but one cannot extend an enum as they are final classes under the hood. Currently, the only other native enum is the one that was added with the Randomizer Additions RFC [1] so this topic hasn't come up yet as the enum for ext-random is definetely complete. Best, George P. Banyard --000000000000e87e5d05f276f34c--