Issue Bug Closed

#107820ResourceCompressor does not handle false return value from GeneralUtility::getUrl() when fetching external resources

Patrick Gaumond 10/23/25, 19:19 updated 12/02/25, 12:04

Description

When the TYPO3 Core’s ResourceCompressor retrieves external resources (for example, remote JavaScript or CSS files), it calls
GeneralUtility::getUrl($url) to fetch their content.
However, getUrl() can return false if the request fails (for example, due to a timeout, 404 response, or network issue).

Currently, ResourceCompressor::retrieveExternalFile() does not check whether $externalContent is a boolean before attempting to compute MD5 hashes and write the file to disk.
This can lead to PHP warnings such as:

md5() expects parameter 1 to be string, bool given

or to the creation of an invalid (empty) cache file.

Steps to Reproduce:

  • Configure TYPO3 to include an external resource (for instance, a CSS file hosted on an unreachable URL).
  • Clear the TYPO3 cache to force re-generation of compressed resources.
  • Observe the PHP error log or TYPO3 logs.

Expected behavior:
TYPO3 should detect that the resource could not be fetched and handle the error gracefully (log a warning, skip writing the file).

Actual behavior:
The Core tries to compute md5($externalContent) even when $externalContent is false, leading to PHP warnings and possibly empty or corrupted cache files.

Reviews 1