Page MenuHomeMiraheze

[Bug] TemplateStyles not enforcing sanitized-css content model across wikis
Closed, ResolvedPublic

Description

Steps to reproduce bug

  • Have the TemplateStyles extension installed on any wiki.
  • Attempt to create a Template namespace subpage ending in .css or import any such page from Wikipedia.

Expected result

  • The CodeEditor (if installed) should be loaded instead of the regular wikitext editor when trying to create page, and the created page should be assigned the sanitized-css content model.
  • The imported page should retain its sanitized-css content model.

Observed result

  • Both of the above results in the wikitext content model being assigned. The issue persisted before and after Miraheze's database issue, likely unrelated.

Links to Discord discussions


Priority set to High as this is a very common feature across wikis (many wikis are likely to have imported basic templates from Wikimedia wikis, which a lot of them utilizes TemplateStyles. Tagging Configuration and ManageWiki to check if it could be caused by unintended configurations set by Special:ManageWiki/namespaces.

Event Timeline

LuciferianThomas created this task.
Agent_Isai lowered the priority of this task from High to Normal.Jan 27 2023, 03:53
Agent_Isai edited projects, added Extensions; removed ManageWiki, Configuration.

@LuciferianThomas Are you sure that this isn't related to the issues caused by the hkrail resets? have you seen it on any other wikis?

It happens miraheze-wide actually. Although I can't vouch for that but, I'm sure of my wikis and many other wikis I've tried it on.

Unknown Object (User) added a comment.Jan 31 2023, 17:04

I'm also aware this is a valid Miraheze issue, that has happened for a very long time. My guess is some conflict with ManageWiki but I was never certain. I also never looked to in-depth either. But it is worth an investigation.

While on T10173: Handling of hkrail.miraheze.org after database recovering and T10384: Resetting hkrail.miraheze.org, I noticed that imports (especially when done from the backend) consistently does not want to import correctly with sanitized-css. In T10384, we ran into content model issues like last time, which we managed to mostly fix by manually mapping the content models upon wiki reset. I have however noticed that even with TemplateStyles and other extensions adding content models installed on the wiki, there seems that sanitized-css was not added into the content models data table. I feel like this might be related to what exactly happened here, and I believe there wouldn't be a separate content models table for extensions (seeing that Scribunto is listed separately in the MediaWiki documentation on content handlers but works together with the main table), so this could be the cause of what causes this bug.

Reception123 claimed this task.

Should now be fixed following the re-resetting of the wiki around a month ago. Please feel free to reopen if that is not the case.

Oh, I missed the email. It's not about specifically my wiki, but when creating .css subpages in the Template namespace in any wiki, the content model still remains default to wikitext instead of automatically creating as sanitized-css like the behaviour in Wikimedia wikis. Users still need to manually change content model for new pages to make them sanitized-css content model.

Herald removed a subscriber: Unknown Object (User). · View Herald TranscriptMar 26 2023, 12:43
Agent_Isai added a subscriber: Shummg.

I'm not sure why but on MediaWiki 1.40, this behavior no longer persists. I am able to create subpage /styles.css in the template namespace with the sanitized-css content model. Anyone is free to test this out on Betaheze.

Interesting findings via eval.php

On metawiki running MediaWiki 1.39:

> var_dump($wgTemplateStylesNamespaces);
array(2) {
  [0]=>
  int(10)
  [1]=>
  int(-1)
}

On metawikibeta running MediaWiki 1.40:

> var_dump($wgTemplateStylesNamespaces);
array(1) {
  [10]=>
  bool(true)
}

Interesting findings via eval.php

On metawiki running MediaWiki 1.39:

> var_dump($wgTemplateStylesNamespaces);
array(2) {
  [0]=>
  int(10)
  [1]=>
  int(-1)
}

On metawikibeta running MediaWiki 1.40:

> var_dump($wgTemplateStylesNamespaces);
array(1) {
  [10]=>
  bool(true)
}

That looks like something on the ManageWiki side is causing the configuration to be borked. The configuration for metawiki is not valid. I think this is a case of wgTemplateStylesNamespaces should be using type vestyle instead of check in ManageWikiNamespaces.php

Agent_Isai assigned this task to Void.

Void to the rescue once more. This was indeed the cause and after having changed this in ManageWikiNamespaces.php and then disabling and re-enabling this in the template namespace, it worked perfectly. If a user encounters this issue, they should disable $wgTemplateStylesNamespaces in the Template namespace (and on every other namespace they have it enabled on) and then they should re-enable it and it should work.