Bug #82636

concatenation changes include order of CSS files, breaks CSS.

Added by Leonie Philine Bitto almost 2 years ago. Updated 25 days ago.

Status:
New
Priority:
Must have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2017-10-02
Due date:
% Done:

0%

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

Description

I have some cssInline, which is automatically externalized into a css file (via config.removeDefaultJS = external).
And I have some CSS files, included via default page.includeCSS.

In the source code, they show up like:

<link rel="stylesheet" type="text/css" href="/fileadmin/site/framework/css/bootstrap.min.css?1506943541" media="all">
<link rel="stylesheet" type="text/css" href="/fileadmin/site/framework/css/main.css?1506943541" media="all">
<link rel="stylesheet" type="text/css" href="/fileadmin/site/framework/css/additions.css?1506943541" media="all">
<link rel="stylesheet" type="text/css" href="/fileadmin/site/framework-nc/css/main.css?1506694395" media="all">
<link rel="stylesheet" type="text/css" href="https://somedomain.tld/css/main.css" media="all">
<link rel="stylesheet" type="text/css" href="/typo3temp/assets/css/436ba33024.css?1506927672" media="all">

You see the externalized one at the bottom.
The externalized one is automatically "excludeFromConcatenation", because that's how things are done in \TYPO3\CMS\Frontend\Page\PageGenerator::addCssToPageRenderer() when called from \TYPO3\CMS\Frontend\Page\PageGenerator::renderContentWithHeader():

self::addCssToPageRenderer($cssPageStyle, true, 'InlinePageCss');

Now when concatenating the other files, suddenly this external file (page.cssInline) which is used to override some CSS of the above files, appears at the TOP of the list. Why?
Because this does not work in \TYPO3\CMS\Core\Resource\ResourceCompressor::concatenateCssFiles():

// place the merged stylesheet on top of the stylesheets
$cssFiles = array_merge($cssFiles, [$targetFile => $concatenatedOptions]);

At this point, $cssFiles is this:

Array
(
    [typo3temp/assets/css/edc1a6c625.css] => Array
        (
            [file] => typo3temp/assets/css/edc1a6c625.css
            [rel] => stylesheet
            [media] => all
            [title] => 
            [compress] => 
            [forceOnTop] => 
            [allWrap] => 
            [excludeFromConcatenation] => 1
            [splitChar] => |
        )

)

And [$targetFile => $concatenatedOptions] is this:

Array
(
    [typo3temp/assets/compressed/merged-9e3a4540615f81c720077bca7cad010d.css] => Array
        (
            [file] => typo3temp/assets/compressed/merged-9e3a4540615f81c720077bca7cad010d.css
            [rel] => stylesheet
            [media] => all
            [compress] => 1
            [excludeFromConcatenation] => 1
            [forceOnTop] => 
            [allWrap] => 
        )

)

after the $cssFiles = array_merge($cssFiles, [$targetFile => $concatenatedOptions]), you get this:

Array
(
    [typo3temp/assets/css/edc1a6c625.css] => Array
        (
            [file] => typo3temp/assets/css/edc1a6c625.css
            [rel] => stylesheet
            [media] => all
            [title] => 
            [compress] => 
            [forceOnTop] => 
            [allWrap] => 
            [excludeFromConcatenation] => 1
            [splitChar] => |
        )

    [typo3temp/assets/compressed/merged-9e3a4540615f81c720077bca7cad010d.css] => Array
        (
            [file] => typo3temp/assets/compressed/merged-9e3a4540615f81c720077bca7cad010d.css
            [rel] => stylesheet
            [media] => all
            [compress] => 1
            [excludeFromConcatenation] => 1
            [forceOnTop] => 
            [allWrap] => 
        )

)

So, now the concatenated file is below the page.cssInline file - the previous include order is not preserved.

Therefore, array_merge() is not the right method here - or the array_merge() parameters need to be exchanged.
The comment line above the array_merge() even says:

 // place the merged stylesheet on top of the stylesheets

But that's not happening - it is placed below the stylesheets, not no top.

Could it be that this is a regression?

History

#1 Updated by Susanne Moog almost 2 years ago

  • Category set to Frontend

#2 Updated by Julian Hofmann about 1 year ago

Maybe a workaround: includeCSSLibs stay on top of the CSS includes.

#3 Updated by Wolfgang Wagner 25 days ago

  • TYPO3 Version changed from 8 to 9
  • PHP Version changed from 7.1 to 7.2

Bug still exists in TYPO3 9.5.8

#4 Updated by Wolfgang Wagner 25 days ago

  • TYPO3 Version changed from 9 to 8
  • PHP Version changed from 7.2 to 7.1

Ups, sorry, accidently changed TYPO3 and PHP-Version...

Also available in: Atom PDF