-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection sorting appears to be altered on v10.1.0 #46213
Comments
Are you using one of the following functions? If so, the #46105 may be affected
|
Yes, was able to trace the issue back to #46105, and specifically because of my use of the In <10.1.0, calling Before: $collection = new Collection([
'alpha',
'bravo',
'charile',
]);
dump($collection->random(3)->toArray());
//['alpha', 'bravo', 'charlie']; After: $collection = new Collection([
'alpha',
'bravo',
'charile',
]);
dump($collection->random(3)->toArray());
//['alpha', 'charlie', 'bravo'];
//['charlie', 'bravo', 'alpha'];
//['bravo', 'alpha', 'charlie']; For most of my tests I didn't actually care about the order, so I was able to switch from using In other tests I had to sort my random elements to make sure they specifically matched returned results. As minor as this is, it feels like a breaking change to me. Even though Laravel does not explicitly call out the order elements may be returned, because
https://www.php.net/manual/en/function.array-rand.php For me specifically, this just exposed some brittleness/assumptions in my tests, but for other people it may have a more serious impact. |
It should be fixed on the |
Description:
After upgrading to Laravel 10.1.0, I was getting some test failures that appeared to be related to Collection sorting. I reverted back to Laravel v10.0.3 and all tests passed again.
I haven't had time to deep dive in yet, but will soon and report back with more info.
Steps To Reproduce:
Possibly use the Collection
sort()
method. Will provide more details as I dig in.The text was updated successfully, but these errors were encountered: