-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Finder] Exclude relative to content root if prefixed /
#54752
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
base: 5.4
Are you sure you want to change the base?
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Fixes symfony#28158 Fixes symfony#47431 Related: symfony#26396 Related: symfony#9158 Related: symfony#28410
3aeedb6
to
d685583
Compare
/
/
Both test failures appear unrelated. |
src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php
Outdated
Show resolved
Hide resolved
I had some unit test changes ready to test this solution, so I have made PR #54754 with the test changes/additions and the code cherry-picked from here. I made it to the 7.1 branch, because, as I read the rules, this is a "new feature" and so new features go to the current minor version branch. Is this a "new feature" or an "enhancement that helps adjust behavior"? |
Does the notInPath method work for this ? This will be a big BC break, as |
Thanks for your comments. Some initial responses below.
Only in the same sense that
Paths provided to So if someone puts a slash in front they (presumably) mean the root of their content ( If that's not what they intended, well that's never been supported (or worked - and still won't). i.e. So if someone is specifying
Or:
That second situation is what this would fix/enable. You can play with the regex a bit (keeping in mind the new one is only used against Old and only: New and supplemental: Aside: The actual bug is in the original regex and/or in which scenarios even end up using it I suppose[1], but fixing this would not be BC. This PR does so in a reasonable way (I think!) without breaking existing code. It makes [1] symfony/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php Lines 56 to 84 in c834064
|
Thank you for the detailed answer. I guess adding some functional tests (testing the behaviour with the recursiveiterator) is not a bad idea :) |
See the PR #54754 that has this code to the 7.1 branch, where I have expanded the test coverage. I'm happy to hear ideas for other combinations of things that should have test cases. (Note: "someone" will need to decide if this is a fix or a new feature. That will determine if this will be allowed as a "patch" fix in v5 and v6 or whether it is only released to v7) |
IMO this would be very nice to have as a bug fix, because the advertised behavior was broken. As an aside, we are trying to add support for this in Composer's autoloader which uses Finder to iterate files for classmaps, as this would allow skipping whole directories instead of iterating all files anyway like we do now, gaining perf, but I have no way of converting an |
Agree. I am happy to help sort out "back-porting" the test changes to here for 5.4, and making a "mid-port" PR for major version 6. "Someone" just decide if this will be accepted as a bug fix. |
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
Added tests:
Technically sub-folders don't have to work I suppose for now, but I'd like to see if I can get them to work too since it'll feel like a more correct implementation. I'll try to take a look at those in the coming days. If anyone sees the culprit, don't hesitate to speak up (I have a few guesses but don't have more time to look at it tonight). |
…solution at the moment Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
This looks like an important thing to fix (and we have another fix proposal in #54754). Let's ping @symfony/mergers to see if we can work on finishing this one. Thanks. |
My contribution there is just to expand the test coverage to try and cover more cases. And I made the PR to a later branch, in case "those that have the power" decide that it has to go in the later branch. How to we get the attention of the Symfony maintainers? |
Carson the bot is threatening to close the OP issue and there seems to be failing checks in this PR? I think this is still relevant, @joshtrichards do you feel that fixing the failing tests and code style issues is possible? |
Fixes #28158
Fixes #47431
Related: #26396
Related: #9158
Related: #28410
This implements a fix for this situation in a non-BC breaking way by doing content root-only relative matches when the
exclude()
path is prefixed by/
. If anexclude()
path does not start with/
, the behavior stays the same as today and will exclude any matching sub-dir anywhere in the tree.Approach first suggested here by @ogizanagi and most recently reiterated by @wouterj here.