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 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.

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 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