RevisionStore: fall back to master db if main slot is missing.

This is to protect against race conditions. There may be situations
where we already got the revision itself, but information is still
missing from the slots or content tables.

Bug: T212428
Bug: T252156
Change-Id: Id0cd85ae93616ad91b07afeccb766e8345fa7c9c
This commit is contained in:
daniel 2020-05-08 12:04:19 +02:00
parent 582b526982
commit 767aee7bb1

View file

@ -1247,6 +1247,21 @@ class RevisionStore
$slots[$row->role_name] = new SlotRecord( $row, $contentCallback );
}
if ( !$slots && !( $queryFlags & self::READ_LATEST ) ) {
// If we found no slots, try looking on the master database (T212428, T252156)
$this->logger->info(
__METHOD__ . ' falling back to READ_LATEST.',
[ 'trace' => wfBacktrace() ]
);
return $this->constructSlotRecords(
$revId,
$slotRows,
$queryFlags | self::READ_LATEST,
$title,
$slotContents
);
}
if ( !isset( $slots[SlotRecord::MAIN] ) ) {
throw new RevisionAccessException(
'Main slot of revision ' . $revId . ' not found in database!'