Avoid primary DB query for non-talk page edits

While investigating primary database queries as part of T370304,
we found that EventDispatcher currently issues a primary DB query
to fetch the previous revision of the newly created revision on
every edit, but discards the result for non-talk pages. So, as an
optimization, have it fetch the previous revision only after the page
has been established to be a talk page.

Bug: T370304
Change-Id: I301f5c3c002c6953ef0b3919a33667a809342b84
This commit is contained in:
Máté Szabó 2024-08-14 18:18:02 +02:00 committed by Ladsgroup
parent b27574f0b6
commit b05a51beb6

View file

@ -53,9 +53,6 @@ class EventDispatcher {
public static function generateEventsForRevision( array &$events, RevisionRecord $newRevRecord ): void {
$services = MediaWikiServices::getInstance();
$revisionStore = $services->getRevisionStore();
$oldRevRecord = $revisionStore->getPreviousRevision( $newRevRecord, IDBAccessObject::READ_LATEST );
$title = Title::newFromLinkTarget(
$newRevRecord->getPageAsLinkTarget()
);
@ -71,6 +68,9 @@ class EventDispatcher {
return;
}
$revisionStore = $services->getRevisionStore();
$oldRevRecord = $revisionStore->getPreviousRevision( $newRevRecord, IDBAccessObject::READ_LATEST );
if ( $oldRevRecord !== null ) {
$oldItemSet = static::getParsedRevision( $oldRevRecord );
} else {