Review main Merged

95328[BUGFIX] Skip inaccessible file references in FileCollector

Georg Ringer CR +2 V +2 Easy +11 −1 updated 09/01/26, 20:04

Commit message

FileCollector::addFileReferences() handed each uid to
ResourceFactory::getFileReferenceObject(), which throws when the
sys_file_reference record cannot be fetched. In the frontend the record
is looked up through PageRepository::checkRecord(), so a hidden
reference yields no data and the exception took down the whole page
render for every visitor.

Hidden references are inaccessible to the frontend by design, so they
are skipped now, just like the relation based lookup in the same class
already skips references whose file has gone missing.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Wouter Wolters +1
    • Benni Mack +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Wouter Wolters +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1114

  1. Georg Ringer uploaded patch set 1 08/14/26, 07:23

  2. Georg Ringer commented on patch set 1 08/14/26, 07:23

    This change is ready for review.
  3. core-ci voted on patch set 1 V +1 08/14/26, 07:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106693

  4. Stefan Bürk voted on patch set 1 CR +1 V +1 08/14/26, 15:57

  5. Wouter Wolters voted on patch set 1 CR +1 V +1 08/14/26, 16:03

  6. Stefan Bürk commented on patch set 1 08/15/26, 18:07

    Unresolved

    The analysis in #109710 is spot on and I can follow the whole chain in the code: FILES.references / FilesProcessor.references receive a raw, unfiltered list of sys_file_reference uids (levelmedia is just the media DB field value), and ResourceFactory::getFileReferenceData() resolves them via PageRepository::checkRecord(), which applies the FrontendRestrictionContainer - and sys_file_reference has enablecolumns.disabled = hidden. So a hidden relation reliably kills the page. Skipping is the right answer and matches what FileRepository::findByRelation() has been doing for the relation-based path all along. I also checked the remaining getFileReferenceObject() callers: ContentObjectRenderer::setState(), getImgResource() and the ImageViewHelpers via resolveFileObject() are all guarded already, so this was the last unguarded frontend path. The catch is narrow and I see no effect on the collector's counts, sorting or limits. Three things I would like to see before a +2: 1. Test. There is no FileCollector test at all today. The natural place is FilesContentObjectTest plus DataSet/FilesContentObjectDataSet.csv (add a hidden column and a hidden reference row). Careful though: a test added there would be false-green. getFileReferenceData() branches on $GLOBALS['TYPO3_REQUEST'], which the functional test base does not set, so it takes the raw else branch (DeletedRestriction only) and never throws - the data set would pass with and without this patch. The test needs ->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE) on $GLOBALS['TYPO3_REQUEST'] (as in ContentObjectRendererTest) or a real executeFrontendSubRequest(). Since the patch turns a hard error into silently missing output, I think the regression test is worth the effort. 2. Logging or at least a comment. FileCollector logs in addFiles(), addFilesFromFileCollection(), addFilesFromFolder() and getFileReferences(); this new catch is the only place that drops a file with no trace and no comment. Note it also swallows FileDoesNotExistException (a subclass) for a sys_file row that no longer exists - a genuine inconsistency, not an editorial state. A logger->debug() (not warning, hidden references are legitimate and would spam) plus a short "why" comment would make this supportable. 3. The commit message says the change mirrors "the relation based lookup in the same class". getFileReferences() is actually more defensive: it also catches \InvalidArgumentException for a removed storage and logs it as error. On this path a removed storage still throws \InvalidArgumentException (1599235454, StorageRepository::findByUid()) and still takes the page down - fluid/ImageViewHelper catches exactly that case with the comment "thrown if file storage does not exist", so it is reachable. Either widen the catch accordingly or soften the wording in the message. Nothing blocking, the fix itself is correct and the release targets (main, 14.3, 13.4) are right - 14.3 is a byte-identical cherry-pick, 13.4 just keeps its now-dead instanceof guard. Keeping my +1; happy to go +2 once there is a test that actually fails without the patch.
  7. Georg Ringer uploaded patch set 2 CR +1 V +1 08/16/26, 08:57

  8. core-ci voted on patch set 2 V +1 08/16/26, 09:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106783

  9. Georg Ringer rebased onto patch set 3 V +1 08/27/26, 15:55

  10. core-ci voted on patch set 3 V +1 08/27/26, 16:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107279

  11. Benni Mack voted on patch set 3 CR +1 V +1 09/01/26, 17:05

  12. Wouter Wolters voted on patch set 3 CR +1 V +1 09/01/26, 19:05

  13. Georg Ringer voted on patch set 3 CR +2 V +2 09/01/26, 19:51

  14. Georg Ringer merged patch set 4 09/01/26, 20:04