Bug #75513 [Opn->Nab]: uksort not working correctly in php 5.6.32

From: Date: Mon, 13 Nov 2017 06:33:28 +0000
Subject: Bug #75513 [Opn->Nab]: uksort not working correctly in php 5.6.32
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212559@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75513&edit=1 ID: 75513 Updated by: requinix@php.net Reported by: daniel at ciokix dot ro Summary: uksort not working correctly in php 5.6.32 -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Ubuntu 14.04 PHP Version: 5.6.32 Block user comment: N Private report: N New Comment: Your comparison function is inconsistent: for example, it will claim that l=a (neither value depends on the other) and that t=l (same) yet it would claim that a<t. PHP 5.6 does not attempt that comparison because (a) that was sheer luck based on the ordering of the original array, but more importantly (b) it could/should logically infer that a=t based on the previous results. PHP 7's sorting behavior changed and the problem is no longer apparent for that given ordering; I tried shuffling randomly a couple times but didn't get any incorrect results, however it's quite possible there is at least one original array ordering that will expose the same flaw. PHP's quicksort is not really the right tool for this job. A topological sort is the most appropriate answer in theory but a simple insertion sort may be sufficient. Regardless, 5.6 has reached end of life and is only receiving security-related fixes now. Previous Comments: ------------------------------------------------------------------------ [2017-11-13 05:17:34] daniel at ciokix dot ro Description: ------------ Although this issue is not reproducible in php7 or later, it occurs in php5.6.32 and it would be great if it could be fixed in the next php5.6 release. Test script: --------------- The differences regarding uksort response for php5.6 and php7 can be seen on 3v4l: https://3v4l.org/Lfq4C ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75513&edit=1

« previous php.bugs (#212559) next »