Repository navigation
Bool filters onlyMy and shared: use relation conditions in middle join - #3790
Merged
yurikuzn merged 1 commit intoSep 15, 2026
Merged
Conversation
The onlyMy and shared bool filters join the assignedUsers and collaborators middle tables without the relation conditions. Both relations use the shared EntityUser and EntityCollaborator tables, so the join matched rows by entityId alone, without entityType. Apply the conditions as the only-team access control filter does.
Contributor
|
Hi, Thank for the PR. Could you accept our CLA by creating a commit here: https://github.com/espocrm/cla. |
Contributor
Author
|
Done — signed in espocrm/cla#130, adding Thanks for looking at the PR so quickly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While reading fc7ac8b ("Fix only team filter, use conditions") I checked the other places that join the assignedUsers and collaborators middle tables, and found two that were left out: the
onlyMyandsharedbool filters.Both relations are stored in the shared
EntityUserandEntityCollaboratortables, and their relation defs carry anentityTypecondition (set inLinkConverters/EntityUser.phpandEntityCollaborator.php).OnlyMyandSharedbuild the join with onlyentityIdanddeleted, so the sub-query matches a middle row by id alone, whatever entity type it belongs to. With the usual random ids this rarely shows up, but it can give a false match when two records of different types share an id, and it is inconsistent withOnlyTeam,ForeignOnlyOwn,ForeignOnlyTeamandRelationQueryHelper, which all constrainentityType.The change copies the loop from
OnlyTeam: the relation conditions are added to the join conditions, so nothing changes for relations that have none.I added
tests/unit/Espo/Core/Select/Bool/FiltersTest.php, which builds each filter against a many-many relation with anentityTypecondition and checks the join. Without the fix both tests fail (Failed asserting that null matches expected 'Test'), with it they pass, and the wholetests/unit/Espo/Core/Selectsuite passes (135 tests). phpstan reports no errors on the two changed files. I based this onfixsince it is a small fix; happy to retarget it tomasterif you prefer.Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.