fix(occ): pass empty string instead of null to user search in home list commands#41631
Merged
Merged
Conversation
…st commands user:home:list-dirs and user:home:list-users --all passed null as the search pattern to IUserManager::search(). On PHP 8 the null reached Connection::escapeLikeParameter(string $param) and raised a TypeError, aborting the command. Use the empty string '' instead, which is the established "match all" sentinel recognised by UserSearch::isSearchable() and used by every other caller. Fixes #41630 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
phil-davis
approved these changes
Jun 16, 2026
phil-davis
left a comment
Contributor
There was a problem hiding this comment.
In places like:
https://github.com/owncloud/core/blob/master/lib/private/User/Manager.php#L285
/**
* search by user id
*
* @param string $pattern
* @param int $limit
* @param int $offset
* @param bool $alwaysReturnAllMatches
* @return \OC\User\User[]
*/
public function search($pattern, $limit = null, $offset = null, $alwaysReturnAllMatches = false) {
Should we specify the types?
$pattern has to be a string, and passing null here was an early part of the problem.
Or does that lead us down a whole rabbit-warren of implementing full parameter and return type declarations across the codebase?!
Member
Author
this is what I am fearing ..... I'd push back such code cleanup for the time being .... |
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.
Summary
occ user:home:list-dirs(anduser:home:list-users --all) crash on PHP 8 with:Root cause
Both commands passed
nullas the search pattern toIUserManager::search()to mean "all users":core/Command/User/HomeListDirs.php:55—search(null)core/Command/User/HomeListUsers.php:82—search(null, null, null, true)The
nullflows throughManager::search()→AccountMapper::search()→Connection::escapeLikeParameter(string $param). On older PHP it was silently coerced to''; PHP 8's strict scalar type hint rejects it and raises aTypeError. (The Docker reference in the issue is incidental — it's a PHP-version difference, not a container one.)The correct "match all" sentinel is the empty string
'', whichUserSearch::isSearchable()explicitly treats as searchable and which every other caller in the codebase already uses (ListUsers,ScanFiles,Scan,Principal).Fix
Pass
''instead ofnullat both call sites.Tests
Updated
HomeListDirsTestandHomeListUsersTestto assert the search pattern isidenticalTo('')(strict — loosewith('')would pass againstnullsince'' == nullin PHP). Both tests fail against the old code and pass after the fix.Fixes #41630
🤖 Generated with Claude Code