Don't require commandLine.inc when not using the command line; instead, move wfWaitFo...
[lhc/web/wiklou.git] / includes / SpecialUndelete.php
1 <?php
2
3 /**
4 * Special page allowing users with the appropriate permissions to view
5 * and restore deleted content
6 *
7 * @addtogroup SpecialPage
8 */
9
10 /**
11 * Constructor
12 */
13 function wfSpecialUndelete( $par ) {
14 global $wgRequest;
15
16 $form = new UndeleteForm( $wgRequest, $par );
17 $form->execute();
18 }
19
20 /**
21 * Used to show archived pages and eventually restore them.
22 * @addtogroup SpecialPage
23 */
24 class PageArchive {
25 protected $title;
26 var $fileStatus;
27
28 function __construct( $title ) {
29 if( is_null( $title ) ) {
30 throw new MWException( 'Archiver() given a null title.');
31 }
32 $this->title = $title;
33 }
34
35 /**
36 * List all deleted pages recorded in the archive table. Returns result
37 * wrapper with (ar_namespace, ar_title, count) fields, ordered by page
38 * namespace/title.
39 *
40 * @return ResultWrapper
41 */
42 public static function listAllPages() {
43 $dbr = wfGetDB( DB_SLAVE );
44 return self::listPages( $dbr, '' );
45 }
46
47 /**
48 * List deleted pages recorded in the archive table matching the
49 * given title prefix.
50 * Returns result wrapper with (ar_namespace, ar_title, count) fields.
51 *
52 * @return ResultWrapper
53 */
54 public static function listPagesByPrefix( $prefix ) {
55 $dbr = wfGetDB( DB_SLAVE );
56
57 $title = Title::newFromText( $prefix );
58 if( $title ) {
59 $ns = $title->getNamespace();
60 $encPrefix = $dbr->escapeLike( $title->getDBkey() );
61 } else {
62 // Prolly won't work too good
63 // @todo handle bare namespace names cleanly?
64 $ns = 0;
65 $encPrefix = $dbr->escapeLike( $prefix );
66 }
67 $conds = array(
68 'ar_namespace' => $ns,
69 "ar_title LIKE '$encPrefix%'",
70 );
71 return self::listPages( $dbr, $conds );
72 }
73
74 protected static function listPages( $dbr, $condition ) {
75 return $dbr->resultObject(
76 $dbr->select(
77 array( 'archive' ),
78 array(
79 'ar_namespace',
80 'ar_title',
81 'COUNT(*) AS count'
82 ),
83 $condition,
84 __METHOD__,
85 array(
86 'GROUP BY' => 'ar_namespace,ar_title',
87 'ORDER BY' => 'ar_namespace,ar_title',
88 'LIMIT' => 100,
89 )
90 )
91 );
92 }
93
94 /**
95 * List the revisions of the given page. Returns result wrapper with
96 * (ar_minor_edit, ar_timestamp, ar_user, ar_user_text, ar_comment) fields.
97 *
98 * @return ResultWrapper
99 */
100 function listRevisions() {
101 $dbr = wfGetDB( DB_SLAVE );
102 $res = $dbr->select( 'archive',
103 array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len', 'ar_deleted' ),
104 array( 'ar_namespace' => $this->title->getNamespace(),
105 'ar_title' => $this->title->getDBkey() ),
106 'PageArchive::listRevisions',
107 array( 'ORDER BY' => 'ar_timestamp DESC' ) );
108 $ret = $dbr->resultObject( $res );
109 return $ret;
110 }
111
112 /**
113 * List the deleted file revisions for this page, if it's a file page.
114 * Returns a result wrapper with various filearchive fields, or null
115 * if not a file page.
116 *
117 * @return ResultWrapper
118 * @todo Does this belong in Image for fuller encapsulation?
119 */
120 function listFiles() {
121 if( $this->title->getNamespace() == NS_IMAGE ) {
122 $dbr = wfGetDB( DB_SLAVE );
123 $res = $dbr->select( 'filearchive',
124 array(
125 'fa_id',
126 'fa_name',
127 'fa_archive_name',
128 'fa_storage_key',
129 'fa_storage_group',
130 'fa_size',
131 'fa_width',
132 'fa_height',
133 'fa_bits',
134 'fa_metadata',
135 'fa_media_type',
136 'fa_major_mime',
137 'fa_minor_mime',
138 'fa_description',
139 'fa_user',
140 'fa_user_text',
141 'fa_timestamp',
142 'fa_deleted' ),
143 array( 'fa_name' => $this->title->getDBkey() ),
144 __METHOD__,
145 array( 'ORDER BY' => 'fa_timestamp DESC' ) );
146 $ret = $dbr->resultObject( $res );
147 return $ret;
148 }
149 return null;
150 }
151
152 /**
153 * Fetch (and decompress if necessary) the stored text for the deleted
154 * revision of the page with the given timestamp.
155 *
156 * @return string
157 * @deprecated Use getRevision() for more flexible information
158 */
159 function getRevisionText( $timestamp ) {
160 $rev = $this->getRevision( $timestamp );
161 return $rev ? $rev->getText() : null;
162 }
163
164 /**
165 * Return a Revision object containing data for the deleted revision.
166 * Note that the result *may* or *may not* have a null page ID.
167 * @param string $timestamp
168 * @return Revision
169 */
170 function getRevision( $timestamp ) {
171 $dbr = wfGetDB( DB_SLAVE );
172 $row = $dbr->selectRow( 'archive',
173 array(
174 'ar_rev_id',
175 'ar_text',
176 'ar_comment',
177 'ar_user',
178 'ar_user_text',
179 'ar_timestamp',
180 'ar_minor_edit',
181 'ar_flags',
182 'ar_text_id',
183 'ar_deleted',
184 'ar_len' ),
185 array( 'ar_namespace' => $this->title->getNamespace(),
186 'ar_title' => $this->title->getDBkey(),
187 'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
188 __METHOD__ );
189 if( $row ) {
190 return new Revision( array(
191 'page' => $this->title->getArticleId(),
192 'id' => $row->ar_rev_id,
193 'text' => ($row->ar_text_id
194 ? null
195 : Revision::getRevisionText( $row, 'ar_' ) ),
196 'comment' => $row->ar_comment,
197 'user' => $row->ar_user,
198 'user_text' => $row->ar_user_text,
199 'timestamp' => $row->ar_timestamp,
200 'minor_edit' => $row->ar_minor_edit,
201 'text_id' => $row->ar_text_id,
202 'deleted' => $row->ar_deleted,
203 'len' => $row->ar_len) );
204 } else {
205 return null;
206 }
207 }
208
209 /**
210 * Return the most-previous revision, either live or deleted, against
211 * the deleted revision given by timestamp.
212 *
213 * May produce unexpected results in case of history merges or other
214 * unusual time issues.
215 *
216 * @param string $timestamp
217 * @return Revision or null
218 */
219 function getPreviousRevision( $timestamp ) {
220 $dbr = wfGetDB( DB_SLAVE );
221
222 // Check the previous deleted revision...
223 $row = $dbr->selectRow( 'archive',
224 'ar_timestamp',
225 array( 'ar_namespace' => $this->title->getNamespace(),
226 'ar_title' => $this->title->getDBkey(),
227 'ar_timestamp < ' .
228 $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ),
229 __METHOD__,
230 array(
231 'ORDER BY' => 'ar_timestamp DESC',
232 'LIMIT' => 1 ) );
233 $prevDeleted = $row ? wfTimestamp( TS_MW, $row->ar_timestamp ) : false;
234
235 $row = $dbr->selectRow( array( 'page', 'revision' ),
236 array( 'rev_id', 'rev_timestamp' ),
237 array(
238 'page_namespace' => $this->title->getNamespace(),
239 'page_title' => $this->title->getDBkey(),
240 'page_id = rev_page',
241 'rev_timestamp < ' .
242 $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ),
243 __METHOD__,
244 array(
245 'ORDER BY' => 'rev_timestamp DESC',
246 'LIMIT' => 1 ) );
247 $prevLive = $row ? wfTimestamp( TS_MW, $row->rev_timestamp ) : false;
248 $prevLiveId = $row ? intval( $row->rev_id ) : null;
249
250 if( $prevLive && $prevLive > $prevDeleted ) {
251 // Most prior revision was live
252 return Revision::newFromId( $prevLiveId );
253 } elseif( $prevDeleted ) {
254 // Most prior revision was deleted
255 return $this->getRevision( $prevDeleted );
256 } else {
257 // No prior revision on this page.
258 return null;
259 }
260 }
261
262 /**
263 * Get the text from an archive row containing ar_text, ar_flags and ar_text_id
264 */
265 function getTextFromRow( $row ) {
266 if( is_null( $row->ar_text_id ) ) {
267 // An old row from MediaWiki 1.4 or previous.
268 // Text is embedded in this row in classic compression format.
269 return Revision::getRevisionText( $row, "ar_" );
270 } else {
271 // New-style: keyed to the text storage backend.
272 $dbr = wfGetDB( DB_SLAVE );
273 $text = $dbr->selectRow( 'text',
274 array( 'old_text', 'old_flags' ),
275 array( 'old_id' => $row->ar_text_id ),
276 __METHOD__ );
277 return Revision::getRevisionText( $text );
278 }
279 }
280
281
282 /**
283 * Fetch (and decompress if necessary) the stored text of the most
284 * recently edited deleted revision of the page.
285 *
286 * If there are no archived revisions for the page, returns NULL.
287 *
288 * @return string
289 */
290 function getLastRevisionText() {
291 $dbr = wfGetDB( DB_SLAVE );
292 $row = $dbr->selectRow( 'archive',
293 array( 'ar_text', 'ar_flags', 'ar_text_id' ),
294 array( 'ar_namespace' => $this->title->getNamespace(),
295 'ar_title' => $this->title->getDBkey() ),
296 'PageArchive::getLastRevisionText',
297 array( 'ORDER BY' => 'ar_timestamp DESC' ) );
298 if( $row ) {
299 return $this->getTextFromRow( $row );
300 } else {
301 return NULL;
302 }
303 }
304
305 /**
306 * Quick check if any archived revisions are present for the page.
307 * @return bool
308 */
309 function isDeleted() {
310 $dbr = wfGetDB( DB_SLAVE );
311 $n = $dbr->selectField( 'archive', 'COUNT(ar_title)',
312 array( 'ar_namespace' => $this->title->getNamespace(),
313 'ar_title' => $this->title->getDBkey() ) );
314 return ($n > 0);
315 }
316
317 /**
318 * Restore the given (or all) text and file revisions for the page.
319 * Once restored, the items will be removed from the archive tables.
320 * The deletion log will be updated with an undeletion notice.
321 *
322 * @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete.
323 * @param string $comment
324 * @param array $fileVersions
325 * @param bool $unsuppress
326 *
327 * @return array(number of file revisions restored, number of image revisions restored, log message)
328 * on success, false on failure
329 */
330 function undelete( $timestamps, $comment = '', $fileVersions = array(), $unsuppress = false ) {
331 // If both the set of text revisions and file revisions are empty,
332 // restore everything. Otherwise, just restore the requested items.
333 $restoreAll = empty( $timestamps ) && empty( $fileVersions );
334
335 $restoreText = $restoreAll || !empty( $timestamps );
336 $restoreFiles = $restoreAll || !empty( $fileVersions );
337
338 if( $restoreFiles && $this->title->getNamespace() == NS_IMAGE ) {
339 $img = wfLocalFile( $this->title );
340 $this->fileStatus = $img->restore( $fileVersions, $unsuppress );
341 $filesRestored = $this->fileStatus->successCount;
342 } else {
343 $filesRestored = 0;
344 }
345
346 if( $restoreText ) {
347 $textRestored = $this->undeleteRevisions( $timestamps, $unsuppress );
348 if($textRestored === false) // It must be one of UNDELETE_*
349 return false;
350 } else {
351 $textRestored = 0;
352 }
353
354 // Touch the log!
355 global $wgContLang;
356 $log = new LogPage( 'delete' );
357
358 if( $textRestored && $filesRestored ) {
359 $reason = wfMsgExt( 'undeletedrevisions-files', array( 'content', 'parsemag' ),
360 $wgContLang->formatNum( $textRestored ),
361 $wgContLang->formatNum( $filesRestored ) );
362 } elseif( $textRestored ) {
363 $reason = wfMsgExt( 'undeletedrevisions', array( 'content', 'parsemag' ),
364 $wgContLang->formatNum( $textRestored ) );
365 } elseif( $filesRestored ) {
366 $reason = wfMsgExt( 'undeletedfiles', array( 'content', 'parsemag' ),
367 $wgContLang->formatNum( $filesRestored ) );
368 } else {
369 wfDebug( "Undelete: nothing undeleted...\n" );
370 return false;
371 }
372
373 if( trim( $comment ) != '' )
374 $reason .= ": {$comment}";
375 $log->addEntry( 'restore', $this->title, $reason );
376
377 return array($textRestored, $filesRestored, $reason);
378 }
379
380 /**
381 * This is the meaty bit -- restores archived revisions of the given page
382 * to the cur/old tables. If the page currently exists, all revisions will
383 * be stuffed into old, otherwise the most recent will go into cur.
384 *
385 * @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete.
386 * @param string $comment
387 * @param array $fileVersions
388 * @param bool $unsuppress, remove all ar_deleted/fa_deleted restrictions of seletected revs
389 *
390 * @return mixed number of revisions restored or false on failure
391 */
392 private function undeleteRevisions( $timestamps, $unsuppress = false ) {
393 if ( wfReadOnly() )
394 return false;
395 $restoreAll = empty( $timestamps );
396
397 $dbw = wfGetDB( DB_MASTER );
398
399 # Does this page already exist? We'll have to update it...
400 $article = new Article( $this->title );
401 $options = 'FOR UPDATE';
402 $page = $dbw->selectRow( 'page',
403 array( 'page_id', 'page_latest' ),
404 array( 'page_namespace' => $this->title->getNamespace(),
405 'page_title' => $this->title->getDBkey() ),
406 __METHOD__,
407 $options );
408 if( $page ) {
409 $makepage = false;
410 # Page already exists. Import the history, and if necessary
411 # we'll update the latest revision field in the record.
412 $newid = 0;
413 $pageId = $page->page_id;
414 $previousRevId = $page->page_latest;
415 # Get the time span of this page
416 $previousTimestamp = $dbw->selectField( 'revision', 'rev_timestamp',
417 array( 'rev_id' => $previousRevId ),
418 __METHOD__ );
419 if( $previousTimestamp === false ) {
420 wfDebug( __METHOD__.": existing page refers to a page_latest that does not exist\n" );
421 return 0;
422 }
423 } else {
424 # Have to create a new article...
425 $makepage = true;
426 $previousRevId = 0;
427 $previousTimestamp = 0;
428 }
429
430 if( $restoreAll ) {
431 $oldones = '1 = 1'; # All revisions...
432 } else {
433 $oldts = implode( ',',
434 array_map( array( &$dbw, 'addQuotes' ),
435 array_map( array( &$dbw, 'timestamp' ),
436 $timestamps ) ) );
437
438 $oldones = "ar_timestamp IN ( {$oldts} )";
439 }
440
441 /**
442 * Select each archived revision...
443 */
444 $result = $dbw->select( 'archive',
445 /* fields */ array(
446 'ar_rev_id',
447 'ar_text',
448 'ar_comment',
449 'ar_user',
450 'ar_user_text',
451 'ar_timestamp',
452 'ar_minor_edit',
453 'ar_flags',
454 'ar_text_id',
455 'ar_deleted',
456 'ar_page_id',
457 'ar_len' ),
458 /* WHERE */ array(
459 'ar_namespace' => $this->title->getNamespace(),
460 'ar_title' => $this->title->getDBkey(),
461 $oldones ),
462 __METHOD__,
463 /* options */ array(
464 'ORDER BY' => 'ar_timestamp' )
465 );
466 $ret = $dbw->resultObject( $result );
467
468 $rev_count = $dbw->numRows( $result );
469 if( $rev_count ) {
470 # We need to seek around as just using DESC in the ORDER BY
471 # would leave the revisions inserted in the wrong order
472 $first = $ret->fetchObject();
473 $ret->seek( $rev_count - 1 );
474 $last = $ret->fetchObject();
475 // We don't handle well changing the top revision's settings
476 if( !$unsuppress && $last->ar_deleted && $last->ar_timestamp > $previousTimestamp ) {
477 wfDebug( __METHOD__.": restoration would result in a deleted top revision\n" );
478 return false;
479 }
480 $ret->seek( 0 );
481 }
482
483 if( $makepage ) {
484 $newid = $article->insertOn( $dbw );
485 $pageId = $newid;
486 }
487
488 $revision = null;
489 $restored = 0;
490
491 while( $row = $ret->fetchObject() ) {
492 if( $row->ar_text_id ) {
493 // Revision was deleted in 1.5+; text is in
494 // the regular text table, use the reference.
495 // Specify null here so the so the text is
496 // dereferenced for page length info if needed.
497 $revText = null;
498 } else {
499 // Revision was deleted in 1.4 or earlier.
500 // Text is squashed into the archive row, and
501 // a new text table entry will be created for it.
502 $revText = Revision::getRevisionText( $row, 'ar_' );
503 }
504 $revision = new Revision( array(
505 'page' => $pageId,
506 'id' => $row->ar_rev_id,
507 'text' => $revText,
508 'comment' => $row->ar_comment,
509 'user' => $row->ar_user,
510 'user_text' => $row->ar_user_text,
511 'timestamp' => $row->ar_timestamp,
512 'minor_edit' => $row->ar_minor_edit,
513 'text_id' => $row->ar_text_id,
514 'deleted' => $unsuppress ? 0 : $row->ar_deleted,
515 'len' => $row->ar_len
516 ) );
517 $revision->insertOn( $dbw );
518 $restored++;
519
520 wfRunHooks( 'ArticleRevisionUndeleted', array( &$this->title, $revision, $row->ar_page_id ) );
521 }
522 // Was anything restored at all?
523 if($restored == 0)
524 return 0;
525
526 if( $revision ) {
527 // Attach the latest revision to the page...
528 $wasnew = $article->updateIfNewerOn( $dbw, $revision, $previousRevId );
529
530 if( $newid || $wasnew ) {
531 // Update site stats, link tables, etc
532 $article->createUpdates( $revision );
533 }
534
535 if( $newid ) {
536 wfRunHooks( 'ArticleUndelete', array( &$this->title, true ) );
537 Article::onArticleCreate( $this->title );
538 } else {
539 wfRunHooks( 'ArticleUndelete', array( &$this->title, false ) );
540 Article::onArticleEdit( $this->title );
541 }
542
543 if( $this->title->getNamespace() == NS_IMAGE ) {
544 $update = new HTMLCacheUpdate( $this->title, 'imagelinks' );
545 $update->doUpdate();
546 }
547 } else {
548 // Revision couldn't be created. This is very weird
549 return self::UNDELETE_UNKNOWNERR;
550 }
551
552 # Now that it's safely stored, take it out of the archive
553 $dbw->delete( 'archive',
554 /* WHERE */ array(
555 'ar_namespace' => $this->title->getNamespace(),
556 'ar_title' => $this->title->getDBkey(),
557 $oldones ),
558 __METHOD__ );
559
560 return $restored;
561 }
562
563 function getFileStatus() { return $this->fileStatus; }
564 }
565
566 /**
567 * The HTML form for Special:Undelete, which allows users with the appropriate
568 * permissions to view and restore deleted content.
569 * @addtogroup SpecialPage
570 */
571 class UndeleteForm {
572 var $mAction, $mTarget, $mTimestamp, $mRestore, $mTargetObj;
573 var $mTargetTimestamp, $mAllowed, $mComment;
574
575 function UndeleteForm( $request, $par = "" ) {
576 global $wgUser;
577 $this->mAction = $request->getVal( 'action' );
578 $this->mTarget = $request->getVal( 'target' );
579 $this->mSearchPrefix = $request->getText( 'prefix' );
580 $time = $request->getVal( 'timestamp' );
581 $this->mTimestamp = $time ? wfTimestamp( TS_MW, $time ) : '';
582 $this->mFile = $request->getVal( 'file' );
583
584 $posted = $request->wasPosted() &&
585 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
586 $this->mRestore = $request->getCheck( 'restore' ) && $posted;
587 $this->mPreview = $request->getCheck( 'preview' ) && $posted;
588 $this->mDiff = $request->getCheck( 'diff' );
589 $this->mComment = $request->getText( 'wpComment' );
590 $this->mUnsuppress = $request->getVal( 'wpUnsuppress' ) && $wgUser->isAllowed( 'oversight' );
591
592 if( $par != "" ) {
593 $this->mTarget = $par;
594 }
595 if ( $wgUser->isAllowed( 'undelete' ) && !$wgUser->isBlocked() ) {
596 $this->mAllowed = true;
597 } else {
598 $this->mAllowed = false;
599 $this->mTimestamp = '';
600 $this->mRestore = false;
601 }
602 if ( $this->mTarget !== "" ) {
603 $this->mTargetObj = Title::newFromURL( $this->mTarget );
604 } else {
605 $this->mTargetObj = NULL;
606 }
607 if( $this->mRestore ) {
608 $timestamps = array();
609 $this->mFileVersions = array();
610 foreach( $_REQUEST as $key => $val ) {
611 $matches = array();
612 if( preg_match( '/^ts(\d{14})$/', $key, $matches ) ) {
613 array_push( $timestamps, $matches[1] );
614 }
615
616 if( preg_match( '/^fileid(\d+)$/', $key, $matches ) ) {
617 $this->mFileVersions[] = intval( $matches[1] );
618 }
619 }
620 rsort( $timestamps );
621 $this->mTargetTimestamp = $timestamps;
622 }
623 }
624
625 function execute() {
626 global $wgOut, $wgUser;
627 if ( $this->mAllowed ) {
628 $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
629 } else {
630 $wgOut->setPagetitle( wfMsg( "viewdeletedpage" ) );
631 }
632
633 if( is_null( $this->mTargetObj ) ) {
634 # Not all users can just browse every deleted page from the list
635 if( $wgUser->isAllowed( 'browsearchive' ) ) {
636 $this->showSearchForm();
637
638 # List undeletable articles
639 if( $this->mSearchPrefix ) {
640 $result = PageArchive::listPagesByPrefix( $this->mSearchPrefix );
641 $this->showList( $result );
642 }
643 } else {
644 $wgOut->addWikiText( wfMsgHtml( 'undelete-header' ) );
645 }
646 return;
647 }
648 if( $this->mTimestamp !== '' ) {
649 return $this->showRevision( $this->mTimestamp );
650 }
651 if( $this->mFile !== null ) {
652 $file = new ArchivedFile( $this->mTargetObj, '', $this->mFile );
653 // Check if user is allowed to see this file
654 if( !$file->userCan( File::DELETED_FILE ) ) {
655 $wgOut->permissionRequired( 'hiderevision' );
656 return false;
657 } else {
658 return $this->showFile( $this->mFile );
659 }
660 }
661 if( $this->mRestore && $this->mAction == "submit" ) {
662 return $this->undelete();
663 }
664 return $this->showHistory();
665 }
666
667 function showSearchForm() {
668 global $wgOut, $wgScript;
669 $wgOut->addWikiMsg( 'undelete-header' );
670
671 $wgOut->addHtml(
672 Xml::openElement( 'form', array(
673 'method' => 'get',
674 'action' => $wgScript ) ) .
675 '<fieldset>' .
676 Xml::element( 'legend', array(),
677 wfMsg( 'undelete-search-box' ) ) .
678 Xml::hidden( 'title',
679 SpecialPage::getTitleFor( 'Undelete' )->getPrefixedDbKey() ) .
680 Xml::inputLabel( wfMsg( 'undelete-search-prefix' ),
681 'prefix', 'prefix', 20,
682 $this->mSearchPrefix ) .
683 Xml::submitButton( wfMsg( 'undelete-search-submit' ) ) .
684 '</fieldset>' .
685 '</form>' );
686 }
687
688 // Generic list of deleted pages
689 private function showList( $result ) {
690 global $wgLang, $wgContLang, $wgUser, $wgOut;
691
692 if( $result->numRows() == 0 ) {
693 $wgOut->addWikiMsg( 'undelete-no-results' );
694 return;
695 }
696
697 $wgOut->addWikiMsg( "undeletepagetext" );
698
699 $sk = $wgUser->getSkin();
700 $undelete = SpecialPage::getTitleFor( 'Undelete' );
701 $wgOut->addHTML( "<ul>\n" );
702 while( $row = $result->fetchObject() ) {
703 $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
704 $link = $sk->makeKnownLinkObj( $undelete, htmlspecialchars( $title->getPrefixedText() ),
705 'target=' . $title->getPrefixedUrl() );
706 #$revs = wfMsgHtml( 'undeleterevisions', $wgLang->formatNum( $row->count ) );
707 $revs = wfMsgExt( 'undeleterevisions',
708 array( 'parseinline' ),
709 $wgLang->formatNum( $row->count ) );
710 $wgOut->addHtml( "<li>{$link} ({$revs})</li>\n" );
711 }
712 $result->free();
713 $wgOut->addHTML( "</ul>\n" );
714
715 return true;
716 }
717
718 private function showRevision( $timestamp ) {
719 global $wgLang, $wgUser, $wgOut;
720 $self = SpecialPage::getTitleFor( 'Undelete' );
721 $skin = $wgUser->getSkin();
722
723 if(!preg_match("/[0-9]{14}/",$timestamp)) return 0;
724
725 $archive = new PageArchive( $this->mTargetObj );
726 $rev = $archive->getRevision( $timestamp );
727
728 if( !$rev ) {
729 $wgOut->addWikiMsg( 'undeleterevision-missing' );
730 return;
731 }
732
733 if( $rev->isDeleted(Revision::DELETED_TEXT) ) {
734 if( !$rev->userCan(Revision::DELETED_TEXT) ) {
735 $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) );
736 return;
737 } else {
738 $wgOut->addWikiText( wfMsg( 'rev-deleted-text-view' ) );
739 $wgOut->addHTML( '<br/>' );
740 // and we are allowed to see...
741 }
742 }
743
744 $wgOut->setPageTitle( wfMsg( 'undeletepage' ) );
745
746 $link = $skin->makeKnownLinkObj(
747 SpecialPage::getTitleFor( 'Undelete', $this->mTargetObj->getPrefixedDBkey() ),
748 htmlspecialchars( $this->mTargetObj->getPrefixedText() )
749 );
750 $time = htmlspecialchars( $wgLang->timeAndDate( $timestamp, true ) );
751 $user = $skin->revUserTools( $rev );
752
753 if( $this->mDiff ) {
754 $previousRev = $archive->getPreviousRevision( $timestamp );
755 if( $previousRev ) {
756 $this->showDiff( $previousRev, $rev );
757 if( $wgUser->getOption( 'diffonly' ) ) {
758 return;
759 } else {
760 $wgOut->addHtml( '<hr />' );
761 }
762 } else {
763 $wgOut->addHtml( wfMsgHtml( 'undelete-nodiff' ) );
764 }
765 }
766
767 $wgOut->addHtml( '<p>' . wfMsgHtml( 'undelete-revision', $link, $time, $user ) . '</p>' );
768
769 wfRunHooks( 'UndeleteShowRevision', array( $this->mTargetObj, $rev ) );
770
771 if( $this->mPreview ) {
772 $wgOut->addHtml( "<hr />\n" );
773 $wgOut->addWikiTextTitleTidy( $rev->revText(), $this->mTargetObj, false );
774 }
775
776 $wgOut->addHtml(
777 wfElement( 'textarea', array(
778 'readonly' => 'readonly',
779 'cols' => intval( $wgUser->getOption( 'cols' ) ),
780 'rows' => intval( $wgUser->getOption( 'rows' ) ) ),
781 $rev->revText() . "\n" ) .
782 wfOpenElement( 'div' ) .
783 wfOpenElement( 'form', array(
784 'method' => 'post',
785 'action' => $self->getLocalURL( "action=submit" ) ) ) .
786 wfElement( 'input', array(
787 'type' => 'hidden',
788 'name' => 'target',
789 'value' => $this->mTargetObj->getPrefixedDbKey() ) ) .
790 wfElement( 'input', array(
791 'type' => 'hidden',
792 'name' => 'timestamp',
793 'value' => $timestamp ) ) .
794 wfElement( 'input', array(
795 'type' => 'hidden',
796 'name' => 'wpEditToken',
797 'value' => $wgUser->editToken() ) ) .
798 wfElement( 'input', array(
799 'type' => 'submit',
800 'name' => 'preview',
801 'value' => wfMsg( 'showpreview' ) ) ) .
802 wfElement( 'input', array(
803 'name' => 'diff',
804 'type' => 'submit',
805 'value' => wfMsg( 'showdiff' ) ) ) .
806 wfCloseElement( 'form' ) .
807 wfCloseElement( 'div' ) );
808 }
809
810 /**
811 * Build a diff display between this and the previous either deleted
812 * or non-deleted edit.
813 * @param Revision $previousRev
814 * @param Revision $currentRev
815 * @return string HTML
816 */
817 function showDiff( $previousRev, $currentRev ) {
818 global $wgOut, $wgUser;
819
820 $diffEngine = new DifferenceEngine();
821 $diffEngine->showDiffStyle();
822 $wgOut->addHtml(
823 "<div>" .
824 "<table border='0' width='98%' cellpadding='0' cellspacing='4' class='diff'>" .
825 "<col class='diff-marker' />" .
826 "<col class='diff-content' />" .
827 "<col class='diff-marker' />" .
828 "<col class='diff-content' />" .
829 "<tr>" .
830 "<td colspan='2' width='50%' align='center' class='diff-otitle'>" .
831 $this->diffHeader( $previousRev ) .
832 "</td>" .
833 "<td colspan='2' width='50%' align='center' class='diff-ntitle'>" .
834 $this->diffHeader( $currentRev ) .
835 "</td>" .
836 "</tr>" .
837 $diffEngine->generateDiffBody(
838 $previousRev->getText(), $currentRev->getText() ) .
839 "</table>" .
840 "</div>\n" );
841
842 }
843
844 private function diffHeader( $rev ) {
845 global $wgUser, $wgLang, $wgLang;
846 $sk = $wgUser->getSkin();
847 $isDeleted = !( $rev->getId() && $rev->getTitle() );
848 if( $isDeleted ) {
849 /// @fixme $rev->getTitle() is null for deleted revs...?
850 $targetPage = SpecialPage::getTitleFor( 'Undelete' );
851 $targetQuery = 'target=' .
852 $this->mTargetObj->getPrefixedUrl() .
853 '&timestamp=' .
854 wfTimestamp( TS_MW, $rev->getTimestamp() );
855 } else {
856 /// @fixme getId() may return non-zero for deleted revs...
857 $targetPage = $rev->getTitle();
858 $targetQuery = 'oldid=' . $rev->getId();
859 }
860 return
861 '<div id="mw-diff-otitle1"><strong>' .
862 $sk->makeLinkObj( $targetPage,
863 wfMsgHtml( 'revisionasof',
864 $wgLang->timeanddate( $rev->getTimestamp(), true ) ),
865 $targetQuery ) .
866 ( $isDeleted ? ' ' . wfMsgHtml( 'deletedrev' ) : '' ) .
867 '</strong></div>' .
868 '<div id="mw-diff-otitle2">' .
869 $sk->revUserTools( $rev ) . '<br/>' .
870 '</div>' .
871 '<div id="mw-diff-otitle3">' .
872 $sk->revComment( $rev ) . '<br/>' .
873 '</div>';
874 }
875
876 /**
877 * Show a deleted file version requested by the visitor.
878 */
879 private function showFile( $key ) {
880 global $wgOut, $wgRequest;
881 $wgOut->disable();
882
883 # We mustn't allow the output to be Squid cached, otherwise
884 # if an admin previews a deleted image, and it's cached, then
885 # a user without appropriate permissions can toddle off and
886 # nab the image, and Squid will serve it
887 $wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
888 $wgRequest->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
889 $wgRequest->response()->header( 'Pragma: no-cache' );
890
891 $store = FileStore::get( 'deleted' );
892 $store->stream( $key );
893 }
894
895 private function showHistory() {
896 global $wgLang, $wgContLang, $wgUser, $wgOut;
897
898 $sk = $wgUser->getSkin();
899 if( $this->mAllowed ) {
900 $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
901 } else {
902 $wgOut->setPagetitle( wfMsg( 'viewdeletedpage' ) );
903 }
904
905 $wgOut->addWikiText( wfMsgHtml( 'undeletepagetitle', $this->mTargetObj->getPrefixedText()) );
906
907 $archive = new PageArchive( $this->mTargetObj );
908 /*
909 $text = $archive->getLastRevisionText();
910 if( is_null( $text ) ) {
911 $wgOut->addWikiMsg( "nohistory" );
912 return;
913 }
914 */
915 if ( $this->mAllowed ) {
916 $wgOut->addWikiMsg( "undeletehistory" );
917 $wgOut->addWikiMsg( "undeleterevdel" );
918 } else {
919 $wgOut->addWikiMsg( "undeletehistorynoadmin" );
920 }
921
922 # List all stored revisions
923 $revisions = $archive->listRevisions();
924 $files = $archive->listFiles();
925
926 $haveRevisions = $revisions && $revisions->numRows() > 0;
927 $haveFiles = $files && $files->numRows() > 0;
928
929 # Batch existence check on user and talk pages
930 if( $haveRevisions ) {
931 $batch = new LinkBatch();
932 while( $row = $revisions->fetchObject() ) {
933 $batch->addObj( Title::makeTitleSafe( NS_USER, $row->ar_user_text ) );
934 $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->ar_user_text ) );
935 }
936 $batch->execute();
937 $revisions->seek( 0 );
938 }
939 if( $haveFiles ) {
940 $batch = new LinkBatch();
941 while( $row = $files->fetchObject() ) {
942 $batch->addObj( Title::makeTitleSafe( NS_USER, $row->fa_user_text ) );
943 $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->fa_user_text ) );
944 }
945 $batch->execute();
946 $files->seek( 0 );
947 }
948
949 if ( $this->mAllowed ) {
950 $titleObj = SpecialPage::getTitleFor( "Undelete" );
951 $action = $titleObj->getLocalURL( "action=submit" );
952 # Start the form here
953 $top = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'undelete' ) );
954 $wgOut->addHtml( $top );
955 }
956
957 # Show relevant lines from the deletion log:
958 $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) . "\n" );
959 $logViewer = new LogViewer(
960 new LogReader(
961 new FauxRequest(
962 array(
963 'page' => $this->mTargetObj->getPrefixedText(),
964 'type' => 'delete'
965 )
966 )
967 ), LogViewer::NO_ACTION_LINK
968 );
969 $logViewer->showList( $wgOut );
970
971 if( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) {
972 # Format the user-visible controls (comment field, submission button)
973 # in a nice little table
974 $align = $wgContLang->isRtl() ? 'left' : 'right';
975 $table =
976 Xml::openElement( 'fieldset' ) .
977 Xml::element( 'legend', null, wfMsg( 'undelete') ).
978 Xml::openElement( 'table', array( 'id' => 'mw-undelete-table' ) ) .
979 "<tr>
980 <td colspan='2'>" .
981 wfMsgWikiHtml( 'undeleteextrahelp' ) .
982 "</td>
983 </tr>
984 <tr>
985 <td align='$align'>" .
986 Xml::label( wfMsg( 'undeletecomment' ), 'wpComment' ) .
987 "</td>
988 <td>" .
989 Xml::input( 'wpComment', 50, $this->mComment ) .
990 "</td>
991 </tr>
992 <tr>
993 <td>&nbsp;</td>
994 <td>" .
995 Xml::submitButton( wfMsg( 'undeletebtn' ), array( 'name' => 'restore', 'id' => 'mw-undelete-submit' ) ) .
996 Xml::element( 'input', array( 'type' => 'reset', 'value' => wfMsg( 'undeletereset' ), 'id' => 'mw-undelete-reset' ) ) .
997 "</td>
998 </tr>
999 <tr>
1000 <td>&nbsp;</td>
1001 <td>" .
1002 Xml::check( 'wpUnsuppress', $this->mUnsuppress, array('id' => 'mw-undelete-unsupress') ) . ' ' .
1003 Xml::label( wfMsgHtml('revdelete-unsuppress'), 'mw-undelete-unsupress' ) .
1004 "</td>
1005 </tr>" .
1006 Xml::closeElement( 'table' ) .
1007 Xml::closeElement( 'fieldset' );
1008
1009 $wgOut->addHtml( $table );
1010 }
1011
1012 $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'history' ) ) . "\n" );
1013
1014 if( $haveRevisions ) {
1015 # The page's stored (deleted) history:
1016 $wgOut->addHTML("<ul>");
1017 $target = urlencode( $this->mTarget );
1018 $remaining = $revisions->numRows();
1019 $earliestLiveTime = $this->getEarliestTime( $this->mTargetObj );
1020
1021 while( $row = $revisions->fetchObject() ) {
1022 $remaining--;
1023 $wgOut->addHTML( $this->formatRevisionRow( $row, $earliestLiveTime, $remaining, $sk ) );
1024 }
1025 $revisions->free();
1026 $wgOut->addHTML("</ul>");
1027 } else {
1028 $wgOut->addWikiMsg( "nohistory" );
1029 }
1030
1031 if( $haveFiles ) {
1032 $wgOut->addHtml( Xml::element( 'h2', null, wfMsg( 'filehist' ) ) . "\n" );
1033 $wgOut->addHtml( "<ul>" );
1034 while( $row = $files->fetchObject() ) {
1035 $wgOut->addHTML( $this->formatFileRow( $row, $sk ) );
1036 }
1037 $files->free();
1038 $wgOut->addHTML( "</ul>" );
1039 }
1040
1041 if ( $this->mAllowed ) {
1042 # Slip in the hidden controls here
1043 $misc = Xml::hidden( 'target', $this->mTarget );
1044 $misc .= Xml::hidden( 'wpEditToken', $wgUser->editToken() );
1045 $misc .= Xml::closeElement( 'form' );
1046 $wgOut->addHtml( $misc );
1047 }
1048
1049 return true;
1050 }
1051
1052 private function formatRevisionRow( $row, $earliestLiveTime, $remaining, $sk ) {
1053 global $wgUser, $wgLang;
1054
1055 $rev = new Revision( array(
1056 'page' => $this->mTargetObj->getArticleId(),
1057 'comment' => $row->ar_comment,
1058 'user' => $row->ar_user,
1059 'user_text' => $row->ar_user_text,
1060 'timestamp' => $row->ar_timestamp,
1061 'minor_edit' => $row->ar_minor_edit,
1062 'deleted' => $row->ar_deleted,
1063 'len' => $row->ar_len ) );
1064
1065 $stxt = '';
1066 $ts = wfTimestamp( TS_MW, $row->ar_timestamp );
1067 if( $this->mAllowed ) {
1068 $checkBox = Xml::check( "ts$ts" );
1069 $titleObj = SpecialPage::getTitleFor( "Undelete" );
1070 $pageLink = $this->getPageLink( $rev, $titleObj, $ts, $sk );
1071 # Last link
1072 if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
1073 $last = wfMsgHtml('diff');
1074 } else if( $remaining > 0 || ($earliestLiveTime && $ts > $earliestLiveTime) ) {
1075 $last = $sk->makeKnownLinkObj( $titleObj, wfMsgHtml('diff'),
1076 "target=" . $this->mTargetObj->getPrefixedUrl() . "&timestamp=$ts&diff=prev" );
1077 } else {
1078 $last = wfMsgHtml('diff');
1079 }
1080 } else {
1081 $checkBox = '';
1082 $pageLink = $wgLang->timeanddate( $ts, true );
1083 $last = wfMsgHtml('diff');
1084 }
1085 $userLink = $sk->revUserTools( $rev );
1086
1087 if(!is_null($size = $row->ar_len)) {
1088 if($size == 0)
1089 $stxt = wfMsgHtml('historyempty');
1090 else
1091 $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) );
1092 }
1093 $comment = $sk->revComment( $rev );
1094 $revdlink = '';
1095 if( $wgUser->isAllowed( 'deleterevision' ) ) {
1096 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
1097 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
1098 // If revision was hidden from sysops
1099 $del = wfMsgHtml('rev-delundel');
1100 } else {
1101 $ts = wfTimestamp( TS_MW, $row->ar_timestamp );
1102 $del = $sk->makeKnownLinkObj( $revdel,
1103 wfMsgHtml('rev-delundel'),
1104 'target=' . $this->mTargetObj->getPrefixedUrl() . "&artimestamp=$ts" );
1105 // Bolden oversighted content
1106 if( $rev->isDeleted( Revision::DELETED_RESTRICTED ) )
1107 $del = "<strong>$del</strong>";
1108 }
1109 $revdlink = "<tt>(<small>$del</small>)</tt>";
1110 }
1111
1112 return "<li>$checkBox $revdlink ($last) $pageLink . . $userLink $stxt $comment</li>";
1113 }
1114
1115 private function formatFileRow( $row, $sk ) {
1116 global $wgUser, $wgLang;
1117
1118 $file = ArchivedFile::newFromRow( $row );
1119
1120 $ts = wfTimestamp( TS_MW, $row->fa_timestamp );
1121 if( $this->mAllowed && $row->fa_storage_key ) {
1122 $checkBox = Xml::check( "fileid" . $row->fa_id );
1123 $key = urlencode( $row->fa_storage_key );
1124 $target = urlencode( $this->mTarget );
1125 $titleObj = SpecialPage::getTitleFor( "Undelete" );
1126 $pageLink = $this->getFileLink( $file, $titleObj, $ts, $key, $sk );
1127 } else {
1128 $checkBox = '';
1129 $pageLink = $wgLang->timeanddate( $ts, true );
1130 }
1131 $userLink = $this->getFileUser( $file, $sk );
1132 $data =
1133 wfMsgHtml( 'widthheight',
1134 $wgLang->formatNum( $row->fa_width ),
1135 $wgLang->formatNum( $row->fa_height ) ) .
1136 ' (' .
1137 wfMsgHtml( 'nbytes', $wgLang->formatNum( $row->fa_size ) ) .
1138 ')';
1139 $comment = $this->getFileComment( $file, $sk );
1140 $revdlink = '';
1141 if( $wgUser->isAllowed( 'deleterevision' ) ) {
1142 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
1143 if( !$file->userCan(File::DELETED_RESTRICTED ) ) {
1144 // If revision was hidden from sysops
1145 $del = $this->messages['rev-delundel'];
1146 } else {
1147 $del = $sk->makeKnownLinkObj( $revdel,
1148 wfMsgHtml('rev-delundel'),
1149 'target=' . $this->mTargetObj->getPrefixedUrl() .
1150 '&fileid=' . $row->fa_id );
1151 // Bolden oversighted content
1152 if( $file->isDeleted( File::DELETED_RESTRICTED ) )
1153 $del = "<strong>$del</strong>";
1154 }
1155 $revdlink = "<tt>(<small>$del</small>)</tt>";
1156 }
1157 return "<li>$checkBox $revdlink $pageLink . . $userLink $data $comment</li>\n";
1158 }
1159
1160 private function getEarliestTime( $title ) {
1161 $dbr = wfGetDB( DB_SLAVE );
1162 if( $title->exists() ) {
1163 $min = $dbr->selectField( 'revision',
1164 'MIN(rev_timestamp)',
1165 array( 'rev_page' => $title->getArticleId() ),
1166 __METHOD__ );
1167 return wfTimestampOrNull( TS_MW, $min );
1168 }
1169 return null;
1170 }
1171
1172 /**
1173 * Fetch revision text link if it's available to all users
1174 * @return string
1175 */
1176 function getPageLink( $rev, $titleObj, $ts, $sk ) {
1177 global $wgLang;
1178
1179 if( !$rev->userCan(Revision::DELETED_TEXT) ) {
1180 return '<span class="history-deleted">' . $wgLang->timeanddate( $ts, true ) . '</span>';
1181 } else {
1182 $link = $sk->makeKnownLinkObj( $titleObj, $wgLang->timeanddate( $ts, true ),
1183 "target=".$this->mTargetObj->getPrefixedUrl()."&timestamp=$ts" );
1184 if( $rev->isDeleted(Revision::DELETED_TEXT) )
1185 $link = '<span class="history-deleted">' . $link . '</span>';
1186 return $link;
1187 }
1188 }
1189
1190 /**
1191 * Fetch image view link if it's available to all users
1192 * @return string
1193 */
1194 function getFileLink( $file, $titleObj, $ts, $key, $sk ) {
1195 global $wgLang;
1196
1197 if( !$file->userCan(File::DELETED_FILE) ) {
1198 return '<span class="history-deleted">' . $wgLang->timeanddate( $ts, true ) . '</span>';
1199 } else {
1200 $link = $sk->makeKnownLinkObj( $titleObj, $wgLang->timeanddate( $ts, true ),
1201 "target=".$this->mTargetObj->getPrefixedUrl()."&file=$key" );
1202 if( $file->isDeleted(File::DELETED_FILE) )
1203 $link = '<span class="history-deleted">' . $link . '</span>';
1204 return $link;
1205 }
1206 }
1207
1208 /**
1209 * Fetch file's user id if it's available to this user
1210 * @return string
1211 */
1212 function getFileUser( $file, $sk ) {
1213 if( !$file->userCan(File::DELETED_USER) ) {
1214 return '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
1215 } else {
1216 $link = $sk->userLink( $file->getRawUser(), $file->getRawUserText() ) .
1217 $sk->userToolLinks( $file->getRawUser(), $file->getRawUserText() );
1218 if( $file->isDeleted(File::DELETED_USER) )
1219 $link = '<span class="history-deleted">' . $link . '</span>';
1220 return $link;
1221 }
1222 }
1223
1224 /**
1225 * Fetch file upload comment if it's available to this user
1226 * @return string
1227 */
1228 function getFileComment( $file, $sk ) {
1229 if( !$file->userCan(File::DELETED_COMMENT) ) {
1230 return '<span class="history-deleted"><span class="comment">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span></span>';
1231 } else {
1232 $link = $sk->commentBlock( $file->getRawDescription() );
1233 if( $file->isDeleted(File::DELETED_COMMENT) )
1234 $link = '<span class="history-deleted">' . $link . '</span>';
1235 return $link;
1236 }
1237 }
1238
1239 function undelete() {
1240 global $wgOut, $wgUser;
1241 if ( wfReadOnly() ) {
1242 $wgOut->readOnlyPage();
1243 return;
1244 }
1245 if( !is_null( $this->mTargetObj ) ) {
1246 $archive = new PageArchive( $this->mTargetObj );
1247 $ok = $archive->undelete(
1248 $this->mTargetTimestamp,
1249 $this->mComment,
1250 $this->mFileVersions,
1251 $this->mUnsuppress );
1252
1253 if( is_array($ok) ) {
1254 if ( $ok[1] ) // Undeleted file count
1255 wfRunHooks( 'FileUndeleteComplete', array(
1256 $this->mTargetObj, $this->mFileVersions,
1257 $wgUser, $this->mComment) );
1258
1259 $skin = $wgUser->getSkin();
1260 $link = $skin->makeKnownLinkObj( $this->mTargetObj );
1261 $wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) );
1262 } else {
1263 $wgOut->showFatalError( wfMsg( "cannotundelete" ) );
1264 $wgOut->addHtml( '<p>' . wfMsgHtml( "undeleterevdel" ) . '</p>' );
1265 }
1266
1267 // Show file deletion warnings and errors
1268 $status = $archive->getFileStatus();
1269 if( $status && !$status->isGood() ) {
1270 $wgOut->addWikiText( $status->getWikiText( 'undelete-error-short', 'undelete-error-long' ) );
1271 }
1272 } else {
1273 $wgOut->showFatalError( wfMsg( "cannotundelete" ) );
1274 }
1275 return false;
1276 }
1277 }