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

From: Date: Sun, 19 Jul 2020 09:56:25 +0000
Subject: Bug #79868 [Asn->Ver]: Sorting with array_unique gives unwanted result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228115@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
 Updated by:         sjon@php.net
 Reported by:        dries at vints dot io
 Summary:            Sorting with array_unique gives unwanted result
-Status:             Assigned
+Status:             Verified
 Type:               Bug
 Package:            *General Issues
 Operating System:   macOS Catalina 10.15.5
 PHP Version:        8.0.0alpha2
-Assigned To:        sjon
+Assigned To:        nikic
 Block user comment: N
 Private report:     N



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


Thread (7 messages)

« previous php.bugs (#228115) next »