[PR #5715] Fix MetadataFilter regression after #507 (#2815) not testing filters after first one #9703

Open
opened 2026-01-22 16:05:10 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/5715

State: closed
Merged: No


PR #507 (issue #2815 [DDC-2128]) introduced a regression, with the effect that when providing a filter array with more than one string, only the first pattern is tested (and the subsequent ones are like ignored).

With the series of commits 6963bf6028%5E...9a3cf77919b0541048be5bfe7806a001c31974d1, the function accept() was modified so that, if the first pattern of the $this->filter array (is not invalid, but) does not match $metadata->name, then the function returns false early, never trying the next patterns in the array.
Instead, it should continue to iterate, and only return true on the first encountered pattern that matches (if any) or return false after the end of the loop (if no pattern matched). (That's what it was doing before the series of commits, see 6963bf6028%5E/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php#L78-L84.)

Sorry I cannot practically write a unit-test for this fix, but feel free to add one (or help me).
Update: I added a test (and checked that it was passing before the regression, is failing without the fix and is passing with the fix).
Update (2): I amended the test commits (sorry for the confusion if any). The fix is only for version 2.5+ but the test could be suitable for 2.4 (and maybe even older branches) by not taking the last commit.

**Original Pull Request:** https://github.com/doctrine/orm/pull/5715 **State:** closed **Merged:** No --- PR #507 (issue #2815 [DDC-2128]) introduced a **regression**, with the effect that when providing a filter array with more than one string, _only the first pattern is tested_ (and the subsequent ones are like ignored). With the series of commits https://github.com/doctrine/doctrine2/compare/6963bf60286a3b4f3d74f3769a6a2a1f0d001ad0%5E...9a3cf77919b0541048be5bfe7806a001c31974d1, the function `accept()` was modified so that, if the first pattern of the `$this->filter` array (is not invalid, but) does not match `$metadata->name`, then the function returns `false` early, _never trying the next patterns in the array_. Instead, it should continue to iterate, and only return `true` on the first encountered pattern that matches (if any) or return `false` after the end of the loop (if no pattern matched). _(That's what it was doing before the series of commits, see https://github.com/doctrine/doctrine2/blob/6963bf60286a3b4f3d74f3769a6a2a1f0d001ad0%5E/lib/Doctrine/ORM/Tools/Console/MetadataFilter.php#L78-L84.)_ ~~Sorry I cannot practically write a unit-test for this fix, but feel free to add one (or help me).~~ _Update:_ I added a test (and checked that it was passing before the regression, is failing without the fix and is passing with the fix). _Update (2):_ I amended the test commits (sorry for the confusion if any). The fix is only for version 2.5+ but the test could be suitable for 2.4 (and maybe even older branches) by not taking the last commit.
admin added the pull-request label 2026-01-22 16:05:10 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9703