fix(search): search as the user the provider is given - #2936
Open
jospoortvliet wants to merge 1 commit into
Open
fix(search): search as the user the provider is given#2936jospoortvliet wants to merge 1 commit into
jospoortvliet wants to merge 1 commit into
Conversation
SearchTablesProvider receives the account to search as, but called TableService::search() and ViewService::search() without it. Both accept an optional $userId and fall back to PermissionsService::preCheckUserId(null), which resolves the session user — so any caller searching on behalf of someone else silently received its own results instead. This has no effect on unified search, where the two are always the same person. It matters for callers that search on behalf of another account, such as background jobs or compliance tooling, where returning the caller's own tables is not a degraded result but a wrong one. Both services already take the parameter, so this passes the argument that already exists rather than changing any API. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Jos Poortvliet <jospoortvliet@gmail.com>
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.
Both services already take the parameter, so this passes the argument that already exists rather than changing any API.
The problem
SearchTablesProvider receives the account to search as, but calls TableService::search() and ViewService::search() without it. Both accept an optional $userId and fall back to PermissionsService::preCheckUserId(null), which resolves the session user so any caller searching on behalf of someone else silently received its own results instead.
I assume this is not intentional, just 'good enough' for unified search.
Some more details:
lib/Search/SearchTablesProvider.php:82and:93callTableService::search($term, $limit, $offset)andViewService::search($term, $limit, $offset).?string $userId = nulland, when null, callPermissionsService::preCheckUserId(null)→$this->userId, the session user.search(IUser $user, ISearchQuery $query)is handed the account to search as, and already uses it for theisEnabledForUser()check on the line above.Through the unified search UI the session user and
$userare always the same, so nothing is visibly broken today. But it breaks when you need to search on behalf of another account, like a background job, or a compliance tool that must search within a defined set of accounts.this PR
The change in this PR is very simple:
Pass
$user->getUID()to both calls. No API change; both services already accept it.Tests
New
tests/unit/Search/SearchTablesProviderTest.php:Verified the test fails against the unfixed provider and passes with it.
Checks run
phpunit -c tests/unit/phpunit.xml --filter SearchTablesProviderTest→ 2 passed (run inside the dev container; the bootstrap needs a database)php -lon both filesphp-cs-fixer --dry-runon both files → no violations🖼️ Screenshots
🏁 Checklist
/backport to stableX.X🤖 AI (if applicable)
The change and its test were produced with Claude Code (claude-opus-5).