Project

General

Profile

Actions

Bug #84261

closed

PageRenderer Includes and config.compress/concatenate CSS/JS does not work

Added by Paul Beck about 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Frontend
Target version:
Start date:
2018-03-14
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

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);
Actions #1

Updated by Paul Beck about 6 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);
        }
Actions #2

Updated by Stefan Froemken about 6 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

Actions #3

Updated by Gerrit Code Review about 6 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

Actions #4

Updated by Gerrit Code Review almost 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

Actions #5

Updated by Gerrit Code Review almost 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

Actions #6

Updated by Gerrit Code Review almost 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

Actions #7

Updated by Gerrit Code Review almost 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

Actions #8

Updated by Gerrit Code Review almost 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

Actions #9

Updated by Gerrit Code Review almost 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

Actions #10

Updated by Gerrit Code Review almost 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

Actions #11

Updated by Gerrit Code Review almost 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

Actions #12

Updated by Gerrit Code Review almost 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

Actions #13

Updated by Anonymous almost 6 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #14

Updated by Gerrit Code Review almost 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

Actions #15

Updated by Gerrit Code Review almost 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

Actions #16

Updated by Anonymous almost 6 years ago

  • Status changed from Under Review to Resolved
Actions #17

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF