Bug #79868 [Ver]: Sorting with array_unique gives unwanted result

From: Date: Sun, 19 Jul 2020 10:01:52 +0000
Subject: Bug #79868 [Ver]: Sorting with array_unique gives unwanted result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228116@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79868&edit=1 ID: 79868 User updated by: dries at vints dot io Reported by: dries at vints dot io Summary: Sorting with array_unique gives unwanted result Status: Verified Type: Bug Package: *General Issues Operating System: macOS Catalina 10.15.5 PHP Version: 8.0.0alpha2 Assigned To: nikic Block user comment: N Private report: N New Comment: Just to be fully clear: we've already worked around this by writing our own sorting function. If you decided that this is indeed the intended behavior then that would be alright with us. Previous Comments: ------------------------------------------------------------------------ [2020-07-18 16:37:56] dries at vints dot io @sjon I can't, I don't dispute the new behavior makes more sense. This was a side effect we didn't forsee. I'm reporting this as a change in behavior after Nikita confirmed this wasn't suppose to change: https://twitter.com/nikita_ppv/status/1284143520962486273 ------------------------------------------------------------------------ [2020-07-18 11:26:26] sjon@php.net can you explain why "Illuminate\Routing" should be sorted before "Illuminate\Auth" ? ------------------------------------------------------------------------ [2020-07-17 15:22:28] dries at vints dot io Description: ------------ Sorting with array_unique returns different results than in previous PHP versions. I suspect this is because of https://wiki.php.net/rfc/stable_sorting If you run the test script from below it'll return the result seeing in https://3v4l.org/9sbAq Test script: --------------- var_dump(array_unique([ 'Illuminate\Routing\Middleware\SubstituteBindings', 'Illuminate\Auth\Middleware\Authorize:edit,post', ], SORT_REGULAR)); Expected result: ---------------- array(2) { [0]=> string(48) "Illuminate\Routing\Middleware\SubstituteBindings" [1]=> string(46) "Illuminate\Auth\Middleware\Authorize:edit,post" } Actual result: -------------- array(2) { [1]=> string(46) "Illuminate\Auth\Middleware\Authorize:edit,post" [0]=> string(48) "Illuminate\Routing\Middleware\SubstituteBindings" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79868&edit=1

« previous php.bugs (#228116) next »