Bug #84261
closedPageRenderer Includes and config.compress/concatenate CSS/JS does not work
100%
Description
When including JS and CSS files using the Pagerenderer in some Extbase actions the config.compress/concatenate function will break with a WARNING.
Example include in an Extbase Controller Action:
$pageRenderer = $this->objectManager->get(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->addJsFooterFile('EXT:myext/Resources/Public/Javascripts/my.js');
Then enable the compression in the Typoscript configuration and you will get this warning:
file_get_contents(/home/www/p123456789/html/typo3conf/ext/myext/Resources/Public/Javascripts/my.js): failed to open stream
The path is stripping a path segment to the TYPO3_path it should be this instead:
/home/www/p123456789/html/*TYPO3*/typo3conf/ext/myext/Resources/Public/Javascripts/my.js
Somehow, files that are included using the PageRenderer will be delivered relative to the RessourceCompressor like:
"../typo3conf/ext/myext/Resources/Public/Javascripts/my.js"
Line 284 of RessourceCompressor will then strip it away and remove the /typo3/-part of the path in this line:
$filenameAbsolute = GeneralUtility::resolveBackPath($this->rootPath . $filename);
Updated by Paul Beck almost 7 years ago
Addition: The error only occurs when including files prefixed with EXT: because the file then will be resolved relative on Line 462 of RessourceCompressor:
// build the file path relatively to the PATH_site
if (strpos($filename, 'EXT:') === 0) {
$file = GeneralUtility::getFileAbsFileName($filename);
}
Including files with addJsFooterFile('/typo3conf/ext/myext/...') works perfectly.
It should be absolute here instead. Seems to be fixed when getting the absolute path after that:
// build the file path relatively to the PATH_site
if (strpos($filename, 'EXT:') === 0) {
$file = GeneralUtility::getFileAbsFileName($filename);
$file = GeneralUtility::resolveBackPath(PATH_typo3 . $file);
}
Updated by Stefan Froemken almost 7 years ago
- Category set to Frontend
- Status changed from New to Accepted
- Target version set to next-patchlevel
I can confirm this bug. In getFilenameFromMainDir() the Path with EXT: will be converted to an absolute path and than this spart will be executed:
// check if the file exists, and if so, return the path relative to TYPO3_mainDir if (is_file($file)) { $mainDirDepth = substr_count(TYPO3_mainDir, '/'); return str_repeat('../', $mainDirDepth) . str_replace(PATH_site, '', $file); }
I think that this part would be Ok for TYPO3 BE rendering, but will fail in case of FE.
Maybe this part has to be refactored for FE usage.
Stefan
Updated by Gerrit Code Review almost 7 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Gerrit Code Review over 6 years ago
Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/56803
Updated by Anonymous over 6 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 62de88be908950845962431843053060ecc5d3d7.
Updated by Gerrit Code Review over 6 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57386
Updated by Gerrit Code Review over 6 years ago
Patch set 2 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57386
Updated by Anonymous over 6 years ago
- Status changed from Under Review to Resolved
Applied in changeset 7ccb4a5677057fc7a3ac81fdad6ad227f5a65e26.