Page MenuHomePhabricator

File page edit preview does not load Filepage.css
Closed, ResolvedPublic

Description

To reduce the number of rows in Commons’ templatelinks table, we moved some styles from Module:Information/styles.css to MediaWiki:Filepage.css. (See the module talk page and the styles talk page for more information.) However, it turns out that MediaWiki:Filepage.css isn’t loaded when previewing edits to file pages (when not using VisualEditor), so the Information tables currently have broken styles there – example:

image.png (1×3 px, 875 KB)

(It’s worth noting that it looks fine in VisualEditor:)
image.png (900×3 px, 199 KB)

IMHO we should fix this by making MediaWiki load Filepage.css when previewing file edits.

Event Timeline

Change 995322 had a related patch set uploaded (by Lucas Werkmeister; author: Lucas Werkmeister):

[mediawiki/core@master] Load Filepage.css when previewing File pages

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

Change 995322 merged by jenkins-bot:

[mediawiki/core@master] Load Filepage.css when previewing File pages

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

Change 997779 had a related patch set uploaded (by Lucas Werkmeister; author: Lucas Werkmeister):

[mediawiki/core@wmf/1.42.0-wmf.16] Load Filepage.css when previewing File pages

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

Change 997779 merged by jenkins-bot:

[mediawiki/core@wmf/1.42.0-wmf.16] Load Filepage.css when previewing File pages

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

Mentioned in SAL (#wikimedia-operations) [2024-02-06T14:33:23Z] <logmsgbot> lucaswerkmeister-wmde@deploy2002 Started scap: Backport for [[gerrit:997779|Load Filepage.css when previewing File pages (T356505)]]

Mentioned in SAL (#wikimedia-operations) [2024-02-06T14:36:52Z] <logmsgbot> lucaswerkmeister-wmde@deploy2002 lucaswerkmeister-wmde and lucaswerkmeister: Backport for [[gerrit:997779|Load Filepage.css when previewing File pages (T356505)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-02-06T14:44:14Z] <logmsgbot> lucaswerkmeister-wmde@deploy2002 Finished scap: Backport for [[gerrit:997779|Load Filepage.css when previewing File pages (T356505)]] (duration: 10m 51s)

LucasWerkmeister claimed this task.

The fix seems to work fine in production as far as I can tell.

There are two other previews where this is still broken.

  1. Ajax preview in MediaWiki core (Preferences > Editing > Preview without reloading the page)
  2. Preview tab in the WikiEditor toolbar.

Screenshot 2024-02-06 at 19.15.57.png (992×2 px, 260 KB)

Screenshot 2024-02-06 at 19.14.53.png (1×2 px, 512 KB)

I suggest moving the filepage module styles loading away from ImagePage.php/EditPage.php to Skin::getDefaultModules. It seems like a good for the 'core' array there.

From a quick code search, it seems no other content-related modules are loaded from WikiPage subclasses (i.e. ImagePage, CategoryPage), we always do that from OutputPage/Skin instead. The subclasses instead deal only with the interface that is rendered around or atop the content when such page is viewed, which is why it is missing during edit/submit actions. This makes sense in that the interfaces that those modules are generally for are also not rendered during edit/submit actions, but the "filepage" module, as we learn from this task, is related to the content, not the interface (from a MediaWiki core POV anyway). Thus rather than duplicating the logic into EditPage, it might make more sense in Skin::getDefaultModules!

This is essentially the core equivalent of the onBeforePageDisplay hook (which is where where extensions load page/namespace-specific styles, and does naturally apply to view and edit actions alike, avoiding this bug). Indeed OutputPage.php in core runs that hook right after loadSkinModules().

Sounds fair enough – I’m not very familiar with how responsibilities are distributed between Skin, WikiPage, and other core classes, but if Skin::getDefaultModules() is allowed to vary by title ($this->getRelevantTitle(), I guess?), then that seems fine.

Yeah, or $this->getTitle(). If one views a special page in relation to a File page, are the content styles needed there? Either way is fine.

Change 998534 had a related patch set uploaded (by Lucas Werkmeister; author: Lucas Werkmeister):

[mediawiki/core@master] Move filepage styles to Skin::getDefaultModules()

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

If one views a special page in relation to a File page, are the content styles needed there?

Probably not, I just didn’t realize $this->getTitle()` was also available.¹ I hope I understood your suggestion correctly – it fixes the Ajax preview, at least (I don’t have WikiEditor set up so I didn’t test that).

¹ (I haven’t bothered to set up IntelliJ or another IDE on my non-work system yet, so if I sound stupider than @Lucas_Werkmeister_WMDE, it’s because I’m using plain Emacs :P)

Change 998534 merged by jenkins-bot:

[mediawiki/core@master] Move filepage styles to Skin::getDefaultModules()

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

matmarex added a project: MediaWiki-General.
matmarex subscribed.