Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103667 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93874 invoked from network); 2 Jan 2019 19:19:34 -0000 Received: from unknown (HELO tbjjbihbhebb.turbo-smtp.net) (199.187.174.11) by pb1.pair.com with SMTP; 2 Jan 2019 19:19:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=php.net; s=turbo-smtp; x=1547049134; h=DomainKey-Signature:Received: Received:MIME-Version:References:In-Reply-To:From:Date: Message-ID:Subject:To:Cc:Content-Type; bh=lGpJeDJDqE4uFO6umzw01t aQBT+0gdqoW+cX3rTd5dA=; b=SNbuzl4jvnk/Am6aEi8XPbLpA+cwIBk4Z32LNm E/EJERaxTWMo7LC3OE2jBOioQTtjrAzmeJ7JG6aDGriW9aGd+3R71/qaaXlLDeuG 5e3UPydY/qS2NJ4T+IT0CM1vwccSh9WwBX0aHAI+IxC7AEjrNavY1pTpgqbK70yl jIl80= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=turbo-smtp; d=php.net; h=Received:Received:X-TurboSMTP-Tracking:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version:References:In-Reply-To:From:Date:X-Gmail-Original-Message-Id:Message-ID:Subject:To:Cc:Content-Type; b=BS5pIcpwQ22VMV+ETRovaiqB+cykSUai4AKQonFQ9xWqtxnQ+soIbM6aPD3QRz LKo7rN7UnJH2r5ps1En2sJepVGRQa+JJ9WhXzEL9LQPG6zSNCzEMq4C4m6O6hM5C Hws3uDjHZzp4TJUtVhIspo/uPutk4IZR5u56rAdI+IvXs=; Received: (qmail 25915 invoked from network); 2 Jan 2019 15:52:13 -0000 Received: X-TurboSMTP-Tracking: 4770804025 X-Gm-Message-State: AJcUukeYCbqbmFsnZzCTHHoYO5RBf5Cx2ZnwFcNGvV1W1bJGKOqCWyYB MQMWRxPEvtBeabJBCbq1Iu293YdRibVEon/gPNw= X-Google-Smtp-Source: ALg8bN4QPhcIaVE86MHXTxJFHf+E1NzyUEW7S2+k6dNLU3n3Fn90lZoXP3iUv/wgsQpsm8+2UZWNjZwOzEf0Z0Tnv/Q= X-Received: by 2002:a37:8383:: with SMTP id f125mr41206550qkd.49.1546444333228; Wed, 02 Jan 2019 07:52:13 -0800 (PST) MIME-Version: 1.0 References: <94f5feb8-6589-3a0a-2849-7679cec1858c@gmx.de> <574c2a6f-9ca7-7aa8-4bd9-a7191b27cb31@gmx.de> In-Reply-To: <574c2a6f-9ca7-7aa8-4bd9-a7191b27cb31@gmx.de> Date: Wed, 2 Jan 2019 17:51:17 +0200 X-Gmail-Original-Message-Id: Message-ID: To: "Christoph M. Becker" Cc: Nikita Popov , PHP internals , Stanislav Malyshev Content-Type: multipart/alternative; boundary="00000000000025a744057e7ba135" Subject: Re: [PHP-DEV] Inconsistent float to string vs. string to floatcasting From: zeev@php.net (Zeev Suraski) --00000000000025a744057e7ba135 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2 Jan 2019 at 17:12 Christoph M. Becker wrote: > On 02.01.2019 at 12:32, Zeev Suraski wrote: > > > Unless I'm missing something, changing this behavior would require a > full, > > line-by-line audit of the code - with no Search & Replace patterns that > can > > find these instances in any reasonable level of reliability. Every pla= ce > > where a floating number (which could come from anywhere, so not very ea= sy > > to track) is used in a string context (which too can happen in countles= s > > different contexts, virtually impossible to track) would be affected. > > Sounds pretty nightmarish to me. I for one fail to recall a behavioral > > change that was quite as significant as this one in terms of the > complexity > > of finding instances that must be updated. Like Stas, I'm not disputin= g > > that this is not an ideal behavior or that we'd do it differently if we > > were starting from scratch - but I also agree with him that it's pretty > > much out of the question to simply change it at this point. > > > > Can you point out a change you believe is as or more significant than > this > > one that we did? I think the only one that comes close is > > magic_quotes_runtime, and even that was significantly easier to handle = in > > terms of the cost of auditing the code (again, unless I'm missing > > something, which is of course very much a possibility). > > Wasn't the removal of register_globals a similar change? Not so long > ago I've stumbled upon a script which counteracted this by extract()ing > the superglobals manually (surely, a very bad practise, but at least > some kind of workaround to keep legacy scripts going). However, the > introduction of =E2=80=9CUniform Variable Syntax=E2=80=9D[1] may have cau= sed similar > issues; likely without any possible workaround. > Well, the removal of register_globals was a very big deal - and was done for arguably much more pressing reasons (security). So I wouldn't refer to it as basis to illustrate that this isn't a big deal... That said - as you pointed out yourself, there was a very easy workaround for those that didn't want or couldn't afford to do a full code audit - a few lines of user and code that emulated it. Regarding Uniform Variable Syntax - the cases where the behavior changed there were truly edge cases, that nobody in his right mind should be using anyway, and that can probably also be searched for using a clever regex. This isn=E2=80=99t the case here. Unless I=E2=80=99m missing something, a = code as simple as $x =3D 3.99; print =E2=80=9CPrice: $x=E2=80=9D; would be affected. So, I think it has a much bigger impact than the UVS incompatibility, it=E2= =80=99s much more difficult to find, and does not have a userland workaround unless we introduce a language level one. > > > The solution for this *might* be a very unholy one - actually going > against > > our practices adding a new INI entry to would disable the > locale-awareness > > for float->string conversions; But for upgrade considerations, I don't > > think we can even consider simply changing this behavior and forcing > > virtually everyone using a non-dot decimal separator to undergo a full > code > > audit. > > Would it be a sensible option to trigger a warning or notice whenever a > float is converted to string yielding a different result than before, > using an ini directive to control this? Or perhaps even throw a > deprecation notice in this case, without even introducing an ini directiv= e? It would be technically possible, but given the context these conversions often occur in I think it would look awful... Also, one would have to run their software through all possible code flows in order to know for sure it=E2=80=99s safe to turn it off and move to the new behavior. And legend = has it, that not all PHP users (or developers in general) have 100% testing coverage :) If we do end up adding a new INI entry - maybe it can be a tristate - legacy, legacy+notice, or new. Just a thought. And I wouldn=E2=80=99t com= mit to actually removing it at any time by officially deprecating it... Zeev --00000000000025a744057e7ba135--