Bug #82486

IncludeJS* / includeCSS* (including compression / concatenation) ignoring absRefPrefix

Added by Jens Engelmann about 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2017-09-14
Due date:
% Done:

0%

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

Description

The includeJS and includeCSS functions in typoscript are ignoring the given absRefPrefix.

I tested this on a fresh installation of TYPO3 8.7.6 with the following typoscript code:

config {
  absRefPrefix = /foo/
  compressJs = 1
}

page = PAGE
page {
  10 = TEXT
  10.value = HELLO WORLD!
  # setting a link to test if absRefPrefix works
  10.typolink.parameter = 1

  includeJSLibs.js1 = fileadmin/js1.js
  includeJSLibs.js2 = fileadmin/js2.js

  includeCSS.css1 = fileadmin/css1.css
  includeCSSLibs.css1 = fileadmin/css1.css
}

This gives me the following html output on the generated page:

<link rel="stylesheet" type="text/css" href="/fileadmin/css1.css?1505384618" media="all">
<link rel="stylesheet" type="text/css" href="/fileadmin/css1.css?1505384618" media="all">
<script src="/typo3temp/assets/compressed/js1-5130fdbc94c8b9e6f1802cab56df2b78.js?1505384940" type="text/javascript"></script>
<script src="/typo3temp/assets/compressed/js2-2a2ef88a17be994adbe3c851da68f8fe.js?1505384940" type="text/javascript"></script>

The sources do get a prefix - but it's "/" instead of the declared absRefPrefix "/foo/".

The test link on the other hand is generated correctly:

<a href="/foo/index.php?id=1">HELLO WORLD!</a>


Related issues

Related to TYPO3 Core - Bug #77722: absRefPrefix is not applied everywhere New 2016-08-31
Duplicates TYPO3 Core - Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9 Closed 2018-01-21

History

#1 Updated by DANIEL Rémy almost 2 years ago

  • Related to Bug #77722: absRefPrefix is not applied everywhere added

#2 Updated by Klaus Moser over 1 year ago

Same issue here. I think this is caused by TYPO3\CMS\Core\Utility\PathUtility:getAbsoluteWebPath().
The method makes a path absolute by adding GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') and ignores the configured absRefPrefix.

I don't know if there is a better way to get the configured absRefPrefix, but this could fix the issue:

if (isset($GLOBALS['TSFE']->config['config']['absRefPrefix']) && !empty($GLOBALS['TSFE']->config['config']['absRefPrefix'])) {
    $targetPath = rtrim($GLOBALS['TSFE']->config['config']['absRefPrefix'], '/') . '/' . $targetPath;
} else {
    $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
}

#3 Updated by Adrien Jacob over 1 year ago

Thanks a lot for the suggested fix, it did the job for me...

#4 Updated by Riccardo De Contardi over 1 year ago

  • Related to Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9 added

#5 Updated by Markus Klein over 1 year ago

  • Duplicates Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9 added

#6 Updated by Markus Klein over 1 year ago

  • Related to deleted (Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9)

#7 Updated by Markus Klein over 1 year ago

  • Status changed from New to Closed

Closing this as duplicate.

Also available in: Atom PDF