Merge "Chinese Conversion Table Update 2017-6"
[lhc/web/wiklou.git] / includes / page / PageArchive.php
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 along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 use MediaWiki\MediaWikiServices;
22 use Wikimedia\Rdbms\ResultWrapper;
23 use Wikimedia\Rdbms\IDatabase;
24
25 /**
26 * Used to show archived pages and eventually restore them.
27 */
28 class PageArchive {
29 /** @var Title */
30 protected $title;
31
32 /** @var Status */
33 protected $fileStatus;
34
35 /** @var Status */
36 protected $revisionStatus;
37
38 /** @var Config */
39 protected $config;
40
41 public function __construct( $title, Config $config = null ) {
42 if ( is_null( $title ) ) {
43 throw new MWException( __METHOD__ . ' given a null title.' );
44 }
45 $this->title = $title;
46 if ( $config === null ) {
47 wfDebug( __METHOD__ . ' did not have a Config object passed to it' );
48 $config = MediaWikiServices::getInstance()->getMainConfig();
49 }
50 $this->config = $config;
51 }
52
53 public function doesWrites() {
54 return true;
55 }
56
57 /**
58 * List all deleted pages recorded in the archive table. Returns result
59 * wrapper with (ar_namespace, ar_title, count) fields, ordered by page
60 * namespace/title.
61 *
62 * @return ResultWrapper
63 */
64 public static function listAllPages() {
65 $dbr = wfGetDB( DB_REPLICA );
66
67 return self::listPages( $dbr, '' );
68 }
69
70 /**
71 * List deleted pages recorded in the archive matching the
72 * given term, using search engine archive.
73 * Returns result wrapper with (ar_namespace, ar_title, count) fields.
74 *
75 * @param string $term Search term
76 * @return ResultWrapper
77 */
78 public static function listPagesBySearch( $term ) {
79 $title = Title::newFromText( $term );
80 if ( $title ) {
81 $ns = $title->getNamespace();
82 $termMain = $title->getText();
83 $termDb = $title->getDBkey();
84 } else {
85 // Prolly won't work too good
86 // @todo handle bare namespace names cleanly?
87 $ns = 0;
88 $termMain = $termDb = $term;
89 }
90
91 // Try search engine first
92 $engine = MediaWikiServices::getInstance()->newSearchEngine();
93 $engine->setLimitOffset( 100 );
94 $engine->setNamespaces( [ $ns ] );
95 $results = $engine->searchArchiveTitle( $termMain );
96 if ( !$results->isOK() ) {
97 $results = [];
98 } else {
99 $results = $results->getValue();
100 }
101
102 if ( !$results ) {
103 // Fall back to regular prefix search
104 return self::listPagesByPrefix( $term );
105 }
106
107 $dbr = wfGetDB( DB_REPLICA );
108 $condTitles = array_unique( array_map( function ( Title $t ) {
109 return $t->getDBkey();
110 }, $results ) );
111 $conds = [
112 'ar_namespace' => $ns,
113 $dbr->makeList( [ 'ar_title' => $condTitles ], LIST_OR ) . " OR ar_title " .
114 $dbr->buildLike( $termDb, $dbr->anyString() )
115 ];
116
117 return self::listPages( $dbr, $conds );
118 }
119
120 /**
121 * List deleted pages recorded in the archive table matching the
122 * given title prefix.
123 * Returns result wrapper with (ar_namespace, ar_title, count) fields.
124 *
125 * @param string $prefix Title prefix
126 * @return ResultWrapper
127 */
128 public static function listPagesByPrefix( $prefix ) {
129 $dbr = wfGetDB( DB_REPLICA );
130
131 $title = Title::newFromText( $prefix );
132 if ( $title ) {
133 $ns = $title->getNamespace();
134 $prefix = $title->getDBkey();
135 } else {
136 // Prolly won't work too good
137 // @todo handle bare namespace names cleanly?
138 $ns = 0;
139 }
140
141 $conds = [
142 'ar_namespace' => $ns,
143 'ar_title' . $dbr->buildLike( $prefix, $dbr->anyString() ),
144 ];
145
146 return self::listPages( $dbr, $conds );
147 }
148
149 /**
150 * @param IDatabase $dbr
151 * @param string|array $condition
152 * @return bool|ResultWrapper
153 */
154 protected static function listPages( $dbr, $condition ) {
155 return $dbr->select(
156 [ 'archive' ],
157 [
158 'ar_namespace',
159 'ar_title',
160 'count' => 'COUNT(*)'
161 ],
162 $condition,
163 __METHOD__,
164 [
165 'GROUP BY' => [ 'ar_namespace', 'ar_title' ],
166 'ORDER BY' => [ 'ar_namespace', 'ar_title' ],
167 'LIMIT' => 100,
168 ]
169 );
170 }
171
172 /**
173 * List the revisions of the given page. Returns result wrapper with
174 * various archive table fields.
175 *
176 * @return ResultWrapper
177 */
178 public function listRevisions() {
179 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
180 $queryInfo = $revisionStore->getArchiveQueryInfo();
181
182 $conds = [
183 'ar_namespace' => $this->title->getNamespace(),
184 'ar_title' => $this->title->getDBkey(),
185 ];
186 $options = [ 'ORDER BY' => 'ar_timestamp DESC' ];
187
188 ChangeTags::modifyDisplayQuery(
189 $queryInfo['tables'],
190 $queryInfo['fields'],
191 $conds,
192 $queryInfo['joins'],
193 $options,
194 ''
195 );
196
197 $dbr = wfGetDB( DB_REPLICA );
198 return $dbr->select(
199 $queryInfo['tables'],
200 $queryInfo['fields'],
201 $conds,
202 __METHOD__,
203 $options,
204 $queryInfo['joins']
205 );
206 }
207
208 /**
209 * List the deleted file revisions for this page, if it's a file page.
210 * Returns a result wrapper with various filearchive fields, or null
211 * if not a file page.
212 *
213 * @return ResultWrapper
214 * @todo Does this belong in Image for fuller encapsulation?
215 */
216 public function listFiles() {
217 if ( $this->title->getNamespace() != NS_FILE ) {
218 return null;
219 }
220
221 $dbr = wfGetDB( DB_REPLICA );
222 $fileQuery = ArchivedFile::getQueryInfo();
223 return $dbr->select(
224 $fileQuery['tables'],
225 $fileQuery['fields'],
226 [ 'fa_name' => $this->title->getDBkey() ],
227 __METHOD__,
228 [ 'ORDER BY' => 'fa_timestamp DESC' ],
229 $fileQuery['joins']
230 );
231 }
232
233 /**
234 * Return a Revision object containing data for the deleted revision.
235 * Note that the result *may* or *may not* have a null page ID.
236 *
237 * @param string $timestamp
238 * @return Revision|null
239 */
240 public function getRevision( $timestamp ) {
241 $dbr = wfGetDB( DB_REPLICA );
242 $arQuery = Revision::getArchiveQueryInfo();
243
244 $row = $dbr->selectRow(
245 $arQuery['tables'],
246 $arQuery['fields'],
247 [
248 'ar_namespace' => $this->title->getNamespace(),
249 'ar_title' => $this->title->getDBkey(),
250 'ar_timestamp' => $dbr->timestamp( $timestamp )
251 ],
252 __METHOD__,
253 [],
254 $arQuery['joins']
255 );
256
257 if ( $row ) {
258 return Revision::newFromArchiveRow( $row, [ 'title' => $this->title ] );
259 }
260
261 return null;
262 }
263
264 /**
265 * Return the most-previous revision, either live or deleted, against
266 * the deleted revision given by timestamp.
267 *
268 * May produce unexpected results in case of history merges or other
269 * unusual time issues.
270 *
271 * @param string $timestamp
272 * @return Revision|null Null when there is no previous revision
273 */
274 public function getPreviousRevision( $timestamp ) {
275 $dbr = wfGetDB( DB_REPLICA );
276
277 // Check the previous deleted revision...
278 $row = $dbr->selectRow( 'archive',
279 'ar_timestamp',
280 [ 'ar_namespace' => $this->title->getNamespace(),
281 'ar_title' => $this->title->getDBkey(),
282 'ar_timestamp < ' .
283 $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ],
284 __METHOD__,
285 [
286 'ORDER BY' => 'ar_timestamp DESC',
287 'LIMIT' => 1 ] );
288 $prevDeleted = $row ? wfTimestamp( TS_MW, $row->ar_timestamp ) : false;
289
290 $row = $dbr->selectRow( [ 'page', 'revision' ],
291 [ 'rev_id', 'rev_timestamp' ],
292 [
293 'page_namespace' => $this->title->getNamespace(),
294 'page_title' => $this->title->getDBkey(),
295 'page_id = rev_page',
296 'rev_timestamp < ' .
297 $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ],
298 __METHOD__,
299 [
300 'ORDER BY' => 'rev_timestamp DESC',
301 'LIMIT' => 1 ] );
302 $prevLive = $row ? wfTimestamp( TS_MW, $row->rev_timestamp ) : false;
303 $prevLiveId = $row ? intval( $row->rev_id ) : null;
304
305 if ( $prevLive && $prevLive > $prevDeleted ) {
306 // Most prior revision was live
307 return Revision::newFromId( $prevLiveId );
308 } elseif ( $prevDeleted ) {
309 // Most prior revision was deleted
310 return $this->getRevision( $prevDeleted );
311 }
312
313 // No prior revision on this page.
314 return null;
315 }
316
317 /**
318 * Get the text from an archive row containing ar_text, ar_flags and ar_text_id
319 *
320 * @param object $row Database row
321 * @return string
322 */
323 public function getTextFromRow( $row ) {
324 if ( is_null( $row->ar_text_id ) ) {
325 // An old row from MediaWiki 1.4 or previous.
326 // Text is embedded in this row in classic compression format.
327 return Revision::getRevisionText( $row, 'ar_' );
328 }
329
330 // New-style: keyed to the text storage backend.
331 $dbr = wfGetDB( DB_REPLICA );
332 $text = $dbr->selectRow( 'text',
333 [ 'old_text', 'old_flags' ],
334 [ 'old_id' => $row->ar_text_id ],
335 __METHOD__ );
336
337 return Revision::getRevisionText( $text );
338 }
339
340 /**
341 * Fetch (and decompress if necessary) the stored text of the most
342 * recently edited deleted revision of the page.
343 *
344 * If there are no archived revisions for the page, returns NULL.
345 *
346 * @return string|null
347 */
348 public function getLastRevisionText() {
349 $dbr = wfGetDB( DB_REPLICA );
350 $row = $dbr->selectRow( 'archive',
351 [ 'ar_text', 'ar_flags', 'ar_text_id' ],
352 [ 'ar_namespace' => $this->title->getNamespace(),
353 'ar_title' => $this->title->getDBkey() ],
354 __METHOD__,
355 [ 'ORDER BY' => 'ar_timestamp DESC' ] );
356
357 if ( $row ) {
358 return $this->getTextFromRow( $row );
359 }
360
361 return null;
362 }
363
364 /**
365 * Quick check if any archived revisions are present for the page.
366 *
367 * @return bool
368 */
369 public function isDeleted() {
370 $dbr = wfGetDB( DB_REPLICA );
371 $n = $dbr->selectField( 'archive', 'COUNT(ar_title)',
372 [ 'ar_namespace' => $this->title->getNamespace(),
373 'ar_title' => $this->title->getDBkey() ],
374 __METHOD__
375 );
376
377 return ( $n > 0 );
378 }
379
380 /**
381 * Restore the given (or all) text and file revisions for the page.
382 * Once restored, the items will be removed from the archive tables.
383 * The deletion log will be updated with an undeletion notice.
384 *
385 * This also sets Status objects, $this->fileStatus and $this->revisionStatus
386 * (depending what operations are attempted).
387 *
388 * @param array $timestamps Pass an empty array to restore all revisions,
389 * otherwise list the ones to undelete.
390 * @param string $comment
391 * @param array $fileVersions
392 * @param bool $unsuppress
393 * @param User $user User performing the action, or null to use $wgUser
394 * @param string|string[] $tags Change tags to add to log entry
395 * ($user should be able to add the specified tags before this is called)
396 * @return array|bool array(number of file revisions restored, number of image revisions
397 * restored, log message) on success, false on failure.
398 */
399 public function undelete( $timestamps, $comment = '', $fileVersions = [],
400 $unsuppress = false, User $user = null, $tags = null
401 ) {
402 // If both the set of text revisions and file revisions are empty,
403 // restore everything. Otherwise, just restore the requested items.
404 $restoreAll = empty( $timestamps ) && empty( $fileVersions );
405
406 $restoreText = $restoreAll || !empty( $timestamps );
407 $restoreFiles = $restoreAll || !empty( $fileVersions );
408
409 if ( $restoreFiles && $this->title->getNamespace() == NS_FILE ) {
410 $img = wfLocalFile( $this->title );
411 $img->load( File::READ_LATEST );
412 $this->fileStatus = $img->restore( $fileVersions, $unsuppress );
413 if ( !$this->fileStatus->isOK() ) {
414 return false;
415 }
416 $filesRestored = $this->fileStatus->successCount;
417 } else {
418 $filesRestored = 0;
419 }
420
421 if ( $restoreText ) {
422 $this->revisionStatus = $this->undeleteRevisions( $timestamps, $unsuppress, $comment );
423 if ( !$this->revisionStatus->isOK() ) {
424 return false;
425 }
426
427 $textRestored = $this->revisionStatus->getValue();
428 } else {
429 $textRestored = 0;
430 }
431
432 // Touch the log!
433
434 if ( !$textRestored && !$filesRestored ) {
435 wfDebug( "Undelete: nothing undeleted...\n" );
436
437 return false;
438 }
439
440 if ( $user === null ) {
441 global $wgUser;
442 $user = $wgUser;
443 }
444
445 $logEntry = new ManualLogEntry( 'delete', 'restore' );
446 $logEntry->setPerformer( $user );
447 $logEntry->setTarget( $this->title );
448 $logEntry->setComment( $comment );
449 $logEntry->setTags( $tags );
450 $logEntry->setParameters( [
451 ':assoc:count' => [
452 'revisions' => $textRestored,
453 'files' => $filesRestored,
454 ],
455 ] );
456
457 Hooks::run( 'ArticleUndeleteLogEntry', [ $this, &$logEntry, $user ] );
458
459 $logid = $logEntry->insert();
460 $logEntry->publish( $logid );
461
462 return [ $textRestored, $filesRestored, $comment ];
463 }
464
465 /**
466 * This is the meaty bit -- It restores archived revisions of the given page
467 * to the revision table.
468 *
469 * @param array $timestamps Pass an empty array to restore all revisions,
470 * otherwise list the ones to undelete.
471 * @param bool $unsuppress Remove all ar_deleted/fa_deleted restrictions of seletected revs
472 * @param string $comment
473 * @throws ReadOnlyError
474 * @return Status Status object containing the number of revisions restored on success
475 */
476 private function undeleteRevisions( $timestamps, $unsuppress = false, $comment = '' ) {
477 if ( wfReadOnly() ) {
478 throw new ReadOnlyError();
479 }
480
481 $dbw = wfGetDB( DB_MASTER );
482 $dbw->startAtomic( __METHOD__ );
483
484 $restoreAll = empty( $timestamps );
485
486 # Does this page already exist? We'll have to update it...
487 $article = WikiPage::factory( $this->title );
488 # Load latest data for the current page (T33179)
489 $article->loadPageData( 'fromdbmaster' );
490 $oldcountable = $article->isCountable();
491
492 $page = $dbw->selectRow( 'page',
493 [ 'page_id', 'page_latest' ],
494 [ 'page_namespace' => $this->title->getNamespace(),
495 'page_title' => $this->title->getDBkey() ],
496 __METHOD__,
497 [ 'FOR UPDATE' ] // lock page
498 );
499
500 if ( $page ) {
501 $makepage = false;
502 # Page already exists. Import the history, and if necessary
503 # we'll update the latest revision field in the record.
504
505 # Get the time span of this page
506 $previousTimestamp = $dbw->selectField( 'revision', 'rev_timestamp',
507 [ 'rev_id' => $page->page_latest ],
508 __METHOD__ );
509
510 if ( $previousTimestamp === false ) {
511 wfDebug( __METHOD__ . ": existing page refers to a page_latest that does not exist\n" );
512
513 $status = Status::newGood( 0 );
514 $status->warning( 'undeleterevision-missing' );
515 $dbw->endAtomic( __METHOD__ );
516
517 return $status;
518 }
519 } else {
520 # Have to create a new article...
521 $makepage = true;
522 $previousTimestamp = 0;
523 }
524
525 $oldWhere = [
526 'ar_namespace' => $this->title->getNamespace(),
527 'ar_title' => $this->title->getDBkey(),
528 ];
529 if ( !$restoreAll ) {
530 $oldWhere['ar_timestamp'] = array_map( [ &$dbw, 'timestamp' ], $timestamps );
531 }
532
533 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
534 $queryInfo = $revisionStore->getArchiveQueryInfo();
535 $queryInfo['tables'][] = 'revision';
536 $queryInfo['fields'][] = 'rev_id';
537 $queryInfo['joins']['revision'] = [ 'LEFT JOIN', 'ar_rev_id=rev_id' ];
538
539 /**
540 * Select each archived revision...
541 */
542 $result = $dbw->select(
543 $queryInfo['tables'],
544 $queryInfo['fields'],
545 $oldWhere,
546 __METHOD__,
547 /* options */
548 [ 'ORDER BY' => 'ar_timestamp' ],
549 $queryInfo['joins']
550 );
551
552 $rev_count = $result->numRows();
553 if ( !$rev_count ) {
554 wfDebug( __METHOD__ . ": no revisions to restore\n" );
555
556 $status = Status::newGood( 0 );
557 $status->warning( "undelete-no-results" );
558 $dbw->endAtomic( __METHOD__ );
559
560 return $status;
561 }
562
563 // We use ar_id because there can be duplicate ar_rev_id even for the same
564 // page. In this case, we may be able to restore the first one.
565 $restoreFailedArIds = [];
566
567 // Map rev_id to the ar_id that is allowed to use it. When checking later,
568 // if it doesn't match, the current ar_id can not be restored.
569
570 // Value can be an ar_id or -1 (-1 means no ar_id can use it, since the
571 // rev_id is taken before we even start the restore).
572 $allowedRevIdToArIdMap = [];
573
574 $latestRestorableRow = null;
575
576 foreach ( $result as $row ) {
577 if ( $row->ar_rev_id ) {
578 // rev_id is taken even before we start restoring.
579 if ( $row->ar_rev_id === $row->rev_id ) {
580 $restoreFailedArIds[] = $row->ar_id;
581 $allowedRevIdToArIdMap[$row->ar_rev_id] = -1;
582 } else {
583 // rev_id is not taken yet in the DB, but it might be taken
584 // by a prior revision in the same restore operation. If
585 // not, we need to reserve it.
586 if ( isset( $allowedRevIdToArIdMap[$row->ar_rev_id] ) ) {
587 $restoreFailedArIds[] = $row->ar_id;
588 } else {
589 $allowedRevIdToArIdMap[$row->ar_rev_id] = $row->ar_id;
590 $latestRestorableRow = $row;
591 }
592 }
593 } else {
594 // If ar_rev_id is null, there can't be a collision, and a
595 // rev_id will be chosen automatically.
596 $latestRestorableRow = $row;
597 }
598 }
599
600 $result->seek( 0 ); // move back
601
602 $oldPageId = 0;
603 if ( $latestRestorableRow !== null ) {
604 $oldPageId = (int)$latestRestorableRow->ar_page_id; // pass this to ArticleUndelete hook
605
606 // grab the content to check consistency with global state before restoring the page.
607 $revision = Revision::newFromArchiveRow( $latestRestorableRow,
608 [
609 'title' => $article->getTitle(), // used to derive default content model
610 ]
611 );
612 $user = User::newFromName( $revision->getUserText( Revision::RAW ), false );
613 $content = $revision->getContent( Revision::RAW );
614
615 // NOTE: article ID may not be known yet. prepareSave() should not modify the database.
616 $status = $content->prepareSave( $article, 0, -1, $user );
617 if ( !$status->isOK() ) {
618 $dbw->endAtomic( __METHOD__ );
619
620 return $status;
621 }
622 }
623
624 $newid = false; // newly created page ID
625 $restored = 0; // number of revisions restored
626 /** @var Revision $revision */
627 $revision = null;
628 $restoredPages = [];
629 // If there are no restorable revisions, we can skip most of the steps.
630 if ( $latestRestorableRow === null ) {
631 $failedRevisionCount = $rev_count;
632 } else {
633 if ( $makepage ) {
634 // Check the state of the newest to-be version...
635 if ( !$unsuppress
636 && ( $latestRestorableRow->ar_deleted & Revision::DELETED_TEXT )
637 ) {
638 $dbw->endAtomic( __METHOD__ );
639
640 return Status::newFatal( "undeleterevdel" );
641 }
642 // Safe to insert now...
643 $newid = $article->insertOn( $dbw, $latestRestorableRow->ar_page_id );
644 if ( $newid === false ) {
645 // The old ID is reserved; let's pick another
646 $newid = $article->insertOn( $dbw );
647 }
648 $pageId = $newid;
649 } else {
650 // Check if a deleted revision will become the current revision...
651 if ( $latestRestorableRow->ar_timestamp > $previousTimestamp ) {
652 // Check the state of the newest to-be version...
653 if ( !$unsuppress
654 && ( $latestRestorableRow->ar_deleted & Revision::DELETED_TEXT )
655 ) {
656 $dbw->endAtomic( __METHOD__ );
657
658 return Status::newFatal( "undeleterevdel" );
659 }
660 }
661
662 $newid = false;
663 $pageId = $article->getId();
664 }
665
666 foreach ( $result as $row ) {
667 // Check for key dupes due to needed archive integrity.
668 if ( $row->ar_rev_id && $allowedRevIdToArIdMap[$row->ar_rev_id] !== $row->ar_id ) {
669 continue;
670 }
671 // Insert one revision at a time...maintaining deletion status
672 // unless we are specifically removing all restrictions...
673 $revision = Revision::newFromArchiveRow( $row,
674 [
675 'page' => $pageId,
676 'title' => $this->title,
677 'deleted' => $unsuppress ? 0 : $row->ar_deleted
678 ] );
679
680 // This will also copy the revision to ip_changes if it was an IP edit.
681 $revision->insertOn( $dbw );
682
683 $restored++;
684
685 Hooks::run( 'ArticleRevisionUndeleted',
686 [ &$this->title, $revision, $row->ar_page_id ] );
687 $restoredPages[$row->ar_page_id] = true;
688 }
689
690 // Now that it's safely stored, take it out of the archive
691 // Don't delete rows that we failed to restore
692 $toDeleteConds = $oldWhere;
693 $failedRevisionCount = count( $restoreFailedArIds );
694 if ( $failedRevisionCount > 0 ) {
695 $toDeleteConds[] = 'ar_id NOT IN ( ' . $dbw->makeList( $restoreFailedArIds ) . ' )';
696 }
697
698 $dbw->delete( 'archive',
699 $toDeleteConds,
700 __METHOD__ );
701 }
702
703 $status = Status::newGood( $restored );
704
705 if ( $failedRevisionCount > 0 ) {
706 $status->warning(
707 wfMessage( 'undeleterevision-duplicate-revid', $failedRevisionCount ) );
708 }
709
710 // Was anything restored at all?
711 if ( $restored ) {
712 $created = (bool)$newid;
713 // Attach the latest revision to the page...
714 $wasnew = $article->updateIfNewerOn( $dbw, $revision );
715 if ( $created || $wasnew ) {
716 // Update site stats, link tables, etc
717 $article->doEditUpdates(
718 $revision,
719 User::newFromName( $revision->getUserText( Revision::RAW ), false ),
720 [
721 'created' => $created,
722 'oldcountable' => $oldcountable,
723 'restored' => true
724 ]
725 );
726 }
727
728 Hooks::run( 'ArticleUndelete',
729 [ &$this->title, $created, $comment, $oldPageId, $restoredPages ] );
730 if ( $this->title->getNamespace() == NS_FILE ) {
731 DeferredUpdates::addUpdate(
732 new HTMLCacheUpdate( $this->title, 'imagelinks', 'file-restore' )
733 );
734 }
735 }
736
737 $dbw->endAtomic( __METHOD__ );
738
739 return $status;
740 }
741
742 /**
743 * @return Status
744 */
745 public function getFileStatus() {
746 return $this->fileStatus;
747 }
748
749 /**
750 * @return Status
751 */
752 public function getRevisionStatus() {
753 return $this->revisionStatus;
754 }
755 }