Bug #79868 [Ver->Csd]: Sorting with array_unique gives unwanted result
Edit report at https://bugs.php.net/bug.php?id=79868&edit=1
ID: 79868
Updated by: nikic@php.net
Reported by: dries at vints dot io
Summary: Sorting with array_unique gives unwanted result
-Status: Verified
+Status: Closed
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:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6f8d0ba0dd7d9e96ec6b2b75337f701a5ce3d3f0
Log: Fix bug #79868
Previous Comments:
------------------------------------------------------------------------
[2020-07-19 10:01:52] dries at vints dot io
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.
------------------------------------------------------------------------
[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
Thread (7 messages)