Page MenuHomePhabricator

Unclear MCR replacement for WikiPage::prepareContentForEdit
Open, MediumPublic

Description

The docs of WikiPage::prepareContentForEdit say:

@deprecated since 1.32, use getDerivedDataUpdater instead

But WikiPage::getDerivedDataUpdater is private, and so has been since its introduction in r405015. What should we use as replacement?

Event Timeline

Eevans triaged this task as Medium priority.Jan 10 2020, 5:22 PM

{{ping}} This method was deprecated 3 versions ago and it still doesn't have a documented replacement.

@daniel: Any comments which public function to use instead? Thanks in advance!

Change 701074 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] WIP: introduced PreparedUpdate to replace PreparedEdit

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

This was stalled for a long time, since I was hoping to avoid WikiPage maintaining state about ongoing edits. That would however mean replacing several hooks that are fired during edits with a new version that would expose the relevant state directly. We never got around to scheduling that effort.

My proposal for now is to continue the pattern set by PreparedEdit and WikiPage::prepareContentFor edit, by introducing PreparedUpdate and WikiPage::prepareUpdate(). The PreparedUpdate interface seems find for the future. Access to WikiPage::prepareUpdate() should eventually become unnecessary when we have better hooks.

I made a WIP patch to explore the idea. Comments on the approach I took are very welcome.

Pinging @Addshore since we discussed this in the context of Wikibase recently, in particular the need to defer rendering until after the response has been sent.

Besides AbuseFilter, other extensions affected are TemplateData, SpamBlacklist, MediaWiki-extensions-FlaggedRevs, and ConfirmEdit (CAPTCHA extension).

Change 705854 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/extensions/SpamBlacklist@master] Use WikiPage::getCurrentUpdate

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

I suggest reverting the changes that moved away from the (soft-deprecated) WikiPage::prepareContentForEdit method. This method is to my knowledge the only appropiate way we have for extension hooks during an edit stash or edit submit request to obtain the ParserOutput in a shared and cached way.

Please comment at T288639 if you disagree. Copying here for awareness.

The prepareContentForEdit signature is very close to what the new proposed thing looks like. And re-adopting that first will be an easy way to re-centralise the call structure, as well as to validate out hypothesis with regards to save timing regression.

Ideally, extensions would get a PreparedUpdate as a hook parameter. Until we have that, we can expose the "current" PreparedUpdate via a service. This is better than relying on a WikiPage instance coming from RequestContext (especially since we want to kill RequestContext::getWikiPage).

Change 705854 abandoned by Daniel Kinzler:

[mediawiki/extensions/SpamBlacklist@master] Use WikiPage::getCurrentUpdate

Reason:

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

Change 701074 merged by jenkins-bot:

[mediawiki/core@master] Introduced PreparedUpdate to replace PreparedEdit

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