Skip to content

fix(occ): pass empty string instead of null to user search in home list commands#41631

Merged
DeepDiver1975 merged 1 commit into
masterfrom
fix/41630-home-list-search-null
Jun 16, 2026
Merged

fix(occ): pass empty string instead of null to user search in home list commands#41631
DeepDiver1975 merged 1 commit into
masterfrom
fix/41630-home-list-search-null

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Member

Summary

occ user:home:list-dirs (and user:home:list-users --all) crash on PHP 8 with:

TypeError: OC\DB\Connection::escapeLikeParameter(): Argument #1 ($param)
must be of type string, null given

Root cause

Both commands passed null as the search pattern to IUserManager::search() to mean "all users":

  • core/Command/User/HomeListDirs.php:55search(null)
  • core/Command/User/HomeListUsers.php:82search(null, null, null, true)

The null flows through Manager::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 a TypeError. (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 '', which UserSearch::isSearchable() explicitly treats as searchable and which every other caller in the codebase already uses (ListUsers, ScanFiles, Scan, Principal).

Fix

Pass '' instead of null at both call sites.

Tests

Updated HomeListDirsTest and HomeListUsersTest to assert the search pattern is identicalTo('') (strict — loose with('') would pass against null since '' == null in PHP). Both tests fail against the old code and pass after the fix.

Fixes #41630

🤖 Generated with Claude Code

…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 phil-davis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?!

@DeepDiver1975

Copy link
Copy Markdown
Member Author

Or does that lead us down a whole rabbit-warren of implementing full parameter and return type declarations across the codebase?!

this is what I am fearing ..... I'd push back such code cleanup for the time being ....

@DeepDiver1975 DeepDiver1975 merged commit c8b9dd5 into master Jun 16, 2026
26 checks passed
@DeepDiver1975 DeepDiver1975 deleted the fix/41630-home-list-search-null branch June 16, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OC11: command: 'occ user:home:list-dirs' errors when using Docker

2 participants