Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107918 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72149 invoked from network); 17 Dec 2019 09:06:54 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 17 Dec 2019 09:06:54 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 82EDE2D2005 for ; Mon, 16 Dec 2019 23:06:45 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Mon, 16 Dec 2019 23:06:45 -0800 (PST) Received: by mail-ot1-x342.google.com with SMTP id x3so12447636oto.11 for ; Mon, 16 Dec 2019 23:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8rOR8SLgKng+zAsk2JntpPwSZl8cDsndfo3MFsDTb6s=; b=oWDEyF0KkvZ61+qNnq+w+DPTDX3M05JTMNzVN1usYQm1m0JiPvOEIr3GvBD8nsdhmd /BxFtwevjN2wqKKtcIAMcauDlrefDw6f77RfKCrb8UZnTu9dY84CCViiaKN98tbJTxSR ayhsV7yBHDQO5JD3hF24kt520FGQccqCnWQ0TiMMcqYcIxlJsXLQehyuXwT+k8Nki3wq 1v6aygeFuqfexendo2VEfprPKRlKHf7shmTT8OS1kbwSi6n6pIjuqFeI6MbVmU3qe5En 9GWIZvFBK+OI7wvwhwoizuaRazm0lNBRItXNYLr6Wmkb0twnJZDeYbCh2RgWjyWKe7o7 /m3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8rOR8SLgKng+zAsk2JntpPwSZl8cDsndfo3MFsDTb6s=; b=C40GIKeUuUBWyH++ct6kcsyFtGfEaHW0vCxnUfWOSrNDMFAZt3Y9/P9SjZPhF2fzAX aBVfz1RB2jFFjuV/uVEbBLKY5OSwxsgmetBoC0tldTt2S9TRWOwnNzlN6a25J/JoW7O+ HbbAN0/2c3lEiwkubzIi+Clxix+Qu9p5O8SMRNLX+6NPoHZ3GRr2XU9k7+ndnyjSP8BH OnAA4fd5mIcGXv8+XVGQXZhYFAsobKWJcM38mBsBMQngHc7vASZLIJXGWOz2lJ7jgzTH 84a6mbAoY0MB1rMBlOgOXUpKVAMF6AmXmaF/xbVZdljBw7SQe17ZBxqX3LPrRdDarsap bnkQ== X-Gm-Message-State: APjAAAV4CY3udI2mSEkVAIxQlutFUBmki0SjU04xai8mZjLHkyzSTNof pey5Fp/pc+IWLvNQ1Y/w4Y1h6em5XLKzJp+olEMQZMmocKk= X-Google-Smtp-Source: APXvYqyXBos3OtFgVRSZ0a8oR/K1zct13hKA7zqfW9ou7b8MIHB8LXA9u72UEU6GmD5/ODETcdavpIHGrLpE1QLIjyM= X-Received: by 2002:a05:6830:1c90:: with SMTP id v16mr30997189otf.259.1576566404473; Mon, 16 Dec 2019 23:06:44 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 17 Dec 2019 08:06:32 +0100 Message-ID: To: George Peter Banyard Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000080e9440599e0f8af" X-Envelope-From: Subject: Re: [PHP-DEV] Allowing variable strings to be defined for a string offset From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --00000000000080e9440599e0f8af Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable pon., 16 gru 2019 o 10:58 George Peter Banyard napisa=C5= =82(a): > Greetings internals, > > I'm here to get internals's opinion about allowing a string offset to be > replaced with arbitrary strings. > > Since forever strings with more then one byte have been truncated silentl= y > to one byte. The case with empty string *kinda* was existent but had a > buggy behaviour (see bug 71572 [1]) and as such has been turned into a > warning in PHP 7.1.0, and is meant to be promoted to an Error Exception p= er > the Reclassifying engine warnings RFC. [2] > An illustration of both these cases is available on 3v4l.org [3] > > > I've got an implementation ready as a pull request on GitHub [4] (which > still needs some polishing for it to make CI happy and fix the various > leaks). > > However, the question is if this behaviour is desirable. Moreover, the > silent truncation of strings with more than one byte should be changed to > the same severity as the empty string case; i.e. an Error Exception. This > seems reasonable due to the possible loss of data. > > What ever the decision is, a BC break is to be expected. As code which > inadvertently tries to assign multiple bytes to an offset will know have > all those bytes in the string whereas before only the first one was used = to > replace the byte at the designated offset. On the other hand the > introduction of an Error Exception is obviously a BC break but as it poin= ts > out to some kind of logic error. > I would assume the impact to be minimal for both of these case. > > Any opinions? > > Best regards > > George Peter Banyard > > [1] https://bugs.php.net/bug.php?id=3D71572 > [2] https://wiki.php.net/rfc/engine_warnings > [3] https://3v4l.org/O0nEM > [4] https://github.com/php/php-src/pull/5013 Allowing to unset string offset with empty string assignment in your patch will not trigger a Warning anymore, but using unset with string offset currently emits "Fatal error: Uncaught Error: Cannot unset string offset". An expected result is to be the same but an effect radically different as you can see [1]. IMHO allowing string offset to be unset using unset construct could be allowed to ensure consistency then. Any thoughts on this? BR, -- Micha=C5=82 Brzuchalski [1] https://3v4l.org/0Ol3N --00000000000080e9440599e0f8af--