Issue Bug Closed

#103423Invalid array offset error in linkvalidator

Georg Großberger 03/19/24, 11:54 updated 07/09/24, 15:37

Description

In \TYPO3\CMS\Linkvalidator\Result\LinkAnalyzerResult::getLocalizedPageId the linkanalyzer tries to find the UID of a page translation, with a fallback to “0” if none is found. The fallback is implemented with

// ...
->executeQuery()
->fetchAssociative()['uid'] ?: 0;

However, the method “fetchAssociative” return a boolean “false” if no record is available in the result and the “[‘uid’]” access causes a “Trying to access array offset on false error” warning.

A possible fix is to change part of the getLocalizedPageId method to

// ...
->executeQuery()
->fetchAllAssociative()[0]['uid'] ?? 0;

Reviews 3