Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107915 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19204 invoked from network); 16 Dec 2019 11:59:13 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 16 Dec 2019 11:59:13 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id C98142CA62A for ; Mon, 16 Dec 2019 01:58:50 -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=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No Received: from mail-vs1-f66.google.com (mail-vs1-f66.google.com [209.85.217.66]) (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 01:58:50 -0800 (PST) Received: by mail-vs1-f66.google.com with SMTP id p6so3714460vsj.11 for ; Mon, 16 Dec 2019 01:58:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+Pf+LYibfAPyRNF2C0Vivo1oBfvLpszEDlphrT/fmy4=; b=YEVNBWMIDj4FB5v1qm7IqyLH5wz56yhhcEnB68OCvepKg01R6Eu43QoOxTTv3EZd8c jZx7tvMIQUf3I9GbhlJ2VqRA7YnqQb/FJBIiCD17UsysHyY3kTcLltTPdlT8fWQHHd5d RML/aEQbjo8lOwL25ou79nw+5nibV+HNPFNzGFtxPyplHqhlXSPOImjvJCQb/wRoh/+r tFKtRvZSkt8o+wOX5RBfhv++bSNqFD00OdDNY7F6KB4uuyQeSsu/RrBUMqFpXFcM1yYV nox1odSCDuBMRtPa69UANUKI8aQ2gYS19Z/DoStLhcFx8nPv2cLHnmyNFcu3mIpGQgiY 6O+g== X-Gm-Message-State: APjAAAV9hCaCWbTteaEJ6ybYd5BN4uIFcyvt+ToxYWtbF3OM+oitfwTH Md8FFedb+9KhFM3xppadz+0JR9F2Tqk= X-Google-Smtp-Source: APXvYqwXtmLGQ/+42UkyFoCbBGDoZX1I7VWms6DNqMq6v3dZKpDaDmYb9XBxUtsRNlrn/zk7yqkBxw== X-Received: by 2002:a67:d31e:: with SMTP id a30mr19886203vsj.205.1576490329720; Mon, 16 Dec 2019 01:58:49 -0800 (PST) Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com. [209.85.221.170]) by smtp.gmail.com with ESMTPSA id 9sm8595467vkr.39.2019.12.16.01.58.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Dec 2019 01:58:49 -0800 (PST) Received: by mail-vk1-f170.google.com with SMTP id t129so1441613vkg.6 for ; Mon, 16 Dec 2019 01:58:48 -0800 (PST) X-Received: by 2002:ac5:c7da:: with SMTP id e26mr23899778vkn.38.1576490328603; Mon, 16 Dec 2019 01:58:48 -0800 (PST) MIME-Version: 1.0 Date: Mon, 16 Dec 2019 10:58:34 +0100 X-Gmail-Original-Message-ID: Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000000742a50599cf4228" X-Envelope-From: Subject: [PHP-DEV] Allowing variable strings to be defined for a string offset From: girgias@php.net (George Peter Banyard) --0000000000000742a50599cf4228 Content-Type: text/plain; charset="UTF-8" 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 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] 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 points 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=71572 [2] https://wiki.php.net/rfc/engine_warnings [3] https://3v4l.org/O0nEM [4] https://github.com/php/php-src/pull/5013 --0000000000000742a50599cf4228--