Re: com php-src: Faster sorting algo: UPGRADING Zend/Makefile.am Zend/tests/methods-on-non-objects-usort.phpt Zend/zend_API.c Zend/zend_hash.c
Zend/zend_hash.h Zend/zend_ini.c Zend/zend_llist.c Zend/zend_qsort.c Zend/zend_qsort.h Zend/zend_sort.c Zend/zend_sort.h Zend/zend_ts_hash.c
Zend/zend_types.h configure.in ext/ereg/ereg.c ext/intl/collator/collator_sort.c ext/phar/dirstream.c ext/phar/phar_internal.h ext/standard/array.c
ext/standard/info.c ex

From: Date: Sun, 18 Jan 2015 22:08:35 +0000
Subject: Re: com php-src: Faster sorting algo: UPGRADING Zend/Makefile.am Zend/tests/methods-on-non-objects-usort.phpt Zend/zend_API.c Zend/zend_hash.c
Zend/zend_hash.h Zend/zend_ini.c Zend/zend_llist.c Zend/zend_qsort.c Zend/zend_qsort.h Zend/zend_sort.c Zend/zend_sort.h Zend/zend_ts_hash.c
Zend/zend_types.h configure.in ext/ereg/ereg.c ext/intl/collator/collator_sort.c ext/phar/dirstream.c ext/phar/phar_internal.h ext/standard/array.c
ext/standard/info.c ex
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-80761@lists.php.net to get a copy of this message
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: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#80761) next »