Page MenuHomePhabricator

Revision::getPrevious() returns null within onNewRevisionFromEditComplete hook
Open, LowPublic

Description

This ticket is to document the anomaly that caused T223828

Sometime in early May 2019, Revision::getPrevious() started returning null within the onNewRevisionFromEditComplete, even if a previous revision exists. This broke functionality in PageTriage. I have not confirmed this behaviour elsewhere in MediaWiki, but we were able to deduce nothing in PageTriage was the culprit.

Outside this context, Revision::getPrevious() works as expected. It seems to only be within onNewRevisionFromEditComplete. Changing the Core code to use READ_LATEST still does not resolve this issue, so I don't believe it is any sort of race condition.

A search shows the onNewRevisionFromEditComplete hook is not used many places and, for deployed WMF extensions, none are also using Revision::getPrevious(). Instead some (e.g. Wikibase) are using Revision::newFromId( $parentId ) to get the previous revision. Using this tactic worked for PageTriage, so we went with that.

The suspect patch I found was https://gerrit.wikimedia.org/r/c/mediawiki/core/+/507028 but even reverting it did not resolve the problem for me. I reverted back MediaWiki, and PageTriage, as far as I could (until I hit db changes), and I was still getting null for Revision::getPrevious(). So, the issue is truly a mystery!

Event Timeline

@daniel Adding you as a subscriber, should you want to pursue this further. I did not tag this with Core Platform Team Initiatives (MCR) as I can't confirm it's truly MCR-related, but that is my best guess.

Regardless, thank you for the help you provided over at T223828#5236438 :)

Revision::getPrevious() presumably returns null because RevisionStore::getPreviousRevision() returns null. Changing the caller from the old to the new method would not resolve the problem.

Changing the Core code to use READ_LATEST still does not resolve this issue, so I don't believe it is any sort of race condition.

Did you try that flag in the call to getPreviousRevision(), or just the Revision constructor? The former is the critical one, the later is unlikely to change anything.

Changing the Core code to use READ_LATEST still does not resolve this issue, so I don't believe it is any sort of race condition.

Did you try that flag in the call to getPreviousRevision(), or just the Revision constructor? The former is the critical one, the later is unlikely to change anything.

From T223828#5238155 I'm guessing I only did this in the constructor, so that might be the issue.

This discovery happened when Community Tech was working on PageTriage. That project has since concluded, so I don't have as much time to devote to this. I created this task just to document my findings. It may very well be invalid.

eprodromou subscribed.

We think this needs more examination, so we're going to take a closer look.