Debian Codegraph @

includes/actions/DeleteAction.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
16 *
17 * @file
18 * @ingroup Actions
19 */
20
21 use MediaWiki\Cache\BacklinkCacheFactory;
22 use MediaWiki\CommentStore\CommentStore;
23 use MediaWiki\Context\IContextSource;
24 use MediaWiki\Html\Html;
25 use MediaWiki\HTMLForm\HTMLForm;
26 use MediaWiki\Linker\LinkRenderer;
27 use MediaWiki\MainConfigNames;
28 use MediaWiki\MediaWikiServices;
29 use MediaWiki\Message\Message;
30 use MediaWiki\Page\DeletePage;
31 use MediaWiki\Page\DeletePageFactory;
32 use MediaWiki\Revision\RevisionRecord;
33 use MediaWiki\Session\CsrfTokenSet;
34 use MediaWiki\Status\Status;
35 use MediaWiki\Title\NamespaceInfo;
36 use MediaWiki\Title\TitleFactory;
37 use MediaWiki\Title\TitleFormatter;
38 use MediaWiki\User\Options\UserOptionsLookup;
39 use MediaWiki\Watchlist\WatchlistManager;
40 use Wikimedia\Rdbms\IConnectionProvider;
41 use Wikimedia\Rdbms\IDBAccessObject;
42 use Wikimedia\Rdbms\ReadOnlyMode;
43 use Wikimedia\RequestTimeout\TimeoutException;
44
45 /**
46 * Handle page deletion
47 *
48 * @ingroup Actions
49 */
50 class DeleteAction extends FormAction {
51
52 /**
53 * Constants used to localize form fields
54 */
55 protected const MSG_REASON_DROPDOWN = 'reason-dropdown';
56 protected const MSG_REASON_DROPDOWN_SUPPRESS = 'reason-dropdown-suppress';
57 protected const MSG_REASON_DROPDOWN_OTHER = 'reason-dropdown-other';
58 protected const MSG_COMMENT = 'comment';
59 protected const MSG_REASON_OTHER = 'reason-other';
60 protected const MSG_SUBMIT = 'submit';
61 protected const MSG_LEGEND = 'legend';
62 protected const MSG_EDIT_REASONS = 'edit-reasons';
63 protected const MSG_EDIT_REASONS_SUPPRESS = 'edit-reasons-suppress';
64
65 protected WatchlistManager $watchlistManager;
66 protected LinkRenderer $linkRenderer;
67 private BacklinkCacheFactory $backlinkCacheFactory;
68 protected ReadOnlyMode $readOnlyMode;
69 protected UserOptionsLookup $userOptionsLookup;
70 private DeletePageFactory $deletePageFactory;
71 private int $deleteRevisionsLimit;
72 private NamespaceInfo $namespaceInfo;
73 private TitleFormatter $titleFormatter;
74 private TitleFactory $titleFactory;
75
76 private IConnectionProvider $dbProvider;
77
78 /**
79 * @inheritDoc
80 */
81 public function __construct( Article $article, IContextSource $context ) {
82 parent::__construct( $article, $context );
83 $services = MediaWikiServices::getInstance();
84 $this->watchlistManager = $services->getWatchlistManager();
85 $this->linkRenderer = $services->getLinkRenderer();
86 $this->backlinkCacheFactory = $services->getBacklinkCacheFactory();
87 $this->readOnlyMode = $services->getReadOnlyMode();
88 $this->userOptionsLookup = $services->getUserOptionsLookup();
89 $this->deletePageFactory = $services->getDeletePageFactory();
90 $this->deleteRevisionsLimit = $services->getMainConfig()->get( MainConfigNames::DeleteRevisionsLimit );
91 $this->namespaceInfo = $services->getNamespaceInfo();
92 $this->titleFormatter = $services->getTitleFormatter();
93 $this->titleFactory = $services->getTitleFactory();
94 $this->dbProvider = $services->getConnectionProvider();
95 }
96
97 public function getName() {
98 return 'delete';
99 }
100
101 public function onSubmit( $data ) {
102 return false;
103 }
104
105 public function onSuccess() {
106 return false;
107 }
108
109 protected function usesOOUI() {
110 return true;
111 }
112
113 protected function getPageTitle() {
114 $title = $this->getTitle();
115 return $this->msg( 'delete-confirm' )->plaintextParams( $title->getPrefixedText() );
116 }
117
118 public function getRestriction() {
119 return 'delete';
120 }
121
122 protected function alterForm( HTMLForm $form ) {
123 $title = $this->getTitle();
124 $form
125 ->setAction( $this->getFormAction() )
126 ->setWrapperLegendMsg( $this->getFormMsg( self::MSG_LEGEND ) )
127 ->setWrapperAttributes( [ 'id' => 'mw-delete-table' ] )
128 ->suppressDefaultSubmit()
129 ->setId( 'deleteconfirm' )
130 ->setTokenSalt( [ 'delete', $title->getPrefixedText() ] );
131 }
132
133 public function show() {
134 $this->setHeaders();
135 $this->useTransactionalTimeLimit();
136 $this->addHelpLink( 'Help:Sysop deleting and undeleting' );
137
138 // This will throw exceptions if there's a problem
139 $this->checkCanExecute( $this->getUser() );
140
141 $this->tempDelete();
142 }
143
144 protected function tempDelete() {
145 $article = $this->getArticle();
146 $title = $this->getTitle();
147 $context = $this->getContext();
148 $user = $context->getUser();
149 $request = $context->getRequest();
150 $outputPage = $context->getOutput();
151
152 # Better double-check that it hasn't been deleted yet!
153 $article->getPage()->loadPageData(
154 $request->wasPosted() ? IDBAccessObject::READ_LATEST : IDBAccessObject::READ_NORMAL
155 );
156 if ( !$article->getPage()->exists() ) {
157 $outputPage->setPageTitleMsg(
158 $context->msg( 'cannotdelete-title' )->plaintextParams( $title->getPrefixedText() )
159 );
160 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
161 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
162 );
163 $this->showLogEntries();
164
165 return;
166 }
167
168 $hasValidCsrfToken = $this->getContext()
169 ->getCsrfTokenSet()
170 ->matchTokenField(
171 CsrfTokenSet::DEFAULT_FIELD_NAME,
172 [ 'delete', $title->getPrefixedText() ]
173 );
174
175 # If we are not processing the results of the deletion confirmation dialog, show the form
176 if ( !$request->wasPosted() || !$hasValidCsrfToken ) {
177 $this->tempConfirmDelete();
178 return;
179 }
180
181 # Check to make sure the page has not been edited while the deletion was being confirmed
182 if ( $article->getRevIdFetched() !== $request->getIntOrNull( 'wpConfirmationRevId' ) ) {
183 $this->showEditedWarning();
184 $this->tempConfirmDelete();
185 return;
186 }
187
188 # Flag to hide all contents of the archived revisions
189 $suppress = $request->getCheck( 'wpSuppress' ) &&
190 $context->getAuthority()->isAllowed( 'suppressrevision' );
191
192 $context = $this->getContext();
193 $deletePage = $this->deletePageFactory->newDeletePage(
194 $this->getWikiPage(),
195 $context->getAuthority()
196 );
197 $shouldDeleteTalk = $request->getCheck( 'wpDeleteTalk' ) &&
198 $deletePage->canProbablyDeleteAssociatedTalk()->isGood();
199 $deletePage->setDeleteAssociatedTalk( $shouldDeleteTalk );
200 $status = $deletePage
201 ->setSuppress( $suppress )
202 ->deleteIfAllowed( $this->getDeleteReason() );
203
204 if ( $status->isOK() ) {
205 $outputPage->setPageTitleMsg( $this->msg( 'actioncomplete' ) );
206 $outputPage->setRobotPolicy( 'noindex,nofollow' );
207
208 if ( !$status->isGood() ) {
209 // If the page (and/or its talk) couldn't be found (e.g. because it was deleted in another request),
210 // let the user know.
211 $outputPage->addHTML(
212 Html::warningBox(
213 $outputPage->parseAsContent(
214 Status::wrap( $status )->getWikiText(
215 false,
216 false,
217 $context->getLanguage()
218 )
219 )
220 )
221 );
222 }
223
224 $this->showSuccessMessages(
225 $deletePage->getSuccessfulDeletionsIDs(),
226 $deletePage->deletionsWereScheduled()
227 );
228
229 if ( !$status->isGood() ) {
230 $this->showLogEntries();
231 }
232 $outputPage->returnToMain();
233 } else {
234 $outputPage->setPageTitleMsg(
235 $this->msg( 'cannotdelete-title' )->plaintextParams( $this->getTitle()->getPrefixedText() )
236 );
237
238 $outputPage->wrapWikiTextAsInterface(
239 'error mw-error-cannotdelete',
240 Status::wrap( $status )->getWikiText( false, false, $context->getLanguage() )
241 );
242 $this->showLogEntries();
243 }
244
245 $this->watchlistManager->setWatch( $request->getCheck( 'wpWatch' ), $context->getAuthority(), $title );
246 }
247
248 /**
249 * Display success messages
250 *
251 * @param array $deleted
252 * @param array $scheduled
253 * @return void
254 */
255 private function showSuccessMessages( array $deleted, array $scheduled ): void {
256 $outputPage = $this->getContext()->getOutput();
257 $loglink = '[[Special:Log/delete|' . $this->msg( 'deletionlog' )->text() . ']]';
258 $pageBaseDisplayTitle = wfEscapeWikiText( $this->getTitle()->getPrefixedText() );
259 $pageTalkDisplayTitle = wfEscapeWikiText( $this->titleFormatter->getPrefixedText(
260 $this->namespaceInfo->getTalkPage( $this->getTitle() )
261 ) );
262
263 $deletedTalk = $deleted[DeletePage::PAGE_TALK] ?? false;
264 $deletedBase = $deleted[DeletePage::PAGE_BASE];
265 $scheduledTalk = $scheduled[DeletePage::PAGE_TALK] ?? false;
266 $scheduledBase = $scheduled[DeletePage::PAGE_BASE];
267
268 if ( $deletedBase && $deletedTalk ) {
269 $outputPage->addWikiMsg( 'deleted-page-and-talkpage',
270 $pageBaseDisplayTitle,
271 $pageTalkDisplayTitle,
272 $loglink );
273 } elseif ( $deletedBase ) {
274 $outputPage->addWikiMsg( 'deletedtext', $pageBaseDisplayTitle, $loglink );
275 } elseif ( $deletedTalk ) {
276 $outputPage->addWikiMsg( 'deletedtext', $pageTalkDisplayTitle, $loglink );
277 }
278
279 // run hook if article was deleted
280 if ( $deletedBase ) {
281 $this->getHookRunner()->onArticleDeleteAfterSuccess( $this->getTitle(), $outputPage );
282 }
283
284 if ( $scheduledBase ) {
285 $outputPage->addWikiMsg( 'delete-scheduled', $pageBaseDisplayTitle );
286 }
287
288 if ( $scheduledTalk ) {
289 $outputPage->addWikiMsg( 'delete-scheduled', $pageTalkDisplayTitle );
290 }
291 }
292
293 protected function showEditedWarning(): void {
294 $this->getOutput()->addHTML(
295 Html::warningBox( $this->getContext()->msg( 'editedwhiledeleting' )->parse() )
296 );
297 }
298
299 private function showHistoryWarnings(): void {
300 $context = $this->getContext();
301 $title = $this->getTitle();
302
303 // The following can use the real revision count as this is only being shown for users
304 // that can delete this page.
305 // This, as a side-effect, also makes sure that the following query isn't being run for
306 // pages with a larger history, unless the user has the 'bigdelete' right
307 // (and is about to delete this page).
308 $revisions = (int)$this->dbProvider->getReplicaDatabase()->newSelectQueryBuilder()
309 ->select( 'COUNT(rev_page)' )
310 ->from( 'revision' )
311 ->where( [ 'rev_page' => $title->getArticleID() ] )
312 ->caller( __METHOD__ )
313 ->fetchField();
314
315 // @todo i18n issue/patchwork message
316 $context->getOutput()->addHTML(
317 '<strong class="mw-delete-warning-revisions">' .
318 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
319 $context->msg( 'word-separator' )->escaped() . $this->linkRenderer->makeKnownLink(
320 $title,
321 $context->msg( 'history' )->text(),
322 [],
323 [ 'action' => 'history' ] ) .
324 '</strong>'
325 );
326
327 if ( $title->isBigDeletion() ) {
328 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
329 [
330 'delete-warning-toobig',
331 $context->getLanguage()->formatNum( $this->deleteRevisionsLimit )
332 ]
333 );
334 }
335 }
336
337 protected function showFormWarnings(): void {
338 $this->showBacklinksWarning();
339 $this->showSubpagesWarnings();
340 }
341
342 private function showBacklinksWarning(): void {
343 $backlinkCache = $this->backlinkCacheFactory->getBacklinkCache( $this->getTitle() );
344 if ( $backlinkCache->hasLinks( 'pagelinks' ) || $backlinkCache->hasLinks( 'templatelinks' ) ) {
345 $this->getOutput()->addHTML(
346 Html::warningBox(
347 $this->msg( 'deleting-backlinks-warning' )->parse(),
348 'plainlinks'
349 )
350 );
351 }
352 }
353
354 protected function showSubpagesWarnings(): void {
355 $title = $this->getTitle();
356 $subpageCount = count( $title->getSubpages( 51 ) );
357 if ( $subpageCount ) {
358 $this->getOutput()->addHTML(
359 Html::warningBox(
360 $this->msg( 'deleting-subpages-warning' )->numParams( $subpageCount )->parse(),
361 'plainlinks'
362 )
363 );
364 }
365
366 if ( !$title->isTalkPage() ) {
367 $talkPageTitle = $this->titleFactory->newFromLinkTarget( $this->namespaceInfo->getTalkPage( $title ) );
368 $subpageCount = count( $talkPageTitle->getSubpages( 51 ) );
369 if ( $subpageCount ) {
370 $this->getOutput()->addHTML(
371 Html::warningBox(
372 $this->msg( 'deleting-talkpage-subpages-warning' )->numParams( $subpageCount )->parse(),
373 'plainlinks'
374 )
375 );
376 }
377 }
378 }
379
380 private function tempConfirmDelete(): void {
381 $this->prepareOutputForForm();
382 $context = $this->getContext();
383 $outputPage = $context->getOutput();
384 $article = $this->getArticle();
385
386 $reason = $this->getDefaultReason();
387
388 // oldid is set to the revision id of the page when the page was displayed.
389 // Check to make sure the page has not been edited between loading the page
390 // and clicking the delete link
391 $oldid = $context->getRequest()->getIntOrNull( 'oldid' );
392 if ( $oldid !== null && $oldid !== $article->getRevIdFetched() ) {
393 $this->showEditedWarning();
394 }
395 // If the page has a history, insert a warning
396 if ( $this->pageHasHistory() ) {
397 $this->showHistoryWarnings();
398 }
399 $this->showFormWarnings();
400
401 $outputPage->addWikiMsg( 'confirmdeletetext' );
402
403 // FIXME: Replace (or at least rename) this hook
404 $this->getHookRunner()->onArticleConfirmDelete( $this->getArticle(), $outputPage, $reason );
405
406 $form = $this->getForm();
407 if ( $form->show() ) {
408 $this->onSuccess();
409 }
410
411 $this->showEditReasonsLinks();
412 $this->showLogEntries();
413 }
414
415 protected function showEditReasonsLinks(): void {
416 if ( $this->getAuthority()->isAllowed( 'editinterface' ) ) {
417 $link = '';
418 if ( $this->isSuppressionAllowed() ) {
419 $link .= $this->linkRenderer->makeKnownLink(
420 $this->getFormMsg( self::MSG_REASON_DROPDOWN_SUPPRESS )->inContentLanguage()->getTitle(),
421 $this->getFormMsg( self::MSG_EDIT_REASONS_SUPPRESS )->text(),
422 [],
423 [ 'action' => 'edit' ]
424 );
425 $link .= $this->msg( 'pipe-separator' )->escaped();
426 }
427 $link .= $this->linkRenderer->makeKnownLink(
428 $this->getFormMsg( self::MSG_REASON_DROPDOWN )->inContentLanguage()->getTitle(),
429 $this->getFormMsg( self::MSG_EDIT_REASONS )->text(),
430 [],
431 [ 'action' => 'edit' ]
432 );
433 $this->getOutput()->addHTML( '<p class="mw-delete-editreasons">' . $link . '</p>' );
434 }
435 }
436
437 /**
438 * @return bool
439 */
440 protected function isSuppressionAllowed(): bool {
441 return $this->getAuthority()->isAllowed( 'suppressrevision' );
442 }
443
444 /**
445 * @return array
446 */
447 protected function getFormFields(): array {
448 $user = $this->getUser();
449 $title = $this->getTitle();
450 $article = $this->getArticle();
451
452 $fields = [];
453
454 $dropdownReason = $this->getFormMsg( self::MSG_REASON_DROPDOWN )->inContentLanguage()->text();
455 // Add additional specific reasons for suppress
456 if ( $this->isSuppressionAllowed() ) {
457 $dropdownReason .= "\n" . $this->getFormMsg( self::MSG_REASON_DROPDOWN_SUPPRESS )
458 ->inContentLanguage()->text();
459 }
460
461 $options = Html::listDropdownOptions(
462 $dropdownReason,
463 [ 'other' => $this->getFormMsg( self::MSG_REASON_DROPDOWN_OTHER )->text() ]
464 );
465
466 $fields['DeleteReasonList'] = [
467 'type' => 'select',
468 'id' => 'wpDeleteReasonList',
469 'tabindex' => 1,
470 'infusable' => true,
471 'options' => $options,
472 'label' => $this->getFormMsg( self::MSG_COMMENT )->text(),
473 ];
474
475 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
476 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
477 // Unicode codepoints.
478 $fields['Reason'] = [
479 'type' => 'text',
480 'id' => 'wpReason',
481 'tabindex' => 2,
482 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
483 'infusable' => true,
484 'default' => $this->getDefaultReason(),
485 'autofocus' => true,
486 'label' => $this->getFormMsg( self::MSG_REASON_OTHER )->text(),
487 ];
488
489 $delPage = $this->deletePageFactory->newDeletePage( $this->getWikiPage(), $this->getAuthority() );
490 if ( $delPage->canProbablyDeleteAssociatedTalk()->isGood() ) {
491 $fields['DeleteTalk'] = [
492 'type' => 'check',
493 'id' => 'wpDeleteTalk',
494 'tabindex' => 3,
495 'default' => false,
496 'label-message' => 'deletepage-deletetalk',
497 ];
498 }
499
500 if ( $user->isRegistered() ) {
501 $checkWatch = $this->userOptionsLookup->getBoolOption( $user, 'watchdeletion' ) ||
502 $this->watchlistManager->isWatched( $user, $title );
503 $fields['Watch'] = [
504 'type' => 'check',
505 'id' => 'wpWatch',
506 'tabindex' => 4,
507 'default' => $checkWatch,
508 'label-message' => 'watchthis',
509 ];
510 }
511 if ( $this->isSuppressionAllowed() ) {
512 $fields['Suppress'] = [
513 'type' => 'check',
514 'id' => 'wpSuppress',
515 'tabindex' => 5,
516 'default' => false,
517 'label-message' => 'revdelete-suppress',
518 ];
519 }
520
521 $fields['ConfirmB'] = [
522 'type' => 'submit',
523 'id' => 'wpConfirmB',
524 'tabindex' => 6,
525 'buttonlabel' => $this->getFormMsg( self::MSG_SUBMIT )->text(),
526 'flags' => [ 'primary', 'destructive' ],
527 ];
528
529 $fields['ConfirmationRevId'] = [
530 'type' => 'hidden',
531 'id' => 'wpConfirmationRevId',
532 'default' => $article->getRevIdFetched(),
533 ];
534
535 return $fields;
536 }
537
538 /**
539 * @return string
540 */
541 protected function getDeleteReason(): string {
542 $deleteReasonList = $this->getRequest()->getText( 'wpDeleteReasonList', 'other' );
543 $deleteReason = $this->getRequest()->getText( 'wpReason' );
544
545 if ( $deleteReasonList === 'other' ) {
546 return $deleteReason;
547 } elseif ( $deleteReason !== '' ) {
548 // Entry from drop down menu + additional comment
549 $colonseparator = $this->msg( 'colon-separator' )->inContentLanguage()->text();
550 return $deleteReasonList . $colonseparator . $deleteReason;
551 } else {
552 return $deleteReasonList;
553 }
554 }
555
556 /**
557 * Show deletion log fragments pertaining to the current page
558 */
559 protected function showLogEntries(): void {
560 $deleteLogPage = new LogPage( 'delete' );
561 $outputPage = $this->getContext()->getOutput();
562 $outputPage->addHTML( Html::element( 'h2', [], $deleteLogPage->getName()->text() ) );
563 LogEventsList::showLogExtract( $outputPage, 'delete', $this->getTitle() );
564 }
565
566 protected function prepareOutputForForm(): void {
567 $outputPage = $this->getOutput();
568 $outputPage->addModules( 'mediawiki.misc-authed-ooui' );
569 $outputPage->addModuleStyles( 'mediawiki.action.styles' );
570 $outputPage->enableOOUI();
571 }
572
573 /**
574 * @return string[]
575 */
576 protected function getFormMessages(): array {
577 return [
578 self::MSG_REASON_DROPDOWN => 'deletereason-dropdown',
579 self::MSG_REASON_DROPDOWN_SUPPRESS => 'deletereason-dropdown-suppress',
580 self::MSG_REASON_DROPDOWN_OTHER => 'deletereasonotherlist',
581 self::MSG_COMMENT => 'deletecomment',
582 self::MSG_REASON_OTHER => 'deleteotherreason',
583 self::MSG_SUBMIT => 'deletepage-submit',
584 self::MSG_LEGEND => 'delete-legend',
585 self::MSG_EDIT_REASONS => 'delete-edit-reasonlist',
586 self::MSG_EDIT_REASONS_SUPPRESS => 'delete-edit-reasonlist-suppress',
587 ];
588 }
589
590 /**
591 * @param string $field One of the self::MSG_* constants
592 * @return Message
593 */
594 protected function getFormMsg( string $field ): Message {
595 $messages = $this->getFormMessages();
596 if ( !isset( $messages[$field] ) ) {
597 throw new InvalidArgumentException( "Invalid field $field" );
598 }
599 return $this->msg( $messages[$field] );
600 }
601
602 /**
603 * @return string
604 */
605 protected function getFormAction(): string {
606 return $this->getTitle()->getLocalURL( 'action=delete' );
607 }
608
609 /**
610 * Default reason to be used for the deletion form
611 *
612 * @return string
613 */
614 protected function getDefaultReason(): string {
615 $requestReason = $this->getRequest()->getText( 'wpReason' );
616 if ( $requestReason ) {
617 return $requestReason;
618 }
619
620 try {
621 return $this->getArticle()->getPage()->getAutoDeleteReason();
622 } catch ( TimeoutException $e ) {
623 throw $e;
624 } catch ( Exception $e ) {
625 # if a page is horribly broken, we still want to be able to
626 # delete it. So be lenient about errors here.
627 # For example, WMF logs show MWException thrown from
628 # ContentHandler::checkModelID().
629 MWExceptionHandler::logException( $e );
630 return '';
631 }
632 }
633
634 /**
635 * Determines whether a page has a history of more than one revision.
636 * @fixme We should use WikiPage::isNew() here, but it doesn't work right for undeleted pages (T289008)
637 * @return bool
638 */
639 private function pageHasHistory(): bool {
640 $dbr = $this->dbProvider->getReplicaDatabase();
641 $res = $dbr->newSelectQueryBuilder()
642 ->select( '*' )
643 ->from( 'revision' )
644 ->where( [ 'rev_page' => $this->getTitle()->getArticleID() ] )
645 ->andWhere(
646 [ $dbr->bitAnd( 'rev_deleted', RevisionRecord::DELETED_USER ) . ' = 0' ]
647 )->limit( 2 )
648 ->caller( __METHOD__ )
649 ->fetchRowCount();
650
651 return $res > 1;
652 }
653 }