44 throw new MWException( __METHOD__ .
' given a null title.' );
48 wfDebug( __METHOD__ .
' did not have a Config object passed to it' );
68 return self::listPages(
$dbr,
'' );
93 'ar_namespace' => $ns,
94 'ar_title' .
$dbr->buildLike( $prefix,
$dbr->anyString() ),
97 return self::listPages(
$dbr, $conds );
111 'count' =>
'COUNT(*)'
116 'GROUP BY' => [
'ar_namespace',
'ar_title' ],
117 'ORDER BY' => [
'ar_namespace',
'ar_title' ],
135 'ar_minor_edit',
'ar_timestamp',
'ar_user',
'ar_user_text',
136 'ar_comment',
'ar_len',
'ar_deleted',
'ar_rev_id',
'ar_sha1',
139 if ( $this->config->get(
'ContentHandlerUseDB' ) ) {
140 $fields[] =
'ar_content_format';
141 $fields[] =
'ar_content_model';
144 $conds = [
'ar_namespace' => $this->
title->getNamespace(),
145 'ar_title' => $this->
title->getDBkey() ];
147 $options = [
'ORDER BY' =>
'ar_timestamp DESC' ];
186 [
'fa_name' => $this->
title->getDBkey() ],
188 [
'ORDER BY' =>
'fa_timestamp DESC' ]
217 if ( $this->config->get(
'ContentHandlerUseDB' ) ) {
218 $fields[] =
'ar_content_format';
219 $fields[] =
'ar_content_model';
222 $row =
$dbr->selectRow(
'archive',
224 [
'ar_namespace' => $this->
title->getNamespace(),
225 'ar_title' => $this->
title->getDBkey(),
250 $row =
$dbr->selectRow(
'archive',
252 [
'ar_namespace' => $this->
title->getNamespace(),
253 'ar_title' => $this->
title->getDBkey(),
258 'ORDER BY' =>
'ar_timestamp DESC',
262 $row =
$dbr->selectRow( [
'page',
'revision' ],
263 [
'rev_id',
'rev_timestamp' ],
265 'page_namespace' => $this->
title->getNamespace(),
266 'page_title' => $this->
title->getDBkey(),
267 'page_id = rev_page',
272 'ORDER BY' =>
'rev_timestamp DESC',
275 $prevLiveId = $row ? intval( $row->rev_id ) : null;
277 if ( $prevLive && $prevLive > $prevDeleted ) {
280 } elseif ( $prevDeleted ) {
296 if ( is_null( $row->ar_text_id ) ) {
304 $text =
$dbr->selectRow(
'text',
305 [
'old_text',
'old_flags' ],
306 [
'old_id' => $row->ar_text_id ],
322 $row =
$dbr->selectRow(
'archive',
323 [
'ar_text',
'ar_flags',
'ar_text_id' ],
324 [
'ar_namespace' => $this->
title->getNamespace(),
325 'ar_title' => $this->
title->getDBkey() ],
327 [
'ORDER BY' =>
'ar_timestamp DESC' ] );
343 $n =
$dbr->selectField(
'archive',
'COUNT(ar_title)',
344 [
'ar_namespace' => $this->
title->getNamespace(),
345 'ar_title' => $this->
title->getDBkey() ],
372 $unsuppress =
false,
User $user = null, $tags = null
376 $restoreAll = empty( $timestamps ) && empty( $fileVersions );
378 $restoreText = $restoreAll || !empty( $timestamps );
379 $restoreFiles = $restoreAll || !empty( $fileVersions );
381 if ( $restoreFiles && $this->
title->getNamespace() ==
NS_FILE ) {
383 $img->load( File::READ_LATEST );
384 $this->fileStatus = $img->restore( $fileVersions, $unsuppress );
385 if ( !$this->fileStatus->isOK() ) {
388 $filesRestored = $this->fileStatus->successCount;
393 if ( $restoreText ) {
395 if ( !$this->revisionStatus->isOK() ) {
399 $textRestored = $this->revisionStatus->getValue();
406 if ( $textRestored && $filesRestored ) {
407 $reason =
wfMessage(
'undeletedrevisions-files' )
408 ->numParams( $textRestored, $filesRestored )->inContentLanguage()->text();
409 } elseif ( $textRestored ) {
410 $reason =
wfMessage(
'undeletedrevisions' )->numParams( $textRestored )
411 ->inContentLanguage()->text();
412 } elseif ( $filesRestored ) {
413 $reason =
wfMessage(
'undeletedfiles' )->numParams( $filesRestored )
414 ->inContentLanguage()->text();
416 wfDebug(
"Undelete: nothing undeleted...\n" );
422 $reason .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() .
$comment;
425 if (
$user === null ) {
431 $logEntry->setPerformer(
$user );
432 $logEntry->setTarget( $this->
title );
433 $logEntry->setComment( $reason );
434 $logEntry->setTags( $tags );
438 $logid = $logEntry->insert();
439 $logEntry->publish( $logid );
441 return [ $textRestored, $filesRestored, $reason ];
461 $dbw->startAtomic( __METHOD__ );
463 $restoreAll = empty( $timestamps );
465 # Does this page already exist? We'll have to update it...
467 # Load latest data for the current page (bug 31179)
468 $article->loadPageData(
'fromdbmaster' );
469 $oldcountable =
$article->isCountable();
471 $page = $dbw->selectRow(
'page',
472 [
'page_id',
'page_latest' ],
473 [
'page_namespace' => $this->
title->getNamespace(),
474 'page_title' => $this->
title->getDBkey() ],
481 # Page already exists. Import the history, and if necessary
482 # we'll update the latest revision field in the record.
484 # Get the time span of this page
485 $previousTimestamp = $dbw->selectField(
'revision',
'rev_timestamp',
486 [
'rev_id' =>
$page->page_latest ],
489 if ( $previousTimestamp ===
false ) {
490 wfDebug( __METHOD__ .
": existing page refers to a page_latest that does not exist\n" );
493 $status->warning(
'undeleterevision-missing' );
494 $dbw->endAtomic( __METHOD__ );
499 # Have to create a new article...
501 $previousTimestamp = 0;
505 'ar_namespace' => $this->
title->getNamespace(),
506 'ar_title' => $this->
title->getDBkey(),
508 if ( !$restoreAll ) {
509 $oldWhere[
'ar_timestamp'] = array_map( [ &$dbw,
'timestamp' ], $timestamps );
530 if ( $this->config->get(
'ContentHandlerUseDB' ) ) {
531 $fields[] =
'ar_content_format';
532 $fields[] =
'ar_content_model';
539 [
'archive',
'revision' ],
544 [
'ORDER BY' =>
'ar_timestamp' ],
545 [
'revision' => [
'LEFT JOIN',
'ar_rev_id=rev_id' ] ]
548 $rev_count =
$result->numRows();
550 wfDebug( __METHOD__ .
": no revisions to restore\n" );
553 $status->warning(
"undelete-no-results" );
554 $dbw->endAtomic( __METHOD__ );
561 $restoreFailedArIds = [];
568 $allowedRevIdToArIdMap = [];
570 $latestRestorableRow = null;
573 if ( $row->ar_rev_id ) {
575 if ( $row->ar_rev_id === $row->rev_id ) {
576 $restoreFailedArIds[] = $row->ar_id;
577 $allowedRevIdToArIdMap[$row->ar_rev_id] = -1;
582 if ( isset( $allowedRevIdToArIdMap[$row->ar_rev_id] ) ) {
583 $restoreFailedArIds[] = $row->ar_id;
585 $allowedRevIdToArIdMap[$row->ar_rev_id] = $row->ar_id;
586 $latestRestorableRow = $row;
592 $latestRestorableRow = $row;
599 if ( $latestRestorableRow !== null ) {
600 $oldPageId = (int)$latestRestorableRow->ar_page_id;
614 $dbw->endAtomic( __METHOD__ );
626 if ( $latestRestorableRow === null ) {
627 $failedRevisionCount = $rev_count;
634 $dbw->endAtomic( __METHOD__ );
639 $newid =
$article->insertOn( $dbw, $latestRestorableRow->ar_page_id );
640 if ( $newid ===
false ) {
642 $newid =
$article->insertOn( $dbw );
647 if ( $latestRestorableRow->ar_timestamp > $previousTimestamp ) {
652 $dbw->endAtomic( __METHOD__ );
664 if ( $row->ar_rev_id && $allowedRevIdToArIdMap[$row->ar_rev_id] !== $row->ar_id ) {
672 'title' => $this->
title,
673 'deleted' => $unsuppress ? 0 : $row->ar_deleted
676 $revision->insertOn( $dbw );
680 [ &$this->
title, $revision, $row->ar_page_id ] );
685 $toDeleteConds = $oldWhere;
686 $failedRevisionCount = count( $restoreFailedArIds );
687 if ( $failedRevisionCount > 0 ) {
688 $toDeleteConds[] =
'ar_id NOT IN ( ' . $dbw->makeList( $restoreFailedArIds ) .
' )';
691 $dbw->delete(
'archive',
698 if ( $failedRevisionCount > 0 ) {
700 wfMessage(
'undeleterevision-duplicate-revid', $failedRevisionCount ) );
705 $created = (bool)$newid;
707 $wasnew =
$article->updateIfNewerOn( $dbw, $revision );
708 if ( $created || $wasnew ) {
714 'created' => $created,
715 'oldcountable' => $oldcountable,
727 $dbw->endAtomic( __METHOD__ );
771 parent::__construct(
'Undelete',
'deletedhistory' );
782 $this->mAction =
$request->getVal(
'action' );
783 if ( $par !== null && $par !==
'' ) {
784 $this->mTarget = $par;
786 $this->mTarget =
$request->getVal(
'target' );
789 $this->mTargetObj = null;
791 if ( $this->mTarget !== null && $this->mTarget !==
'' ) {
795 $this->mSearchPrefix =
$request->getText(
'prefix' );
798 $this->mFilename =
$request->getVal(
'file' );
802 $this->mRestore =
$request->getCheck(
'restore' ) && $posted;
803 $this->mRevdel =
$request->getCheck(
'revdel' ) && $posted;
804 $this->mInvert =
$request->getCheck(
'invert' ) && $posted;
805 $this->mPreview =
$request->getCheck(
'preview' ) && $posted;
806 $this->mDiff =
$request->getCheck(
'diff' );
807 $this->mDiffOnly =
$request->getBool(
'diffonly', $this->
getUser()->getOption(
'diffonly' ) );
808 $this->mComment =
$request->getText(
'wpComment' );
809 $this->mUnsuppress =
$request->getVal(
'wpUnsuppress' ) &&
$user->isAllowed(
'suppressrevision' );
810 $this->mToken =
$request->getVal(
'token' );
813 $this->mAllowed =
true;
814 $this->mCanView =
true;
815 } elseif ( $this->
isAllowed(
'deletedtext' ) ) {
816 $this->mAllowed =
false;
817 $this->mCanView =
true;
818 $this->mRestore =
false;
820 $this->mAllowed =
false;
821 $this->mCanView =
false;
822 $this->mTimestamp =
'';
823 $this->mRestore =
false;
826 if ( $this->mRestore || $this->mInvert ) {
828 $this->mFileVersions = [];
829 foreach (
$request->getValues()
as $key => $val ) {
831 if ( preg_match(
'/^ts(\d{14})$/', $key,
$matches ) ) {
832 array_push( $timestamps,
$matches[1] );
835 if ( preg_match(
'/^fileid(\d+)$/', $key,
$matches ) ) {
836 $this->mFileVersions[] = intval(
$matches[1] );
839 rsort( $timestamps );
840 $this->mTargetTimestamp = $timestamps;
854 if ( $this->mTargetObj !== null ) {
855 return $this->mTargetObj->userCan( $permission,
$user );
857 return $user->isAllowed( $permission );
862 return $this->
isAllowed( $this->mRestriction, $user );
878 if ( is_null( $this->mTargetObj ) ) {
879 $out->addWikiMsg(
'undelete-header' );
881 # Not all users can just browse every deleted page from the list
882 if (
$user->isAllowed(
'browsearchive' ) ) {
890 if ( $this->mAllowed ) {
891 $out->setPageTitle( $this->
msg(
'undeletepage' ) );
893 $out->setPageTitle( $this->
msg(
'viewdeletedpage' ) );
896 $this->
getSkin()->setRelevantTitle( $this->mTargetObj );
898 if ( $this->mTimestamp !==
'' ) {
900 } elseif ( $this->mFilename !== null && $this->mTargetObj->inNamespace(
NS_FILE ) ) {
901 $file =
new ArchivedFile( $this->mTargetObj,
'', $this->mFilename );
903 if ( !$file->exists() ) {
904 $out->addWikiMsg(
'filedelete-nofile', $this->mFilename );
911 } elseif ( !
$user->matchEditToken( $this->mToken, $this->mFilename ) ) {
914 $this->
showFile( $this->mFilename );
916 } elseif ( $this->mAction ===
"submit" ) {
917 if ( $this->mRestore ) {
919 } elseif ( $this->mRevdel ) {
937 foreach ( $this->
getRequest()->getValues()
as $key => $val ) {
939 if ( preg_match(
"/^ts(\d{14})$/", $key,
$matches ) ) {
940 $revisions[ $archive->getRevision(
$matches[1] )->getId() ] = 1;
944 "type" =>
"revision",
946 "target" => $this->mTargetObj->getPrefixedText()
954 $out->setPageTitle( $this->
msg(
'undelete-search-title' ) );
961 [
'for' =>
'prefix' ],
962 $this->
msg(
'undelete-search-prefix' )->parse()
967 $this->mSearchPrefix,
968 [
'id' =>
'prefix',
'autofocus' =>
'' ]
975 # List undeletable articles
976 if ( $this->mSearchPrefix ) {
991 if (
$result->numRows() == 0 ) {
992 $out->addWikiMsg(
'undelete-no-results' );
1000 $out->addHTML(
"<ul>\n" );
1006 htmlspecialchars(
$title->getPrefixedText() ),
1008 [
'target' =>
$title->getPrefixedText() ]
1014 [
'class' =>
'mw-invalidtitle' ],
1022 $revs = $this->
msg(
'undeleterevisions' )->numParams( $row->count )->parse();
1023 $out->addHTML(
"<li>{$item} ({$revs})</li>\n" );
1026 $out->addHTML(
"</ul>\n" );
1032 if ( !preg_match(
'/[0-9]{14}/',
$timestamp ) ) {
1037 if ( !
Hooks::run(
'UndeleteForm::showRevision', [ &$archive, $this->mTargetObj ] ) ) {
1046 $out->addWikiMsg(
'undeleterevision-missing' );
1054 "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1056 'rev-suppressed-text-permission' :
'rev-deleted-text-permission'
1063 "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1065 'rev-suppressed-text-view' :
'rev-deleted-text-view'
1067 $out->addHTML(
'<br />' );
1071 if ( $this->mDiff ) {
1072 $previousRev = $archive->getPreviousRevision(
$timestamp );
1073 if ( $previousRev ) {
1075 if ( $this->mDiffOnly ) {
1079 $out->addHTML(
'<hr />' );
1081 $out->addWikiMsg(
'undelete-nodiff' );
1086 $this->
getPageTitle( $this->mTargetObj->getPrefixedDBkey() ),
1087 htmlspecialchars( $this->mTargetObj->getPrefixedText() )
1103 if ( $this->mPreview || $isText ) {
1104 $openDiv =
'<div id="mw-undelete-revision" class="mw-warning">';
1106 $openDiv =
'<div id="mw-undelete-revision">';
1108 $out->addHTML( $openDiv );
1111 if ( !$this->mDiff ) {
1114 $out->addHTML(
"$revdel " );
1118 $out->addHTML( $this->
msg(
'undelete-revision' )->rawParams(
$link )->params(
1119 $time )->rawParams( $userLink )->params( $d,
$t )->parse() .
'</div>' );
1121 if ( !
Hooks::run(
'UndeleteShowRevision', [ $this->mTargetObj,
$rev ] ) ) {
1125 if ( ( $this->mPreview || !$isText ) &&
$content ) {
1129 $popts =
$out->parserOptions();
1130 $popts->setEditSection(
false );
1132 $pout =
$content->getParserOutput( $this->mTargetObj,
$rev->getId(), $popts,
true );
1133 $out->addParserOutput( $pout );
1141 'readonly' =>
'readonly',
1142 'cols' =>
$user->getIntOption(
'cols' ),
1143 'rows' =>
$user->getIntOption(
'rows' )
1150 'name' =>
'preview',
1151 'value' => $this->
msg(
'showpreview' )->
text()
1155 $previewButton =
'';
1161 'value' => $this->
msg(
'showdiff' )->
text() ] );
1166 'style' =>
'clear: both' ] ) .
1169 'action' => $this->
getPageTitle()->getLocalURL( [
'action' =>
'submit' ] ) ] ) .
1173 'value' => $this->mTargetObj->getPrefixedDBkey() ] ) .
1176 'name' =>
'timestamp',
1180 'name' =>
'wpEditToken',
1181 'value' =>
$user->getEditToken() ] ) .
1199 $diffContext->setTitle( $currentRev->getTitle() );
1202 $diffEngine = $currentRev->getContentHandler()->createDifferenceEngine( $diffContext );
1203 $diffEngine->showDiffStyle();
1205 $formattedDiff = $diffEngine->generateContentDiffBody(
1210 $formattedDiff = $diffEngine->addHeader(
1216 $this->
getOutput()->addHTML(
"<div>$formattedDiff</div>\n" );
1225 $isDeleted = !(
$rev->getId() &&
$rev->getTitle() );
1230 'target' => $this->mTargetObj->getPrefixedText(),
1235 $targetPage =
$rev->getTitle();
1236 $targetQuery = [
'oldid' =>
$rev->getId() ];
1253 [
'ts_rev_id' =>
$rev->getId() ],
1260 return '<div id="mw-diff-' . $prefix .
'title1"><strong>' .
1273 '<div id="mw-diff-' . $prefix .
'title2">' .
1276 '<div id="mw-diff-' . $prefix .
'title3">' .
1279 '<div id="mw-diff-' . $prefix .
'title5">' .
1280 $tagSummary[0] .
'<br />' .
1292 $file =
new ArchivedFile( $this->mTargetObj,
'', $this->mFilename );
1293 $out->addWikiMsg(
'undelete-show-file-confirm',
1294 $this->mTargetObj->getText(),
1295 $lang->userDate( $file->getTimestamp(),
$user ),
1296 $lang->userTime( $file->getTimestamp(),
$user ) );
1301 'target' => $this->mTarget,
1303 'token' =>
$user->getEditToken( $key ),
1319 # We mustn't allow the output to be CDN cached, otherwise
1320 # if an admin previews a deleted image, and it's cached, then
1321 # a user without appropriate permissions can toddle off and
1322 # nab the image, and CDN will serve it
1324 $response->header(
'Expires: ' . gmdate(
'D, d M Y H:i:s', 0 ) .
' GMT' );
1325 $response->header(
'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
1326 $response->header(
'Pragma: no-cache' );
1329 $path = $repo->getZonePath(
'deleted' ) .
'/' . $repo->getDeletedHashPath( $key ) . $key;
1330 $repo->streamFile(
$path );
1337 if ( $this->mAllowed ) {
1338 $out->addModules(
'mediawiki.special.undelete' );
1341 "<div class='mw-undelete-pagetitle'>\n$1\n</div>\n",
1342 [
'undeletepagetitle',
wfEscapeWikiText( $this->mTargetObj->getPrefixedText() ) ]
1346 Hooks::run(
'UndeleteForm::showHistory', [ &$archive, $this->mTargetObj ] );
1354 $out->addHTML(
'<div class="mw-undelete-history">' );
1355 if ( $this->mAllowed ) {
1356 $out->addWikiMsg(
'undeletehistory' );
1357 $out->addWikiMsg(
'undeleterevdel' );
1359 $out->addWikiMsg(
'undeletehistorynoadmin' );
1361 $out->addHTML(
'</div>' );
1363 # List all stored revisions
1364 $revisions = $archive->listRevisions();
1365 $files = $archive->listFiles();
1367 $haveRevisions = $revisions && $revisions->numRows() > 0;
1370 # Batch existence check on user and talk pages
1371 if ( $haveRevisions ) {
1373 foreach ( $revisions
as $row ) {
1378 $revisions->seek( 0 );
1390 if ( $this->mAllowed ) {
1391 $action = $this->
getPageTitle()->getLocalURL( [
'action' =>
'submit' ] );
1392 # Start the form here
1395 [
'method' =>
'post',
'action' => $action,
'id' =>
'undelete' ]
1397 $out->addHTML( $top );
1400 # Show relevant lines from the deletion log:
1401 $deleteLogPage =
new LogPage(
'delete' );
1402 $out->addHTML(
Xml::element(
'h2', null, $deleteLogPage->getName()->text() ) .
"\n" );
1404 # Show relevant lines from the suppression log:
1405 $suppressLogPage =
new LogPage(
'suppress' );
1407 $out->addHTML(
Xml::element(
'h2', null, $suppressLogPage->getName()->text() ) .
"\n" );
1411 if ( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) {
1412 # Format the user-visible controls (comment field, submission button)
1413 # in a nice little table
1418 <td class='mw-input'>" .
1420 'wpUnsuppress',
'mw-undelete-unsuppress', $this->mUnsuppress ) .
1424 $unsuppressBox =
'';
1430 <td colspan='2' class='mw-undelete-extrahelp'>" .
1431 $this->
msg(
'undeleteextrahelp' )->parseAsBlock() .
1435 <td class='mw-label'>" .
1438 <td class='mw-input'>" .
1443 [
'id' =>
'wpComment',
'autofocus' =>
'' ]
1449 <td class='mw-submit'>" .
1451 $this->
msg(
'undeletebtn' )->
text(),
1452 [
'name' =>
'restore',
'id' =>
'mw-undelete-submit' ]
1455 $this->
msg(
'undeleteinvert' )->
text(),
1456 [
'name' =>
'invert',
'id' =>
'mw-undelete-invert' ]
1464 $out->addHTML( $table );
1469 if ( $haveRevisions ) {
1470 # Show the page's stored (deleted) history
1478 'class' =>
'deleterevision-log-submit mw-log-deleterevision-button'
1480 $this->
msg(
'showhideselectedversions' )->
text()
1484 $out->addHTML(
'<ul>' );
1485 $remaining = $revisions->numRows();
1486 $earliestLiveTime = $this->mTargetObj->getEarliestRevTime();
1488 foreach ( $revisions
as $row ) {
1493 $out->addHTML(
'</ul>' );
1495 $out->addWikiMsg(
'nohistory' );
1500 $out->addHTML(
'<ul>' );
1505 $out->addHTML(
'</ul>' );
1508 if ( $this->mAllowed ) {
1509 # Slip in the hidden controls here
1513 $out->addHTML( $misc );
1522 'title' => $this->mTargetObj
1528 if ( $this->mAllowed ) {
1529 if ( $this->mInvert ) {
1530 if ( in_array( $ts, $this->mTargetTimestamp ) ) {
1544 if ( $this->mCanView ) {
1548 $pageLink = htmlspecialchars( $this->
getLanguage()->userTimeAndDate( $ts,
$user ) );
1549 $last = $this->
msg(
'diff' )->escaped();
1550 } elseif ( $remaining > 0 || ( $earliestLiveTime && $ts > $earliestLiveTime ) ) {
1554 $this->
msg(
'diff' )->escaped(),
1557 'target' => $this->mTargetObj->getPrefixedText(),
1564 $last = $this->
msg(
'diff' )->escaped();
1567 $pageLink = htmlspecialchars( $this->
getLanguage()->userTimeAndDate( $ts,
$user ) );
1568 $last = $this->
msg(
'diff' )->escaped();
1578 $size = $row->ar_len;
1579 if ( !is_null( $size ) ) {
1594 $attribs[
'class'] = implode(
' ', $classes );
1597 $revisionRow = $this->
msg(
'undelete-revision-row2' )
1619 if ( $this->mCanView && $row->fa_storage_key ) {
1620 if ( $this->mAllowed ) {
1621 $checkBox =
Xml::check(
'fileid' . $row->fa_id );
1623 $key = urlencode( $row->fa_storage_key );
1629 $data = $this->
msg(
'widthheight' )->numParams( $row->fa_width, $row->fa_height )->text();
1630 $bytes = $this->
msg(
'parentheses' )
1631 ->rawParams( $this->
msg(
'nbytes' )->numParams( $row->fa_size )->text() )
1633 $data = htmlspecialchars( $data .
' ' . $bytes );
1637 $canHide = $this->
isAllowed(
'deleterevision' );
1638 if ( $canHide || ( $file->getVisibility() && $this->
isAllowed(
'deletedhistory' ) ) ) {
1644 'type' =>
'filearchive',
1645 'target' => $this->mTargetObj->getPrefixedDBkey(),
1646 'ids' => $row->fa_id
1655 return "<li>$checkBox $revdlink $pageLink . . $userLink $data $comment</li>\n";
1671 return '<span class="history-deleted">' .
$time .
'</span>';
1676 htmlspecialchars(
$time ),
1679 'target' => $this->mTargetObj->getPrefixedText(),
1685 $link =
'<span class="history-deleted">' .
$link .
'</span>';
1706 return '<span class="history-deleted">' .
$time .
'</span>';
1711 htmlspecialchars(
$time ),
1714 'target' => $this->mTargetObj->getPrefixedText(),
1716 'token' =>
$user->getEditToken( $key )
1721 $link =
'<span class="history-deleted">' .
$link .
'</span>';
1735 return '<span class="history-deleted">' .
1736 $this->
msg(
'rev-deleted-user' )->escaped() .
1744 $link =
'<span class="history-deleted">' .
$link .
'</span>';
1758 return '<span class="history-deleted"><span class="comment">' .
1759 $this->
msg(
'rev-deleted-comment' )->escaped() .
'</span></span>';
1765 $link =
'<span class="history-deleted">' .
$link .
'</span>';
1772 if ( $this->
getConfig()->
get(
'UploadMaintenance' )
1773 && $this->mTargetObj->getNamespace() ==
NS_FILE
1775 throw new ErrorPageError(
'undelete-error',
'filedelete-maintenance' );
1782 Hooks::run(
'UndeleteForm::undelete', [ &$archive, $this->mTargetObj ] );
1783 $ok = $archive->undelete(
1784 $this->mTargetTimestamp,
1786 $this->mFileVersions,
1791 if ( is_array( $ok ) ) {
1794 $this->mTargetObj, $this->mFileVersions,
1795 $this->
getUser(), $this->mComment ] );
1799 $out->addHTML( $this->
msg(
'undeletedpage' )->rawParams(
$link )->parse() );
1801 $out->setPageTitle( $this->
msg(
'undelete-error' ) );
1805 $status = $archive->getRevisionStatus();
1807 $out->addWikiText(
'<div class="error">' .
1816 $status = $archive->getFileStatus();
1818 $out->addWikiText(
'<div class="error">' .
1820 'undelete-error-short',
1821 'undelete-error-long'
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
getTextFromRow($row)
Get the text from an archive row containing ar_text, ar_flags and ar_text_id.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
static revComment(Revision $rev, $local=false, $isPublic=false)
Wrap and format the given revision's comment block, if the current user is allowed to view it...
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
static getRevisionText($row, $prefix= 'old_', $wiki=false)
Get revision text associated with an old or archive row $row is usually an object from wfFetchRow()...
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
getFileComment($file)
Fetch file upload comment if it's available to this user.
getContext()
Gets the context this SpecialPage is executed in.
wfScript($script= 'index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
static getRevDeleteLink(User $user, Revision $rev, Title $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
showDiff($previousRev, $currentRev)
Build a diff display between this and the previous either deleted or non-deleted edit.
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
processing should stop and the error should be shown to the user * false
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name If you don't need a full Title object...
diffHeader($rev, $prefix)
static newFatal($message)
Factory function for fatal errors.
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
if(!isset($args[0])) $lang
static formatRevisionSize($size)
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
showFile($key)
Show a deleted file version requested by the visitor.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
static input($name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
getPreviousRevision($timestamp)
Return the most-previous revision, either live or deleted, against the deleted revision given by time...
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
static check($name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
this hook is for auditing only $response
when a variable name is used in a it is silently declared as a new local masking the global
wfLocalFile($title)
Get an object referring to a locally registered file.
listRevisions()
List the revisions of the given page.
static submitButton($value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
addHelpLink($to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
static label($label, $id, $attribs=[])
Convenience function to build an HTML form label.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED!Use HtmlPageLinkRendererBegin instead.Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
showList($result)
Generic list of deleted pages.
Class to simplify the use of log pages.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
formatRevisionRow($row, $earliestLiveTime, $remaining)
Class representing a list of titles The execute() method checks them all for existence and adds them ...
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
showFileConfirmationForm($key)
Show a form confirming whether a tokenless user really wants to see a file.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
static fieldset($legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
static closeElement($element)
Shortcut to close an XML element.
redirectToRevDel()
Convert submitted form data to format expected by RevisionDelete and redirect the request...
Class representing a row of the 'filearchive' table.
Parent class for all special pages.
undelete($timestamps, $comment= '', $fileVersions=[], $unsuppress=false, User $user=null, $tags=null)
Restore the given (or all) text and file revisions for the page.
static listPages($dbr, $condition)
listFiles()
List the deleted file revisions for this page, if it's a file page.
Content object implementation for representing flat text.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
wfReadOnly()
Check whether the wiki is in read-only mode.
getPageLink($rev, $titleObj, $ts)
Fetch revision text link if it's available to all users.
isAllowed($permission, User $user=null)
Checks whether a user is allowed the permission for the specific title if one is set.
An error page which can definitely be safely rendered using the OutputPage.
Class to invalidate the HTML cache of all the pages linking to a given title.
getDBkey()
Get the main part with underscores.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
static selectFields()
Fields in the filearchive table.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
getFileUser($file)
Fetch file's user id if it's available to this user.
static singleton()
Get a RepoGroup instance.
isDeleted()
Quick check if any archived revisions are present for the page.
static openElement($element, $attribs=null)
This opens an XML element.
getFileLink($file, $titleObj, $ts, $key)
Fetch image view link if it's available to all users.
static revDeleteLinkDisabled($delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
getSkin()
Shortcut to get the skin being used for this instance.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static listAllPages()
List all deleted pages recorded in the archive table.
namespace and then decline to actually register it file or subcat img or subcat $title
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
static newGood($value=null)
Factory function for good results.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getNamespace()
Get the namespace index, i.e.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
static newFromRow($row)
Loads a file object from the filearchive table.
prefixSearchSubpages($search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static getDefaultInstance()
static newFromId($id, $flags=0)
Load a page revision from a given revision ID number.
static userLink($userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
Special page allowing users with the appropriate permissions to view and restore deleted content...
Class for creating log entries manually, to inject them into the database.
error also a ContextSource you ll probably need to make sure the header is varied on $request
userCanExecute(User $user)
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getLastRevisionText()
Fetch (and decompress if necessary) the stored text of the most recently edited deleted revision of t...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
getUser()
Shortcut to get the User executing this instance.
getConfig()
Shortcut to get main config object.
Show an error when a user tries to do something they do not have the necessary permissions for...
Used to show archived pages and eventually restore them.
static userToolLinks($userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
getLanguage()
Shortcut to get user's language.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
getRevision($timestamp)
Return a Revision object containing data for the deleted revision.
static listPagesByPrefix($prefix)
List deleted pages recorded in the archive table matching the given title prefix. ...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
static flag($flag, IContextSource $context=null)
Make an "
" element for a given change flag.
static checkLabel($label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
getRequest()
Get the WebRequest being used for this instance.
static commentBlock($comment, $title=null, $local=false, $wikiId=null)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
undeleteRevisions($timestamps, $unsuppress=false, $comment= '')
This is the meaty bit – It restores archived revisions of the given page to the revision table...
prefixSearchString($search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
static newFromArchiveRow($row, $overrides=[])
Make a fake revision object from an archive table row.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
static revUserTools($rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static revDeleteLink($query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
__construct($title, Config $config=null)
see documentation in includes Linker php for Linker::makeImageLink & $time
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
getPageTitle($subpage=false)
Get a self-referential title object.