On 01/18/2015 11:45 AM, Stanislav Malyshev wrote:
> Hi!
> 
>> Yes, like I said, I am aware that the comparison function is flaky
>> but it is still code that has worked for 15 years so we have to be
>> clear about the BC break. The fact that it works up until the array
> 
> Looking at that function, I'm not sure the fact it worked is not pure
> luck. It is not an order function - it produces different result when
> parameters are switched, i.e. if you call f($a, $b) it would say $a >
> $b, but if you call f($b, $a) it would say $a == $b. Of course, even
> broken functions can produce valid results, with some luck, but I'm not
> sure we can guarantee non-order functions to work when order function is
> required.

Sure, I understand it is flaky. But it is still code that has always
worked in every single version of PHP (and HHVM) ever released going
back 15+ years.

eg. http://3v4l.org/7prWJ

and I have a php3 build here that it works on as well.

We have to be really really careful with this "oh, that code is wrong,
so we can break it argument". This will break hundreds if not thousands
of sites in a hard-to-debug way. It took me less than a minute of
looking on Github to find a case that will break:

https://github.com/chenboking/service.downloadmanager.amule/blob/cda510415f9a58660e096a7de42b3ea6f39ee851/webserver/php-default/amuleweb-main-search.php#L121

It is extremely common to just do a less-than or a greater-than check in
a user comparison function. Of course it isn't textbook-correct, but
since it has always worked, people do it.

-Rasmus

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to