From 01c9271823a3b4151f22f76f4aa99c011c1268db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20K=C3=A4hm?= Date: Thu, 26 Mar 2026 17:29:45 +0000 Subject: [PATCH] [BUGFIX] Use absolute paths for SCSS cache file existence checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The isCached() and needsCompile() methods use relative paths (e.g. "typo3temp/assets/bootstrappackage/css/...") for file_exists() and filemtime() calls. These relative paths are resolved against the current working directory (CWD). In web request context, the CWD is typically the document root (public/), so the relative paths resolve correctly. However, in CLI context (e.g. TYPO3 scheduler tasks, cache warmup scripts), the CWD is the project root — one level above public/. This causes file_exists() to always return false, forcing a full SCSS recompilation on every request even when a valid cache file exists. This is particularly impactful for extensions that trigger internal sub-requests via Application::handle() (e.g. Apache Solr indexing), where SCSS compilation runs multiple times per CLI invocation, adding ~80 seconds per compilation. The fix resolves cache file paths to absolute paths using GeneralUtility::getFileAbsFileName() before performing filesystem checks, consistent with how ScssParser::compile() already resolves paths when writing cache files. --- Classes/Parser/AbstractParser.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Classes/Parser/AbstractParser.php b/Classes/Parser/AbstractParser.php index 0228ffd46..e8edd7230 100644 --- a/Classes/Parser/AbstractParser.php +++ b/Classes/Parser/AbstractParser.php @@ -47,8 +47,10 @@ protected function isCached(string $file, array $settings): bool $cacheIdentifier = $this->getCacheIdentifier($file, $settings); $cacheFile = $this->getCacheFile($cacheIdentifier, $settings['cache']['tempDirectory']); $cacheFileMeta = $this->getCacheFileMeta($cacheFile); + $absoluteCacheFile = GeneralUtility::getFileAbsFileName($cacheFile); + $absoluteCacheFileMeta = GeneralUtility::getFileAbsFileName($cacheFileMeta); - return file_exists($cacheFile) && file_exists($cacheFileMeta); + return file_exists($absoluteCacheFile) && file_exists($absoluteCacheFileMeta); } /** @@ -59,9 +61,10 @@ protected function isCached(string $file, array $settings): bool */ protected function needsCompile(string $cacheFile, string $cacheFileMeta, array $settings): bool { - $needCompilation = false; - $fileModificationTime = filemtime($cacheFile); - $metadata = unserialize((string) file_get_contents($cacheFileMeta), ['allowed_classes' => false]); + $absoluteCacheFile = GeneralUtility::getFileAbsFileName($cacheFile); + $absoluteCacheFileMeta = GeneralUtility::getFileAbsFileName($cacheFileMeta); + $fileModificationTime = filemtime($absoluteCacheFile); + $metadata = unserialize((string) file_get_contents($absoluteCacheFileMeta), ['allowed_classes' => false]); if (is_array($metadata) && is_array($metadata['files'])) { foreach ($metadata['files'] as $file) {