Page MenuHomePhabricator

Styles for a skin added with $out->addStyle() are loaded after instead of before user custom styles.
Closed, ResolvedPublic

Description

The following in a custom skin worked in older versions of MediaWiki, but
in the current trunk it's loaded after the user css

function setupSkinUserCss( OutputPage $out ) {

 parent::setupSkinUserCss( $out );
$out->addStyle( 'luontoliitto/main.css', 'screen' );

}

<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="/w/load.php?debug=true&amp;lang=fi&amp;modules=site&amp;only=styles&amp;skin=luontoliitto&amp;version=20110103T210326Z">
<link rel="stylesheet" href="/w/load.php?debug=true&amp;lang=fi&amp;modules=user&amp;only=styles&amp;skin=luontoliitto&amp;user=Krinkle&amp;version=20110103T210140Z">
<link rel="stylesheet" href="/w/skins/luontoliitto/main.css?301" media="screen">


Version: 1.17.x
Severity: major

Details

Reference
bz26555

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:24 PM
bzimport set Reference to bz26555.

I _think_ the problem is caused by OutputPage::headElement() doing

$ret .= implode( "\n", array(

		$this->getHeadLinks( $sk ),
		$this->buildCssLinks(),
		$this->getHeadItems(),

) );

Here, ResourceLoader is adding its style links in getHeadLinks(), while style links added via addStyle() are output in buildCssLinks(). To fix this issue, either a) the ResourceLoader code could be pulled out of getHeadLinks() into a separate method, b) the call to buildCssLinks() could be moved before getHeadLinks(), or c) the call to buildCssLinks() could be moved _inside_ getHeadLinks(). Not being very familiar with ResourceLoader, I have no idea which of these would be the cleanest solution, or the least likely to cause unexpected side effects.

(In reply to comment #1)

Here, ResourceLoader is adding its style links in getHeadLinks(), while style
links added via addStyle() are output in buildCssLinks(). To fix this issue,
either a) the ResourceLoader code could be pulled out of getHeadLinks() into a
separate method, b) the call to buildCssLinks() could be moved before
getHeadLinks(), or c) the call to buildCssLinks() could be moved _inside_
getHeadLinks(). Not being very familiar with ResourceLoader, I have no idea
which of these would be the cleanest solution, or the least likely to cause
unexpected side effects.

Trevor tried to move the RL stuff into buildCssLinks() but that didn't work too well. I'll poke at this later.

  • Bug 26570 has been marked as a duplicate of this bug. ***