Page MenuHomePhabricator

Template updates are not handled for global config
Closed, ResolvedPublic

Description

MediaUploader registers which templates are used in campaign configs and this allows for campaign config cache invalidation every time a transcluded template is changed (through the LinksUpdate mechanism). This currently does not work for the main global config.

The best I've come up with so far:

  1. Define a new content type, let's call it MediaUploaderConfig, for a single "magic" page, maybe in a special-purpose namespace.
    1. It seems that defining an entire new content type won't be needed, we can hook into an existing one, using this hook.
    2. We probably could try to hack around and make the page impossible to delete, but I'm not sure if it will matter at all. More investigation needed.
  2. Whenever we detect a global config cache invalidation is necessary, we also enqueue a LinksUpdate for the magic page.
  3. Have the content type override getParserOutput() and similarly to CampaignContent, use the GlobalParsedConfig::getTemplates() method to register all used templates on the page in the ParserOutput object. This will cause a LinksUpdate for this page whenever any of the transcluded templates are changed.

Drawbacks: complicated and hacky. On the other hand, it mostly uses built-in mechanisms.

Event Timeline

Ostrzyciel moved this task from To Triage to In Progress on the MediaUploader board.

Change 668749 had a related patch set uploaded (by Ostrzyciel; owner: Ostrzyciel):
[mediawiki/extensions/MediaUploader@master] WIP Add anchor page for global config

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

I've decided not to make a completely new content type, but to reuse CampaignContent and the Campaign: namespace, to cut down on the amount of code required to get it working. Besides, wiki admins looking for template uses in campaigns will look for links from the Campaign NS, so anchoring the global config there makes some sense.

The global config anchor page will be Campaign:- which I doubt anyone would want to use anyway.

After... quite a few iterations, lots of manual testing and swearing, I think it finally works as intended. The following table summarizes what is going on in the three key methods for both cases (a regular campaign and the global config anchor).

MethodRegular campaignGlobal config anchorComment
CampaignContent::fillParserOutputParse the config ignoring the cache entirely, save templatelinksParse the config ignoring the cache entirely, save templatelinksWe need up-to-date templatelinks here, no matter what, so we have to ignore the cache.
CampaignHooks::onPageSaveCompleteUpdate the DB table keeping track of campaigns (deferred update)Nothing in the DB table depends on templates, we only really need the enabled field, so we can limit the DB writes to page saves.
CampaignHooks::onLinksUpdateCompleteInvalidate config cacheInvalidate config cacheLinksUpdate is performed after the campaign page or any of its dependencies is edited. The invalidation will cause all config variants (languages and genders) to be regenerated on the next read.

Change 668749 merged by jenkins-bot:
[mediawiki/extensions/MediaUploader@master] Add anchor page for global config

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

Ostrzyciel claimed this task.