#111113Live search throws ValueError when files share an identifier across storages
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
- Have at least two file storages that contain a file with the same identifier, e.g.
/.DS_Storeor/logo.pngin storage 1 and storage 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).
- The search request responds with an exception instead of results.
Cause
Two independent problems add up:
FileSearchQuery::createCountForSearchDemand()countsCOUNT(DISTINCT sys_file.identifier), whilecreateForSearchDemand()returnsSELECT 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 byFileSearchResult(file list search).SearchRepository::find()builds the paginator stubs witharray_fill(0, $totalCount - $offset - $resultCount, null)and does not expect a provider to count less than it returns. A negative length throws aValueError.
Proposed solution
- Count files by
sys_file.uidso 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 toarray_fill().
Reviews 2
History 13
-
Gerrit Code Review pushed patch set 1 for main to change 96782 status
NewUnder Review <span data-processor="relativetime" data-value="2026-10-17T11:26:36+00:00" > 10/17/26, 11:26 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 96784 <span data-processor="relativetime" data-value="2026-10-17T12:31:28+00:00" > 10/17/26, 12:31 </span>
-
Georg Ringer commented and changed status
Under ReviewResolved done0 %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.