Page MenuHomePhabricator

only original content model is recognized by TemplateStyles
Closed, InvalidPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Create a .css file outside of templatespace.
  • Call that css file from a page. You will get an error that reads something like "Content namespace of [that css file] is "CSS" but it can only be "Sanitized CSS". Make an edit request using.... and something else that i forgot"
  • Go to "Special:ChangeContentModel" and change the content model of that css file to "Sanitized CSS" and purge the cache of the page using that css file

What happens?:
Error persists, templatestyles still thinks that that page's content model is still "CSS"
What should have happened instead?: Error should've gone away and that CSS file's rules be applied to the page's contents

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia): enwiki

Other information (browser name/version, screenshots, etc.):
This can be circumvented if you create the css file in template namespace and move outside of templatespace.

Event Timeline

For what ever reason you need to null edit (https://en.wikipedia.org/wiki/Help:Purge#Null_edit) the CSS page after the content model is changed for it to pick up.

Found the logic for checking content model, it's not a problem with templatestyles.
strike that for now, might actually be an issue with templatestyles but probably not

edit: nope, it's not templatestyles' fault. see

$revRecord = $parser->fetchCurrentRevisionRecordOfTitle( $title );

from https://github.com/wikimedia/mediawiki-extensions-TemplateStyles/blob/master/includes/Hooks.php

		if ( !$content instanceof TemplateStylesContent ) {
			$titleText = $this->titleFormatter->getPrefixedText( $revRecord->getPage() );
			return Status::newFatal(
				'templatestyles-bad-src',
				$titleText,
				wfEscapeWikiText( $titleText ),
				ContentHandler::getLocalizedName( $content->getModel() )
			);
		}

from https://github.com/wikimedia/mediawiki-extensions-TemplateStyles/blob/master/includes/TemplateStylesContentProvider.php

@Pppery could you check to see if this isn't replication lag or something? Thanks in advance. (make a normal page that uses templatestyles to another page which is CSS content model, change the css's content model to sanitized, then clearing the cache of that original normal page(no null edit) 30 minutes later?)

Replication lag takes nowhere near 30 minutes (in fact it's almost always less than a second). I'm not inclined to spend more time testing.

after trying again (and searching the codebase for 4 hours) i eventually decided to replicate the bug on testwiki.wiki to no avail. (which is weird since afaik this bug actually happened. maybe testwiki.wiki has a different config from this or smth? idk)

It sounds like a race condition. Different db config (e.g. replicas), different caching setup, different job queue setup might be effecting it.