Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107917 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35262 invoked from network); 16 Dec 2019 13:21:07 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 16 Dec 2019 13:21:07 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 7DAB12CEC78 for ; Mon, 16 Dec 2019 03:20: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,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: No Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (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 03:20:45 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id b19so6288955wmj.4 for ; Mon, 16 Dec 2019 03:20:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=tEG0qT4saEFCFmsYMDzlorz91Jtzh6PSGjUYACPjBj0=; b=EMNBL2Ykgk/uTLCwwX2HAyk51799WefZtG8NfSYcgfdavUlce0gGNRY7IRx3IfkTIn TfNbe3n4yhMLLIo352OoVTCZ2ROU5xhXyKOm1Isn2V0wud894dcdLT7BlY0WK0OZUnLn a+nTTSaS1haqvXCcJqzMIBCE/QGXHGtDddxe8k4MZCW149PGYIDGd6E5eXjvITtTklM/ Md2s/9Q6pp8M8ygSspcBOKp12IDmYvDeaoDHykJ1FD6/D2vumsi65KbT4dFnt/sJREf/ GBxzg+V4W/2D9+P07zTTdj6LylV5L8lNsEgXjGFn6wJa6IFDL79yTStnQCr/RjiZSzQi 4TNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=tEG0qT4saEFCFmsYMDzlorz91Jtzh6PSGjUYACPjBj0=; b=Uu2mrOfQP6tiTsIN8q3azr1TxIkfB+ONUA5IIH5vG4yt5i+jKmfPafMNGk1+ocIfuz 4D+s0TqWucA4O46TkIqu1mtXh08DmAhdPsizpY0rzskwWdX739TeaQJXsTLwrrL8gtQh T63dUx0TQF8e2mnVeO2N1H3SMI84hpliDCHzs/oSso1F5s2WT0aYJ1lh8yItmCJditSX VEDBmmLPeuB0BVDogktgH554QIGHey0tj4ji9ZhG8UvR0vql3yOmVu/+Rz3nN8lXR8wp CA+KRcZUD4kAc2OlhIhTktHhe7gqTWXB4Ldey7REiV+KiaQv4V1a1lFU34wGOdYQ6icd HjFg== X-Gm-Message-State: APjAAAVAmV8ywZVPZ46TNzCQ6nymjGIl5f+/jHPk3OwXHwSuJVJtJPz1 S6ABtIZXuaZPoptRbmzfLlk= X-Google-Smtp-Source: APXvYqxsj0eqOI/qZbda0tnZaXYvTkaX6zW4ITKLxQwIyJfSZrU/7FcH21Whm4B+cVdjlkrvD4gehw== X-Received: by 2002:a1c:2e91:: with SMTP id u139mr28486481wmu.154.1576495244051; Mon, 16 Dec 2019 03:20:44 -0800 (PST) Received: from [192.168.0.63] (84-75-30-51.dclient.hispeed.ch. [84.75.30.51]) by smtp.gmail.com with ESMTPSA id u24sm13774678wml.10.2019.12.16.03.20.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2019 03:20:43 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Mon, 16 Dec 2019 12:20:42 +0100 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: George Peter Banyard X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] Allowing variable strings to be defined for a string offset From: claude.pache@gmail.com (Claude Pache) > Le 16 d=C3=A9c. 2019 =C3=A0 10:58, George Peter Banyard = a =C3=A9crit : >=20 > Greetings internals, >=20 > I'm here to get internals's opinion about allowing a string offset to = be > replaced with arbitrary strings. >=20 > Since forever strings with more then one byte have been truncated = silently > 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 per > the Reclassifying engine warnings RFC. [2] > An illustration of both these cases is available on 3v4l.org [3] > >=20 > 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). >=20 > 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. >=20 > 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 = points > out to some kind of logic error. > I would assume the impact to be minimal for both of these case. >=20 > Any opinions? >=20 > Best regards >=20 > George Peter Banyard >=20 > [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 Being able to replace one byte with an arbitrary string does not seem = very useful to me, unless you add the functionality of replacing an = arbitrary substring with an arbitrary string (an equivalent of = array_splice() for strings). Your implementation gives the following = potentially surprising result: IMO, the only reasonable thing to do at this point is just emitting a = Warning (or an Error). =E2=80=94Claude