Issue Bug Resolved

#111113Live search throws ValueError when files share an identifier across storages

Georg Ringer 10/17/26, 11:25 updated 10/17/26, 12:35

Description

Searching in the backend live search can fail with an exception:

ValueError: array_fill(): Argument #2 ($count) must be greater than or equal to 0
in typo3/sysext/backend/Classes/Search/LiveSearch/SearchRepository.php:131

Steps to reproduce

  1. Have at least two file storages that contain a file with the same identifier, e.g. /.DS_Store or /logo.png in storage 1 and storage 2.
  2. Open any backend module and search for a term that matches such files in the live search (e.g. a folder name that is part of the identifier).
  3. The search request responds with an exception instead of results.

Cause

Two independent problems add up:

  • FileSearchQuery::createCountForSearchDemand() counts COUNT(DISTINCT sys_file.identifier), while createForSearchDemand() returns SELECT DISTINCT identifier, sys_file.*, i.e. one row per file. The same identifier in several storages is counted once but found multiple times. The count is therefore lower than the number of found items. The same count is used by FileSearchResult (file list search).
  • SearchRepository::find() builds the paginator stubs with array_fill(0, $totalCount - $offset - $resultCount, null) and does not expect a provider to count less than it returns. A negative length throws a ValueError.

Proposed solution

  • Count files by sys_file.uid so that the count matches the rows returned by the search query.
  • Make SearchRepository::find() robust against providers whose count is lower than their result, by never passing a negative length to array_fill().

Reviews 2

History 13

  1. Georg Ringer commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-10-17T12:35:16+00:00" > 10/17/26, 12:35 </span>

    Applied in changeset commit:509c393b84619a4f4d7f90cef02cc973af616646.