Skip to content

[Config] Fix files sorting in GlobResource #43591

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

Merged
merged 1 commit into from
Oct 19, 2021
Merged

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Oct 19, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

It should be on path and not on info

and it's a big perf boost: https://blackfire.io/profiles/compare/27f409a5-73c7-4285-9b58-e631abbdb325/graph

image

@fabpot
Copy link
Member

fabpot commented Oct 19, 2021

That's a behavior change, so should be on 5.4.

@@ -156,7 +156,7 @@ function (\SplFileInfo $file, $path) {
),
\RecursiveIteratorIterator::LEAVES_ONLY
));
uasort($files, 'strnatcmp');
uksort($files, 'strnatcmp');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a bug to me: sorting was supposed to happen on keys, not on values

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it, but it's been like that for years.

@stof
Copy link
Member

stof commented Oct 19, 2021

@fabpot I don't think it changes the behavior. casting the SplFileInfo to string (when passing the value to strnatcmp) produces the same value than the key in the array (but slower). So the behavior should still be the same (and the proof is the fact that tests have not required changes).

For the initial sort, this is an optimisation to try to have an array that is already partially sorted when merging the arrays of different paths. Using natsort there is also a bugfix making the optimization actually work (by using the same sorting than in the final array)

@fabpot
Copy link
Member

fabpot commented Oct 19, 2021

Thank you @lyrixx.

@fabpot fabpot merged commit 4218aa3 into symfony:4.4 Oct 19, 2021
@lyrixx lyrixx deleted the config-glob-bug branch October 19, 2021 15:35
This was referenced Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants