Commit f360dc89 authored by Benni Mack's avatar Benni Mack Committed by Oliver Bartsch
Browse files

[TASK] Deprecate page.includeCSS/includeCSSLibs.my-identifier.import

The option to use the `@import` syntax for including
external CSS files through TypoScript has been deprecated.

This was possible through:

page = PAGE
page.includeCSSLibs.file1 = fileadmin/benni.css
page.includeCSSLibs.file1.import = 1

Through the "import = 1" option the output was

<style>
 @import url('fileadmin/benni.css');
</style>

instead of using the <link> tag.

Using the link tag, which is the de-facto syntax these days,
allows to load a file directly when interpreting the HTML of the
browser, instead of first interpreting the HTML, then the CSS
and have a blocking call to an external URL to continue interpreting
the CSS.

Resolves: #95349
Releases: master
Change-Id: I05071d800fb938af00695005081bfbfaeb4ecee5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71231

Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent f86a3e1c
.. include:: ../../Includes.txt
=======================================================================
Deprecation: #95349 - TypoScript: page.includeCSS/includeCSSLibs.import
=======================================================================
See :issue:`95349`
Description
===========
The option to use the `@import` syntax for including
external CSS files through TypoScript has been deprecated.
This was possible through:
page = PAGE
page.includeCSSLibs.file1 = fileadmin/benni.css
page.includeCSSLibs.file1.import = 1
Through the "import = 1" option the output was
<style>
@import url('fileadmin/benni.css');
</style>
Impact
======
A PHP deprecation warning is triggered when having the :typoscript:`import = 1`
flag enabled in TypoScript on :typoscript:`includeCSS` or :typoscript:`includeCSSLibs`
properties.
Affected Installations
======================
TYPO3 installation with the TypoScript settings:
:typoscript:`page.includeCSS.aFile.import = 1`
:typoscript:`page.includeCSSLibs.aFile.import = 1`
enabled.
Migration
=========
Using the :html:`<link>` tag syntax, which is the de-facto syntax these days,
allows to load a file directly when interpreting the HTML of the
browser, instead of first interpreting the HTML, then the CSS
and have a blocking call to an external URL to continue interpreting the CSS.
It is recommended to use the :html:`<link>` tag or create a inlineCSS TypoScript
manually to load such a file with the :css:`@import` syntax.
.. index:: TypoScript, NotScanned, ext:frontend
......@@ -437,10 +437,12 @@ class RequestHandler implements RequestHandlerInterface
}
if ($ss) {
if ($cssFileConfig['import'] ?? false) {
// @deprecated will be removed in TYPO3 v12.0.
if (!($cssFileConfig['external'] ?? false) && $ss[0] !== '/') {
// To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
$ss = GeneralUtility::dirname(GeneralUtility::getIndpEnv('SCRIPT_NAME')) . '/' . $ss;
}
trigger_error('Using @import via "page.includeCSS.my-identifier.import = 1" within TypoScript will be removed in TYPO3 v12.0.', E_USER_DEPRECATED);
$cssMedia = !empty($cssFileConfig['media']) ? ' ' . htmlspecialchars($cssFileConfig['media']) : '';
$pageRenderer->addCssInlineBlock('import_' . $key, '@import url("' . htmlspecialchars($ss) . '")' . $cssMedia . ';', empty($cssFileConfig['disableCompression']), (bool)($cssFileConfig['forceOnTop'] ?? false));
} else {
......@@ -480,10 +482,12 @@ class RequestHandler implements RequestHandlerInterface
}
if ($ss) {
if ($cssFileConfig['import'] ?? false) {
// @deprecated will be removed in TYPO3 v12.0.
if (!($cssFileConfig['external'] ?? false) && $ss[0] !== '/') {
// To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
$ss = GeneralUtility::dirname(GeneralUtility::getIndpEnv('SCRIPT_NAME')) . '/' . $ss;
}
trigger_error('Using @import via "page.includeCSSLibs.my-identifier.import = 1" within TypoScript will be removed in TYPO3 v12.0.', E_USER_DEPRECATED);
$cssMedia = !empty($cssFileConfig['media']) ? ' ' . htmlspecialchars($cssFileConfig['media']) : '';
$pageRenderer->addCssInlineBlock('import_' . $key, '@import url("' . htmlspecialchars($ss) . '")' . $cssMedia . ';', empty($cssFileConfig['disableCompression']), (bool)($cssFileConfig['forceOnTop'] ?? false));
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment