Page MenuHomePhabricator

Gadgets with only styles and dependencies ignore the dependencies
Closed, ResolvedPublic

Description

Gadgets with only styles and dependencies ignore the dependencies. This is a rare but plausible usecase.

A set of gadgets on Polish Wikipedia is affected by this:

https://pl.wikipedia.org/wiki/MediaWiki:Gadgets-definition

small-sections [ResourceLoader | rights=hidden | hidden | dependencies=mediawiki.user,user.options] | small-sections.js
small-bibliography [ResourceLoader | dependencies=ext.gadget.small-sections] | small-bibliography.css
small-external-links [ResourceLoader | dependencies=ext.gadget.small-sections] | small-external-links.css

small-sections has some JavaScript to mark up sections by specific name on all pages, and the remaining gadgets provide alternative styling for those sections.

This is a regression from T42284 / https://gerrit.wikimedia.org/r/308096.

Event Timeline

matmarex created this task.Oct 8 2016, 6:50 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 8 2016, 6:50 PM
matmarex updated the task description. (Show Details)Oct 8 2016, 6:56 PM
Jdforrester-WMF triaged this task as Normal priority.Oct 8 2016, 11:11 PM
Krinkle added a comment.EditedNov 2 2016, 12:20 AM

@matmarex We can alter the "smart default" for type to default to general if the gadget has dependencies. I assume in your case it is intended that these styles will apply after the JS module (which means, they will not initial block page rendering).

Should we simply alter Gadgets_body.php#L301 to also check !$this->dependencies?

public function getType() {
	/* .. */
	if ( $this->styles && !$this->scripts ) {
		// Similar to ResourceLoaderWikiModule default
		return 'styles';
	}
	/* .. */

That would match the default of FileModule::getType.

Yes, and yes I guess.

Change 322035 had a related patch set uploaded (by Krinkle):
Default to type=general for styles-only gadgets having dependencies

https://gerrit.wikimedia.org/r/322035

matmarex closed this task as Resolved.Nov 17 2016, 3:05 PM
matmarex assigned this task to Krinkle.

Change 322035 merged by jenkins-bot:
Default to type=general for styles-only gadgets having dependencies

https://gerrit.wikimedia.org/r/322035