[BUGFIX] Use absolute paths for SCSS cache file existence checks#1621
Open
dkd-kaehm wants to merge 1 commit intobenjaminkott:masterfrom
Open
[BUGFIX] Use absolute paths for SCSS cache file existence checks#1621dkd-kaehm wants to merge 1 commit intobenjaminkott:masterfrom
dkd-kaehm wants to merge 1 commit intobenjaminkott:masterfrom
Conversation
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.
dkd-kaehm
added a commit
to dkd-kaehm/ext-solr
that referenced
this pull request
Mar 26, 2026
…onment Sub-requests via Application::handle() run in CLI context where the working directory is the project root, not the document root (public/). Third-party code relying on relative paths (e.g. BootstrapPackage SCSS cache checks using file_exists() with relative paths) fails silently, causing full SCSS recompilation on every sub-request. xHProf profiling revealed the impact: - Before fix: 331s per indexing run (94% spent in SCSS recompilation) - After fix: 10s per indexing run (95% faster) - SCSS was compiled 4x per run (once per sub-request) instead of 0x The fix adds chdir(Environment::getPublicPath()) around Application::handle() in executeSubRequest(), restoring the original CWD afterwards via try/finally. This ensures all sub-request code behaves identically to a real web request, regardless of third-party extension implementation details. With this generic fix, the legacy CliEnvironment class and the forcedWebRoot scheduler task option become obsolete and are removed: - Classes/System/Environment/CliEnvironment.php - Classes/System/Environment/WebRootAllReadyDefinedException.php - IndexQueueWorkerTask: CliEnvironment usage, forcedWebRoot property and related methods (getWebRoot, replaceWebRootMarkers) - IndexQueueWorkerTaskAdditionalFieldProvider: forcedWebRoot form field - locallang.xlf: forcedWebRoot label An integration test verifies that CWD is correctly restored after sub-request indexing and that indexing succeeds even when CWD does not match the public directory. Related: benjaminkott/bootstrap_package#1621 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dkd-kaehm
added a commit
to dkd-kaehm/ext-solr
that referenced
this pull request
Mar 30, 2026
…onment Sub-requests via Application::handle() run in CLI context where the working directory is the project root, not the document root (public/). Third-party code relying on relative paths (e.g. BootstrapPackage SCSS cache checks using file_exists() with relative paths) fails silently, causing full SCSS recompilation on every sub-request. xHProf profiling revealed the impact: - Before fix: 331s per indexing run (94% spent in SCSS recompilation) - After fix: 10s per indexing run (95% faster) - SCSS was compiled 4x per run (once per sub-request) instead of 0x The fix adds chdir(Environment::getPublicPath()) around Application::handle() in executeSubRequest(), restoring the original CWD afterwards via try/finally. This ensures all sub-request code behaves identically to a real web request, regardless of third-party extension implementation details. With this generic fix, the legacy CliEnvironment class and the forcedWebRoot scheduler task option become obsolete and are removed: - Classes/System/Environment/CliEnvironment.php - Classes/System/Environment/WebRootAllReadyDefinedException.php - IndexQueueWorkerTask: CliEnvironment usage, forcedWebRoot property and related methods (getWebRoot, replaceWebRootMarkers) - IndexQueueWorkerTaskAdditionalFieldProvider: forcedWebRoot form field - locallang.xlf: forcedWebRoot label An integration test verifies that CWD is correctly restored after sub-request indexing and that indexing succeeds even when CWD does not match the public directory. Related: benjaminkott/bootstrap_package#1621 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dkd-kaehm
added a commit
to dkd-kaehm/ext-solr
that referenced
this pull request
Mar 31, 2026
…onment Sub-requests via Application::handle() run in CLI context where the working directory is the project root, not the document root (public/). Third-party code relying on relative paths (e.g. BootstrapPackage SCSS cache checks using file_exists() with relative paths) fails silently, causing full SCSS recompilation on every sub-request. xHProf profiling revealed the impact: - Before fix: 331s per indexing run (94% spent in SCSS recompilation) - After fix: 10s per indexing run (95% faster) - SCSS was compiled 4x per run (once per sub-request) instead of 0x The fix adds chdir(Environment::getPublicPath()) around Application::handle() in executeSubRequest(), restoring the original CWD afterwards via try/finally. This ensures all sub-request code behaves identically to a real web request, regardless of third-party extension implementation details. With this generic fix, the legacy CliEnvironment class and the forcedWebRoot scheduler task option become obsolete and are removed: - Classes/System/Environment/CliEnvironment.php - Classes/System/Environment/WebRootAllReadyDefinedException.php - IndexQueueWorkerTask: CliEnvironment usage, forcedWebRoot property and related methods (getWebRoot, replaceWebRootMarkers) - IndexQueueWorkerTaskAdditionalFieldProvider: forcedWebRoot form field - locallang.xlf: forcedWebRoot label An integration test verifies that CWD is correctly restored after sub-request indexing and that indexing succeeds even when CWD does not match the public directory. Related: benjaminkott/bootstrap_package#1621 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dkd-kaehm
added a commit
to dkd-kaehm/ext-solr
that referenced
this pull request
Mar 31, 2026
…onment Sub-requests via Application::handle() run in CLI context where the working directory is the project root, not the document root (public/). Third-party code relying on relative paths (e.g. BootstrapPackage SCSS cache checks using file_exists() with relative paths) fails silently, causing full SCSS recompilation on every sub-request. xHProf profiling revealed the impact: - Before fix: 331s per indexing run (94% spent in SCSS recompilation) - After fix: 10s per indexing run (95% faster) - SCSS was compiled 4x per run (once per sub-request) instead of 0x The fix adds chdir(Environment::getPublicPath()) around Application::handle() in executeSubRequest(), restoring the original CWD afterwards via try/finally. This ensures all sub-request code behaves identically to a real web request, regardless of third-party extension implementation details. With this generic fix, the legacy CliEnvironment class and the forcedWebRoot scheduler task option become obsolete and are removed: - Classes/System/Environment/CliEnvironment.php - Classes/System/Environment/WebRootAllReadyDefinedException.php - IndexQueueWorkerTask: CliEnvironment usage, forcedWebRoot property and related methods (getWebRoot, replaceWebRootMarkers) - IndexQueueWorkerTaskAdditionalFieldProvider: forcedWebRoot form field - locallang.xlf: forcedWebRoot label An integration test verifies that CWD is correctly restored after sub-request indexing and that indexing succeeds even when CWD does not match the public directory. Related: benjaminkott/bootstrap_package#1621 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dkd-kaehm
added a commit
to TYPO3-Solr/ext-solr
that referenced
this pull request
Mar 31, 2026
…onment Sub-requests via Application::handle() run in CLI context where the working directory is the project root, not the document root (public/). Third-party code relying on relative paths (e.g. BootstrapPackage SCSS cache checks using file_exists() with relative paths) fails silently, causing full SCSS recompilation on every sub-request. xHProf profiling revealed the impact: - Before fix: 331s per indexing run (94% spent in SCSS recompilation) - After fix: 10s per indexing run (95% faster) - SCSS was compiled 4x per run (once per sub-request) instead of 0x The fix adds chdir(Environment::getPublicPath()) around Application::handle() in executeSubRequest(), restoring the original CWD afterwards via try/finally. This ensures all sub-request code behaves identically to a real web request, regardless of third-party extension implementation details. With this generic fix, the legacy CliEnvironment class and the forcedWebRoot scheduler task option become obsolete and are removed: - Classes/System/Environment/CliEnvironment.php - Classes/System/Environment/WebRootAllReadyDefinedException.php - IndexQueueWorkerTask: CliEnvironment usage, forcedWebRoot property and related methods (getWebRoot, replaceWebRootMarkers) - IndexQueueWorkerTaskAdditionalFieldProvider: forcedWebRoot form field - locallang.xlf: forcedWebRoot label An integration test verifies that CWD is correctly restored after sub-request indexing and that indexing succeeds even when CWD does not match the public directory. Related: benjaminkott/bootstrap_package#1621 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.