MergeHistory: Avoid potential DB query for trivial message variation

Title::exists( Title::READ_LATEST ) can lead to querrying the master
database just to decide whether to show a variation of message to the
user, and even after consulting the master database, the check can be
negated by the TitleExists hook (T265775), making the db check useless.

This can be simplified by notifying the caller upfront whether the
source page is deleted, since this info is authoritatively known at
the point of the deletion.

Bug: T278295
Change-Id: Iccf61a06306126c03be302dddfdfeb576217a048
This commit is contained in:
Ammarpad 2021-03-24 07:43:33 +01:00
parent 4886a4707a
commit 5c0c4d1201
2 changed files with 4 additions and 3 deletions

View file

@ -579,6 +579,8 @@ class MergeHistory {
// fails, it will be communicated in the status reponse.
$reason = wfMessage( 'mergehistory-source-deleted-reason' )->inContentLanguage()->plain();
$deletionStatus = $newPage->doDeleteArticleReal( $reason, $user );
// Notify callers that the source page has been deleted.
$status->value = 'source-deleted';
$status->merge( $deletionStatus );
}

View file

@ -411,9 +411,8 @@ class SpecialMergeHistory extends SpecialPage {
);
// In some cases the target page will be deleted
$append = $targetTitle->exists( Title::READ_LATEST )
? ''
: $this->msg( 'mergehistory-source-deleted', $targetLink );
$append = ( $mergeStatus->getValue() === 'source-deleted' )
? $this->msg( 'mergehistory-source-deleted', $targetLink ) : '';
$this->getOutput()->addWikiMsg( $this->msg( 'mergehistory-done' )
->rawParams( $targetLink )