84 $this->mOldId = $oldId;
85 $this->mPage = $this->
newPage( $title );
102 $t = Title::newFromID( $id );
103 return $t ==
null ? null :
new static(
$t );
122 switch (
$title->getNamespace() ) {
166 $this->mRedirectedFrom = $from;
175 return $this->mPage->getTitle();
192 $this->mContentLoaded =
false;
194 $this->mRedirectedFrom =
null; #
Title object if set
195 $this->mRevIdFetched = 0;
196 $this->mRedirectUrl =
false;
198 $this->mPage->clear();
217 if ( $this->mPage->getId() === 0 ) {
218 # If this is a MediaWiki:x message, then load the messages
219 # and return the message value for x.
221 $text = $this->
getTitle()->getDefaultMessageText();
222 if ( $text ===
false ) {
228 $message = $this->
getContext()->getUser()->isLoggedIn() ?
'noarticletext' :
'noarticletextanon';
243 if ( is_null( $this->mOldId ) ) {
256 $this->mRedirectUrl =
false;
259 $oldid =
$request->getIntOrNull(
'oldid' );
261 if ( $oldid ===
null ) {
265 if ( $oldid !== 0 ) {
266 # Load the given revision and check whether the page is another one.
267 # In that case, update this instance to reflect the change.
268 if ( $oldid === $this->mPage->getLatest() ) {
269 $this->mRevision = $this->mPage->getRevision();
272 if ( $this->mRevision !==
null ) {
274 if ( $this->mPage->getId() != $this->mRevision->getPage() ) {
275 $function = [ get_class( $this->mPage ),
'newFromID' ];
276 $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
282 if (
$request->getVal(
'direction' ) ==
'next' ) {
283 $nextid = $this->
getTitle()->getNextRevisionID( $oldid );
286 $this->mRevision =
null;
288 $this->mRedirectUrl = $this->
getTitle()->getFullURL(
'redirect=no' );
290 } elseif (
$request->getVal(
'direction' ) ==
'prev' ) {
291 $previd = $this->
getTitle()->getPreviousRevisionID( $oldid );
294 $this->mRevision =
null;
314 if ( $this->mContentLoaded ) {
318 $this->mContentLoaded =
true;
319 $this->mContent =
null;
323 # Pre-fill content with error message so that if something
324 # fails we'll have something telling us what we intended.
326 $this->mContentObject =
new MessageContent(
'missing-revision', [ $oldid ] );
329 # $this->mRevision might already be fetched by getOldIDFromRequest()
330 if ( !$this->mRevision ) {
332 if ( !$this->mRevision ) {
333 wfDebug( __METHOD__ .
" failed to retrieve specified revision, id $oldid\n" );
338 $oldid = $this->mPage->getLatest();
340 wfDebug( __METHOD__ .
" failed to find page data for title " .
341 $this->
getTitle()->getPrefixedText() .
"\n" );
345 # Update error message with correct oldid
346 $this->mContentObject =
new MessageContent(
'missing-revision', [ $oldid ] );
348 $this->mRevision = $this->mPage->getRevision();
350 if ( !$this->mRevision ) {
351 wfDebug( __METHOD__ .
" failed to retrieve current page, rev_id $oldid\n" );
359 $content = $this->mRevision->getContent(
365 wfDebug( __METHOD__ .
" failed to retrieve content of revision " .
366 $this->mRevision->getId() .
"\n" );
370 $this->mContentObject = $content;
371 $this->mRevIdFetched = $this->mRevision->getId();
374 $articlePage = $this;
377 'ArticleAfterFetchContentObject',
378 [ &$articlePage, &$this->mContentObject ]
390 # If no oldid, this is the current version.
395 return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent();
417 if ( $this->mRevIdFetched ) {
420 return $this->mPage->getLatest();
431 # Get variables from query string
432 # As side effect this will load the revision and update the title
433 # in a revision ID is passed in the request, so this should remain
434 # the first call of this method even if $oldid is used way below.
438 # Another whitelist check in case getOldID() is altering the title
439 $permErrors = $this->
getTitle()->getUserPermissionsErrors(
'read',
$user );
440 if ( count( $permErrors ) ) {
441 wfDebug( __METHOD__ .
": denied on secondary read check\n" );
445 $outputPage = $this->
getContext()->getOutput();
446 # getOldID() may as well want us to redirect somewhere else
447 if ( $this->mRedirectUrl ) {
448 $outputPage->redirect( $this->mRedirectUrl );
449 wfDebug( __METHOD__ .
": redirecting due to oldid\n" );
454 # If we got diff in the query, we want to see a diff page instead of the article.
455 if ( $this->
getContext()->getRequest()->getCheck(
'diff' ) ) {
456 wfDebug( __METHOD__ .
": showing diff page\n" );
462 # Set page title (may be overridden by DISPLAYTITLE)
463 $outputPage->setPageTitle( $this->
getTitle()->getPrefixedText() );
465 $outputPage->setArticleFlag(
true );
466 # Allow frames by default
467 $outputPage->allowClickjacking();
469 $parserCache = MediaWikiServices::getInstance()->getParserCache();
472 # Render printable version, use printable version cache
473 if ( $outputPage->isPrintable() ) {
474 $parserOptions->setIsPrintable(
true );
475 $parserOptions->setEditSection(
false );
477 $parserOptions->setEditSection(
false );
480 # Try client and file cache
481 if ( !
$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) {
482 # Try to stream the output from file cache
484 wfDebug( __METHOD__ .
": done file cache\n" );
485 # tell wgOut that output is taken care of
486 $outputPage->disable();
487 $this->mPage->doViewUpdates(
$user, $oldid );
493 # Should the parser cache be used?
494 $useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid );
495 wfDebug(
'Article::view using parser cache: ' . ( $useParserCache ?
'yes' :
'no' ) .
"\n" );
496 if (
$user->getStubThreshold() ) {
497 MediaWikiServices::getInstance()->getStatsdDataFactory()->increment(
'pcache_miss_stub' );
503 # Iterate through the possible ways of constructing the output text.
504 # Keep going until $outputDone is set, or we run out of things to do.
507 $this->mParserOutput =
false;
509 while ( !$outputDone && ++$pass ) {
513 $articlePage = $this;
514 Hooks::run(
'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
517 # Early abort if the page doesn't exist
518 if ( !$this->mPage->exists() ) {
519 wfDebug( __METHOD__ .
": showing missing article\n" );
521 $this->mPage->doViewUpdates(
$user );
525 # Try the parser cache
526 if ( $useParserCache ) {
527 $this->mParserOutput = $parserCache->get( $this->mPage, $parserOptions );
529 if ( $this->mParserOutput !==
false ) {
531 wfDebug( __METHOD__ .
": showing parser cache contents for current rev permalink\n" );
534 wfDebug( __METHOD__ .
": showing parser cache contents\n" );
536 $outputPage->addParserOutput( $this->mParserOutput );
537 # Ensure that UI elements requiring revision ID have
538 # the correct version information.
539 $outputPage->setRevisionId( $this->mPage->getLatest() );
540 # Preload timestamp to avoid a DB hit
541 $cachedTimestamp = $this->mParserOutput->getTimestamp();
542 if ( $cachedTimestamp !==
null ) {
543 $outputPage->setRevisionTimestamp( $cachedTimestamp );
544 $this->mPage->setTimestamp( $cachedTimestamp );
551 # This will set $this->mRevision if needed
554 # Are we looking at an old revision
555 if ( $oldid && $this->mRevision ) {
559 wfDebug( __METHOD__ .
": cannot view deleted revision\n" );
564 # Ensure that UI elements requiring revision ID have
565 # the correct version information.
567 # Preload timestamp to avoid a DB hit
568 $outputPage->setRevisionTimestamp( $this->mPage->getTimestamp() );
570 # Pages containing custom CSS or JavaScript get special treatment
571 if ( $this->
getTitle()->isCssOrJsPage() || $this->
getTitle()->isCssJsSubpage() ) {
572 $dir = $this->
getContext()->getLanguage()->getDir();
575 $outputPage->wrapWikiMsg(
576 "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
579 } elseif ( !Hooks::run(
'ArticleContentViewCustom',
582 # Allow extensions do their own custom view for certain pages
587 # Run the parse, protected by a pool counter
588 wfDebug( __METHOD__ .
": doing uncached parse\n" );
594 if ( !$poolArticleView->execute() ) {
595 $error = $poolArticleView->getError();
597 $outputPage->clearHTML();
598 $outputPage->enableClientCache(
false );
599 $outputPage->setRobotPolicy(
'noindex,nofollow' );
601 $errortext = $error->getWikiText(
false,
'view-pool-error' );
602 $outputPage->addWikiText(
'<div class="errorbox">' . $errortext .
'</div>' );
604 # Connection or timeout error
608 $this->mParserOutput = $poolArticleView->getParserOutput();
609 $outputPage->addParserOutput( $this->mParserOutput );
610 if ( $content->getRedirectTarget() ) {
611 $outputPage->addSubtitle(
"<span id=\"redirectsub\">" .
612 $this->
getContext()->msg(
'redirectpagesub' )->parse() .
"</span>" );
615 # Don't cache a dirty ParserOutput object
616 if ( $poolArticleView->getIsDirty() ) {
617 $outputPage->setCdnMaxage( 0 );
618 $outputPage->addHTML(
"<!-- parser cache is expired, " .
619 "sending anyway due to pool overload-->\n" );
624 # Should be unreachable, but just in case...
630 # Get the ParserOutput actually *displayed* here.
631 # Note that $this->mParserOutput is the *current*/oldid version output.
636 # Adjust title for main page & pages with displaytitle
641 # For the main page, overwrite the <title> element with the con-
642 # tents of 'pagetitle-view-mainpage' instead of the default (if
644 # This message always exists because it is in the i18n files
645 if ( $this->
getTitle()->isMainPage() ) {
646 $msg =
wfMessage(
'pagetitle-view-mainpage' )->inContentLanguage();
647 if ( !$msg->isDisabled() ) {
648 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
652 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
653 # This could use getTouched(), but that could be scary for major template edits.
656 # Check for any __NOINDEX__ tags on the page using $pOutput
658 $outputPage->setIndexPolicy( $policy[
'index'] );
659 $outputPage->setFollowPolicy( $policy[
'follow'] );
662 $this->mPage->doViewUpdates(
$user, $oldid );
664 # Load the postEdit module if the user just saved this revision
665 # See also EditPage::setPostEditCookie
668 $postEdit =
$request->getCookie( $cookieKey );
670 # Clear the cookie. This also prevents caching of the response.
671 $request->response()->clearCookie( $cookieKey );
672 $outputPage->addJsConfigVars(
'wgPostEdit', $postEdit );
673 $outputPage->addModules(
'mediawiki.action.view.postEdit' );
682 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
684 if ( strval( $titleText ) !==
'' ) {
685 $this->
getContext()->getOutput()->setPageTitle( $titleText );
698 $diffOnly =
$request->getBool(
'diffonly',
$user->getOption(
'diffonly' ) );
699 $purge =
$request->getVal(
'action' ) ==
'purge';
707 $msg = $this->
getContext()->msg(
'difference-missing-revision' )
711 $this->
getContext()->getOutput()->addHTML( $msg );
715 $contentHandler =
$rev->getContentHandler();
716 $de = $contentHandler->createDifferenceEngine(
726 $this->mRevIdFetched = $de->mNewid;
727 $de->showDiffPage( $diffOnly );
731 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
733 $this->mPage->doViewUpdates(
$user, (
int)$new );
746 $ns = $this->
getTitle()->getNamespace();
748 # Don't index user and user talk pages for blocked users (T13443)
750 $specificTarget =
null;
752 $titleText = $this->
getTitle()->getText();
753 if ( IP::isValid( $titleText ) ) {
754 $vagueTarget = $titleText;
756 $specificTarget = $titleText;
760 'index' =>
'noindex',
761 'follow' =>
'nofollow'
766 if ( $this->mPage->getId() === 0 || $this->getOldID() ) {
767 # Non-articles (special pages etc), and old revisions
769 'index' =>
'noindex',
770 'follow' =>
'nofollow'
772 } elseif ( $this->
getContext()->getOutput()->isPrintable() ) {
773 # Discourage indexing of printable versions, but encourage following
775 'index' =>
'noindex',
778 } elseif ( $this->
getContext()->getRequest()->getInt(
'curid' ) ) {
779 # For ?curid=x urls, disallow indexing
781 'index' =>
'noindex',
786 # Otherwise, construct the policy based on the various config variables.
790 # Honour customised robot policies for this namespace
791 $policy = array_merge(
796 if ( $this->
getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
797 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
798 # a final sanity check that we have really got the parser output.
799 $policy = array_merge(
801 [
'index' => $pOutput->getIndexPolicy() ]
806 # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
807 $policy = array_merge(
824 if ( is_array( $policy ) ) {
826 } elseif ( !$policy ) {
830 $policy = explode(
',', $policy );
831 $policy = array_map(
'trim', $policy );
834 foreach ( $policy
as $var ) {
835 if ( in_array( $var, [
'index',
'noindex' ] ) ) {
836 $arr[
'index'] = $var;
837 } elseif ( in_array( $var, [
'follow',
'nofollow' ] ) ) {
838 $arr[
'follow'] = $var;
856 $outputPage =
$context->getOutput();
858 $rdfrom =
$request->getVal(
'rdfrom' );
862 unset(
$query[
'rdfrom'] );
866 $query[
'redirect'] =
'no';
870 if ( isset( $this->mRedirectedFrom ) ) {
872 $articlePage = $this;
876 if ( Hooks::run(
'ArticleViewRedirect', [ &$articlePage ] ) ) {
878 $this->mRedirectedFrom,
881 [
'redirect' =>
'no' ]
884 $outputPage->addSubtitle(
"<span class=\"mw-redirectedfrom\">" .
885 $context->msg(
'redirectedfrom' )->rawParams( $redir )->parse()
890 $outputPage->addJsConfigVars( [
891 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
893 $outputPage->addModules(
'mediawiki.action.view.redirect' );
896 $outputPage->setCanonicalUrl( $this->
getTitle()->getCanonicalURL() );
899 $outputPage->setRedirectedFrom( $this->mRedirectedFrom );
903 } elseif ( $rdfrom ) {
908 $outputPage->addSubtitle(
"<span class=\"mw-redirectedfrom\">" .
909 $context->msg(
'redirectedfrom' )->rawParams( $redir )->parse()
913 $outputPage->addJsConfigVars( [
914 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
916 $outputPage->addModules(
'mediawiki.action.view.redirect' );
930 if ( $this->
getTitle()->isTalkPage() ) {
931 if ( !
wfMessage(
'talkpageheader' )->isDisabled() ) {
932 $this->
getContext()->getOutput()->wrapWikiMsg(
933 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
944 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
946 && IP::isValid( $this->
getTitle()->getText() )
948 $this->
getContext()->getOutput()->addWikiMsg(
'anontalkpagetext' );
954 Hooks::run(
'ArticleViewFooter', [ $this, $patrolFooterShown ] );
969 $outputPage = $this->
getContext()->getOutput();
982 if ( $this->mRevision
991 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
992 $key =
$cache->makeKey(
'unpatrollable-page',
$title->getArticleID() );
993 if (
$cache->get( $key ) ) {
998 $oldestRevisionTimestamp =
$dbr->selectField(
1000 'MIN( rev_timestamp )',
1001 [
'rev_page' =>
$title->getArticleID() ],
1010 $recentPageCreation =
false;
1011 if ( $oldestRevisionTimestamp
1015 $recentPageCreation =
true;
1019 'rc_timestamp' => $oldestRevisionTimestamp,
1020 'rc_namespace' =>
$title->getNamespace(),
1021 'rc_cur_id' =>
$title->getArticleID()
1027 $markPatrolledMsg =
wfMessage(
'markaspatrolledtext' );
1035 $recentFileUpload =
false;
1039 $newestUploadTimestamp =
$dbr->selectField(
1041 'MAX( img_timestamp )',
1042 [
'img_name' =>
$title->getDBkey() ],
1045 if ( $newestUploadTimestamp
1049 $recentFileUpload =
true;
1053 'rc_log_type' =>
'upload',
1054 'rc_timestamp' => $newestUploadTimestamp,
1056 'rc_cur_id' =>
$title->getArticleID()
1062 $markPatrolledMsg =
wfMessage(
'markaspatrolledtext-file' );
1067 if ( !$recentPageCreation && !$recentFileUpload ) {
1072 $cache->set( $key,
'1' );
1084 if ( $rc->getAttribute(
'rc_patrolled' ) ) {
1089 $cache->set( $key,
'1' );
1094 if ( $rc->getPerformer()->equals(
$user ) ) {
1100 $outputPage->preventClickjacking();
1102 $outputPage->addModules(
'mediawiki.page.patrol.ajax' );
1107 $markPatrolledMsg->escaped(),
1110 'action' =>
'markpatrolled',
1111 'rcid' => $rc->getAttribute(
'rc_id' ),
1115 $outputPage->addHTML(
1116 "<div class='patrollink' data-mw='interface'>" .
1117 wfMessage(
'markaspatrolledlink' )->rawParams(
$link )->escaped() .
1131 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1132 $cache->delete(
$cache->makeKey(
'unpatrollable-page', $articleID ) );
1142 $outputPage = $this->
getContext()->getOutput();
1144 $validUserPage =
false;
1148 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1152 $rootPart = explode(
'/',
$title->getText() )[0];
1153 $user = User::newFromName( $rootPart,
false );
1154 $ip = User::isIP( $rootPart );
1157 if ( !(
$user &&
$user->isLoggedIn() ) && !$ip ) { #
User does not exist
1158 $outputPage->wrapWikiMsg(
"<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1161 # Show log extract if the user is currently blocked
1165 MWNamespace::getCanonicalName(
NS_USER ) .
':' . $block->getTarget(),
1169 'showIfEmpty' =>
false,
1171 'blocked-notice-logextract',
1172 $user->getName() # Support GENDER
in notice
1176 $validUserPage = !
$title->isSubpage();
1178 $validUserPage = !
$title->isSubpage();
1182 Hooks::run(
'ShowMissingArticle', [ $this ] );
1184 # Show delete and move logs if there were any such events.
1185 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1186 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1187 $cache = MediaWikiServices::getInstance()->getMainObjectStash();
1188 $key =
$cache->makeKey(
'page-recent-delete', md5(
$title->getPrefixedText() ) );
1189 $loggedIn = $this->
getContext()->getUser()->isLoggedIn();
1190 if ( $loggedIn ||
$cache->get( $key ) ) {
1191 $logTypes = [
'delete',
'move',
'protect' ];
1195 $conds = [
'log_action != ' .
$dbr->addQuotes(
'revision' ) ];
1197 Hooks::run(
'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1206 'showIfEmpty' =>
false,
1207 'msgKey' => [ $loggedIn
1208 ?
'moveddeleted-notice'
1209 :
'moveddeleted-notice-recent'
1215 if ( !$this->mPage->hasViewableContent() &&
$wgSend404Code && !$validUserPage ) {
1218 $this->
getContext()->getRequest()->response()->statusHeader( 404 );
1223 $outputPage->setIndexPolicy( $policy[
'index'] );
1224 $outputPage->setFollowPolicy( $policy[
'follow'] );
1226 $hookResult = Hooks::run(
'BeforeDisplayNoArticleText', [ $this ] );
1228 if ( !$hookResult ) {
1232 # Show error message
1238 $text =
wfMessage(
'missing-revision', $oldid )->plain();
1239 } elseif (
$title->quickUserCan(
'create', $this->getContext()->getUser() )
1240 &&
$title->quickUserCan(
'edit', $this->getContext()->getUser() )
1242 $message = $this->
getContext()->getUser()->isLoggedIn() ?
'noarticletext' :
'noarticletextanon';
1245 $text =
wfMessage(
'noarticletext-nopermission' )->plain();
1248 $dir = $this->
getContext()->getLanguage()->getDir();
1250 $outputPage->addWikiText( Xml::openElement(
'div', [
1251 'class' =>
"noarticletext mw-content-$dir",
1254 ] ) .
"\n$text\n</div>" );
1270 $outputPage = $this->
getContext()->getOutput();
1274 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1275 'rev-deleted-text-permission' );
1279 } elseif ( $this->
getContext()->getRequest()->getInt(
'unhide' ) != 1 ) {
1280 # Give explanation and add a link to view the revision...
1281 $oldid = intval( $this->
getOldID() );
1282 $link = $this->
getTitle()->getFullURL(
"oldid={$oldid}&unhide=1" );
1284 'rev-suppressed-text-unhide' :
'rev-deleted-text-unhide';
1285 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1292 'rev-suppressed-text-view' :
'rev-deleted-text-view';
1293 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1309 $articlePage = $this;
1311 if ( !Hooks::run(
'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1318 # Cascade unhide param in links for easy deletion browsing
1321 $extraParams[
'unhide'] = 1;
1324 if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
1330 $timestamp = $revision->getTimestamp();
1332 $current = ( $oldid == $this->mPage->getLatest() );
1333 $language =
$context->getLanguage();
1336 $td = $language->userTimeAndDate( $timestamp,
$user );
1337 $tddate = $language->userDate( $timestamp,
$user );
1338 $tdtime = $language->userTime( $timestamp,
$user );
1340 # Show user links if allowed to see them. If hidden, then show them only if requested...
1343 $infomsg = $current && !
$context->msg(
'revision-info-current' )->isDisabled()
1344 ?
'revision-info-current'
1347 $outputPage =
$context->getOutput();
1348 $revisionInfo =
"<div id=\"mw-{$infomsg}\">" .
1350 ->rawParams( $userlinks )
1351 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1357 ?
$context->msg(
'currentrevisionlink' )->escaped()
1360 $context->msg(
'currentrevisionlink' )->escaped(),
1365 ?
$context->msg(
'diff' )->escaped()
1368 $context->msg(
'diff' )->escaped(),
1375 $prev = $this->
getTitle()->getPreviousRevisionID( $oldid );
1379 $context->msg(
'previousrevision' )->escaped(),
1382 'direction' =>
'prev',
1386 :
$context->msg(
'previousrevision' )->escaped();
1390 $context->msg(
'diff' )->escaped(),
1397 :
$context->msg(
'diff' )->escaped();
1398 $nextlink = $current
1399 ?
$context->msg(
'nextrevision' )->escaped()
1402 $context->msg(
'nextrevision' )->escaped(),
1405 'direction' =>
'next',
1409 $nextdiff = $current
1410 ?
$context->msg(
'diff' )->escaped()
1413 $context->msg(
'diff' )->escaped(),
1422 if ( $cdel !==
'' ) {
1427 $outputPage->addSubtitle(
"<div class=\"mw-revision\">" . $revisionInfo .
1428 "<div id=\"mw-revision-nav\">" . $cdel .
1429 $context->msg(
'revision-nav' )->rawParams(
1430 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1431 )->escaped() .
"</div></div>" );
1447 public function viewRedirect( $target, $appendSubtitle =
true, $forceKnown =
false ) {
1450 if ( $appendSubtitle ) {
1453 $out->addModuleStyles(
'mediawiki.action.view.redirectPage' );
1454 return static::getRedirectHeaderHtml(
$lang, $target, $forceKnown );
1470 if ( !is_array( $target ) ) {
1471 $target = [ $target ];
1474 $html =
'<ul class="redirectText">';
1479 htmlspecialchars(
$title->getFullText() ),
1482 $title->isRedirect() ? [
'redirect' =>
'no' ] : [],
1483 ( $forceKnown ? [
'known',
'noclasses' ] : [] )
1488 $redirectToText =
wfMessage(
'redirectto' )->inLanguage(
$lang )->escaped();
1490 return '<div class="redirectMsg">' .
1491 '<p>' . $redirectToText .
'</p>' .
1506 'namespace-' . $this->
getTitle()->getNamespace() .
'-helppage'
1510 if ( !$msg->isDisabled() ) {
1512 $out->addHelpLink( $helpUrl,
true );
1514 $out->addHelpLink( $to, $overrideBaseUrl );
1522 $this->
getContext()->getRequest()->response()->header(
'X-Robots-Tag: noindex' );
1523 $this->
getContext()->getOutput()->setArticleBodyOnly(
true );
1524 $this->
getContext()->getOutput()->enableSectionEditLinks(
false );
1546 public function delete() {
1547 # This code desperately needs to be totally rewritten
1555 $permissionErrors =
$title->getUserPermissionsErrors(
'delete',
$user );
1556 if ( count( $permissionErrors ) ) {
1560 # Read-only check...
1565 # Better double-check that it hasn't been deleted yet!
1566 $this->mPage->loadPageData(
1567 $request->wasPosted() ? WikiPage::READ_LATEST : WikiPage::READ_NORMAL
1569 if ( !$this->mPage->exists() ) {
1570 $deleteLogPage =
new LogPage(
'delete' );
1571 $outputPage =
$context->getOutput();
1572 $outputPage->setPageTitle(
$context->msg(
'cannotdelete-title',
$title->getPrefixedText() ) );
1573 $outputPage->wrapWikiMsg(
"<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1576 $outputPage->addHTML(
1577 Xml::element(
'h2',
null, $deleteLogPage->getName()->text() )
1588 $deleteReasonList =
$request->getText(
'wpDeleteReasonList',
'other' );
1589 $deleteReason =
$request->getText(
'wpReason' );
1591 if ( $deleteReasonList ==
'other' ) {
1592 $reason = $deleteReason;
1593 } elseif ( $deleteReason !=
'' ) {
1595 $colonseparator =
wfMessage(
'colon-separator' )->inContentLanguage()->text();
1596 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1598 $reason = $deleteReasonList;
1602 [
'delete', $this->getTitle()->getPrefixedText() ] )
1604 # Flag to hide all contents of the archived revisions
1605 $suppress =
$request->getCheck(
'wpSuppress' ) &&
$user->isAllowed(
'suppressrevision' );
1607 $this->
doDelete( $reason, $suppress );
1615 $hasHistory =
false;
1619 }
catch ( Exception
$e ) {
1620 # if a page is horribly broken, we still want to be able to
1621 # delete it. So be lenient about errors here.
1622 wfDebug(
"Error while building auto delete summary: $e" );
1628 if ( $hasHistory ) {
1637 $revisions = $edits = (int)
$dbr->selectField(
1640 [
'rev_page' =>
$title->getArticleID() ],
1646 '<strong class="mw-delete-warning-revisions">' .
1647 $context->msg(
'historywarning' )->numParams( $revisions )->parse() .
1649 $context->msg(
'history' )->escaped(),
1651 [
'action' =>
'history' ] ) .
1655 if (
$title->isBigDeletion() ) {
1657 $context->getOutput()->wrapWikiMsg(
"<div class='error'>\n$1\n</div>\n",
1659 'delete-warning-toobig',
1675 wfDebug(
"Article::confirmDelete\n" );
1679 $outputPage = $ctx->getOutput();
1680 $outputPage->setPageTitle(
wfMessage(
'delete-confirm',
$title->getPrefixedText() ) );
1681 $outputPage->addBacklinkSubtitle(
$title );
1682 $outputPage->setRobotPolicy(
'noindex,nofollow' );
1684 $backlinkCache =
$title->getBacklinkCache();
1685 if ( $backlinkCache->hasLinks(
'pagelinks' ) || $backlinkCache->hasLinks(
'templatelinks' ) ) {
1686 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1687 'deleting-backlinks-warning' );
1690 $subpageQueryLimit = 51;
1691 $subpages =
$title->getSubpages( $subpageQueryLimit );
1692 $subpageCount = count( $subpages );
1693 if ( $subpageCount > 0 ) {
1694 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1695 [
'deleting-subpages-warning', Message::numParam( $subpageCount ) ] );
1697 $outputPage->addWikiMsg(
'confirmdeletetext' );
1699 Hooks::run(
'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1702 $checkWatch =
$user->getBoolOption(
'watchdeletion' ) ||
$user->isWatched(
$title );
1704 $outputPage->enableOOUI();
1706 $options = Xml::listDropDownOptions(
1707 $ctx->msg(
'deletereason-dropdown' )->inContentLanguage()->text(),
1708 [
'other' => $ctx->msg(
'deletereasonotherlist' )->inContentLanguage()->text() ]
1712 $fields[] =
new OOUI\FieldLayout(
1713 new OOUI\DropdownInputWidget( [
1714 'name' =>
'wpDeleteReasonList',
1715 'inputId' =>
'wpDeleteReasonList',
1717 'infusable' =>
true,
1722 'label' => $ctx->msg(
'deletecomment' )->text(),
1727 $fields[] =
new OOUI\FieldLayout(
1728 new OOUI\TextInputWidget( [
1729 'name' =>
'wpReason',
1730 'inputId' =>
'wpReason',
1733 'infusable' =>
true,
1735 'autofocus' =>
true,
1738 'label' => $ctx->msg(
'deleteotherreason' )->text(),
1743 if (
$user->isLoggedIn() ) {
1744 $fields[] =
new OOUI\FieldLayout(
1745 new OOUI\CheckboxInputWidget( [
1746 'name' =>
'wpWatch',
1747 'inputId' =>
'wpWatch',
1749 'selected' => $checkWatch,
1752 'label' => $ctx->msg(
'watchthis' )->text(),
1753 'align' =>
'inline',
1754 'infusable' =>
true,
1759 if (
$user->isAllowed(
'suppressrevision' ) ) {
1760 $fields[] =
new OOUI\FieldLayout(
1761 new OOUI\CheckboxInputWidget( [
1762 'name' =>
'wpSuppress',
1763 'inputId' =>
'wpSuppress',
1767 'label' => $ctx->msg(
'revdelete-suppress' )->text(),
1768 'align' =>
'inline',
1769 'infusable' =>
true,
1774 $fields[] =
new OOUI\FieldLayout(
1775 new OOUI\ButtonInputWidget( [
1776 'name' =>
'wpConfirmB',
1777 'inputId' =>
'wpConfirmB',
1779 'value' => $ctx->msg(
'deletepage' )->text(),
1780 'label' => $ctx->msg(
'deletepage' )->text(),
1781 'flags' => [
'primary',
'destructive' ],
1789 $fieldset =
new OOUI\FieldsetLayout( [
1790 'label' => $ctx->msg(
'delete-legend' )->text(),
1791 'id' =>
'mw-delete-table',
1795 $form =
new OOUI\FormLayout( [
1797 'action' =>
$title->getLocalURL(
'action=delete' ),
1798 'id' =>
'deleteconfirm',
1800 $form->appendContent(
1802 new OOUI\HtmlSnippet(
1803 Html::hidden(
'wpEditToken',
$user->getEditToken( [
'delete',
$title->getPrefixedText() ] ) )
1807 $outputPage->addHTML(
1808 new OOUI\PanelLayout( [
1809 'classes' => [
'deletepage-wrapper' ],
1810 'expanded' =>
false,
1817 if (
$user->isAllowed(
'editinterface' ) ) {
1819 $ctx->msg(
'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1820 wfMessage(
'delete-edit-reasonlist' )->escaped(),
1822 [
'action' =>
'edit' ]
1824 $outputPage->addHTML(
'<p class="mw-delete-editreasons">' .
$link .
'</p>' );
1827 $deleteLogPage =
new LogPage(
'delete' );
1828 $outputPage->addHTML( Xml::element(
'h2',
null, $deleteLogPage->getName()->text() ) );
1837 public function doDelete( $reason, $suppress =
false ) {
1840 $outputPage =
$context->getOutput();
1842 $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0,
true, $error,
$user );
1845 $deleted = $this->
getTitle()->getPrefixedText();
1847 $outputPage->setPageTitle(
wfMessage(
'actioncomplete' ) );
1848 $outputPage->setRobotPolicy(
'noindex,nofollow' );
1850 $loglink =
'[[Special:Log/delete|' .
wfMessage(
'deletionlog' )->text() .
']]';
1852 $outputPage->addWikiMsg(
'deletedtext',
wfEscapeWikiText( $deleted ), $loglink );
1854 Hooks::run(
'ArticleDeleteAfterSuccess', [ $this->
getTitle(), $outputPage ] );
1856 $outputPage->returnToMain(
false );
1858 $outputPage->setPageTitle(
1860 $this->
getTitle()->getPrefixedText() )
1863 if ( $error ==
'' ) {
1864 $outputPage->addWikiText(
1865 "<div class=\"error mw-error-cannotdelete\">\n" .
$status->getWikiText() .
"\n</div>"
1867 $deleteLogPage =
new LogPage(
'delete' );
1868 $outputPage->addHTML( Xml::element(
'h2',
null, $deleteLogPage->getName()->text() ) );
1876 $outputPage->addHTML( $error );
1891 static $called =
false;
1894 wfDebug(
"Article::tryFileCache(): called twice!?\n" );
1901 if (
$cache->isCacheGood( $this->mPage->getTouched() ) ) {
1902 wfDebug(
"Article::tryFileCache(): about to load file\n" );
1906 wfDebug(
"Article::tryFileCache(): starting buffer\n" );
1907 ob_start( [ &
$cache,
'saveToFileCache' ] );
1910 wfDebug(
"Article::tryFileCache(): not cacheable\n" );
1925 $cacheable = $this->mPage->getId()
1926 && !$this->mRedirectedFrom && !$this->
getTitle()->isRedirect();
1930 $articlePage = $this;
1931 $cacheable = Hooks::run(
'IsFileCacheable', [ &$articlePage ] );
1954 if (
$user ===
null ) {
1957 $parserOptions = $this->mPage->makeParserOptions(
$user );
1960 return $this->mPage->getParserOutput( $parserOptions, $oldid );
1970 if ( $this->mParserOptions ) {
1971 throw new MWException(
"can't change parser options after they have already been set" );
1975 $this->mParserOptions = clone
$options;
1983 if ( !$this->mParserOptions ) {
1984 $this->mParserOptions = $this->mPage->makeParserOptions( $this->
getContext() );
2010 wfDebug( __METHOD__ .
" called and \$mContext is null. " .
2011 "Return RequestContext::getMain(); for sanity\n" );
2024 if ( property_exists( $this->mPage,
$fname ) ) {
2025 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2026 return $this->mPage->$fname;
2028 trigger_error(
'Inaccessible property via __get(): ' .
$fname, E_USER_NOTICE );
2039 if ( property_exists( $this->mPage,
$fname ) ) {
2040 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2041 $this->mPage->$fname = $fvalue;
2043 } elseif ( !in_array(
$fname, [
'mContext',
'mPage' ] ) ) {
2044 $this->mPage->$fname = $fvalue;
2046 trigger_error(
'Inaccessible property via __set(): ' .
$fname, E_USER_NOTICE );
2055 return $this->mPage->checkFlags(
$flags );
2063 return $this->mPage->checkTouched();
2071 $this->mPage->clearPreparedEdit();
2079 $reason, $suppress =
false, $u1 =
null, $u2 =
null, &$error =
'',
User $user =
null,
2082 return $this->mPage->doDeleteArticleReal(
2083 $reason, $suppress, $u1, $u2, $error,
$user, $tags
2092 return $this->mPage->doDeleteUpdates( $id, $content );
2101 User $user =
null, $serialFormat =
null
2104 return $this->mPage->doEditContent( $content, $summary,
$flags, $baseRevId,
2105 $user, $serialFormat
2114 return $this->mPage->doEditUpdates( $revision,
$user,
$options );
2124 return $this->mPage->doPurge();
2134 return $this->mPage->getLastPurgeTimestamp();
2142 $this->mPage->doViewUpdates(
$user, $oldid );
2150 return $this->mPage->exists();
2158 return $this->mPage->followRedirect();
2166 return $this->mPage->getActionOverrides();
2174 return $this->mPage->getAutoDeleteReason( $hasHistory );
2182 return $this->mPage->getCategories();
2190 return $this->mPage->getComment( $audience,
$user );
2198 return $this->mPage->getContentHandler();
2206 return $this->mPage->getContentModel();
2214 return $this->mPage->getContributors();
2222 return $this->mPage->getCreator( $audience,
$user );
2230 return $this->mPage->getDeletionUpdates( $content );
2238 return $this->mPage->getHiddenCategories();
2246 return $this->mPage->getId();
2254 return $this->mPage->getLatest();
2262 return $this->mPage->getLinksTimestamp();
2270 return $this->mPage->getMinorEdit();
2278 return $this->mPage->getOldestRevision();
2286 return $this->mPage->getRedirectTarget();
2294 return $this->mPage->getRedirectURL( $rt );
2302 return $this->mPage->getRevision();
2310 return $this->mPage->getTimestamp();
2318 return $this->mPage->getTouched();
2326 return $this->mPage->getUndoContent( $undo, $undoafter );
2334 return $this->mPage->getUser( $audience,
$user );
2342 return $this->mPage->getUserText( $audience,
$user );
2350 return $this->mPage->hasViewableContent();
2358 return $this->mPage->insertOn( $dbw, $pageId );
2366 array $expiry, $cascade, $reason, $user =
null
2368 return $this->mPage->insertProtectNullRevision( $revCommentMsg, $limit,
2369 $expiry, $cascade, $reason,
$user
2378 return $this->mPage->insertRedirect();
2386 return $this->mPage->insertRedirectEntry( $rt, $oldLatest );
2394 return $this->mPage->isCountable( $editInfo );
2402 return $this->mPage->isRedirect();
2410 return $this->mPage->loadFromRow( $data, $from );
2418 $this->mPage->loadPageData( $from );
2426 return $this->mPage->lockAndGetLatest();
2434 return $this->mPage->makeParserOptions(
$context );
2442 return $this->mPage->pageDataFromId(
$dbr, $id,
$options );
2458 Content $content, $revision =
null,
User $user =
null,
2459 $serialFormat =
null, $useCache =
true
2461 return $this->mPage->prepareContentForEdit(
2462 $content, $revision,
$user,
2463 $serialFormat, $useCache
2472 return $this->mPage->protectDescription( $limit, $expiry );
2480 return $this->mPage->protectDescriptionLog( $limit, $expiry );
2488 $sectionTitle =
'', $baseRevId =
null
2490 return $this->mPage->replaceSectionAtRev( $sectionId, $sectionContent,
2491 $sectionTitle, $baseRevId
2500 $sectionId,
Content $sectionContent, $sectionTitle =
'', $edittime =
null
2502 return $this->mPage->replaceSectionContent(
2503 $sectionId, $sectionContent, $sectionTitle, $edittime
2512 return $this->mPage->setTimestamp( $ts );
2520 return $this->mPage->shouldCheckParserCache( $parserOptions, $oldId );
2528 return $this->mPage->supportsSections();
2536 return $this->mPage->triggerOpportunisticLinksUpdate( $parserOutput );
2544 return $this->mPage->updateCategoryCounts( $added, $deleted, $id );
2552 return $this->mPage->updateIfNewerOn( $dbw, $revision );
2560 return $this->mPage->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect =
null );
2568 $lastRevIsRedirect =
null
2570 return $this->mPage->updateRevisionOn( $dbw, $revision, $lastRevision,
2586 return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason,
$user );
2597 &$cascade = 0, $expiry = []
2599 return $this->mPage->doUpdateRestrictions(
2617 $reason, $suppress =
false, $u1 =
null, $u2 =
null, &$error =
''
2619 return $this->mPage->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2631 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails,
User $user =
null ) {
2633 return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails,
$user );
2645 $guser = is_null( $guser ) ? $this->
getContext()->getUser() : $guser;
2646 return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2654 $title = $this->mPage->getTitle();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgArticleRobotPolicies
Robot policies per article.
$wgDefaultRobotPolicy
Default robot policy.
$wgSend404Code
Some web hosts attempt to rewrite all responses with a 404 (not found) status code,...
$wgRedirectSources
If local interwikis are set up which allow redirects, set this regexp to restrict URLs which will be ...
$wgUseFilePatrol
Use file patrolling to check new files on Special:Newfiles.
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
$wgEnableWriteAPI
Allow the API to be used to perform write operations (page edits, rollback, etc.) when an authorised ...
$wgNamespaceRobotPolicies
Robot policies per namespaces.
$wgUseNPPatrol
Use new page patrolling to check new pages on Special:Newpages.
$wgDeleteRevisionsLimit
Optional to restrict deletion of pages with higher revision counts to users with the 'bigdelete' perm...
$wgDebugToolbar
Display the new debugging toolbar.
$wgEnableAPI
Enable the MediaWiki API for convenient access to machine-readable data via api.php.
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Class for viewing MediaWiki article and history.
shouldCheckParserCache(ParserOptions $parserOptions, $oldId)
Call to WikiPage function for backwards compatibility.
getRevisionFetched()
Get the fetched Revision object depending on request parameters or null on failure.
ParserOutput $mParserOutput
Title $mRedirectedFrom
Title from which we were redirected here.
updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect=null)
Call to WikiPage function for backwards compatibility.
generateReason(&$hasHistory)
checkFlags( $flags)
Call to WikiPage function for backwards compatibility.
doDeleteArticleReal( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $user=null, $tags=[])
Call to WikiPage function for backwards compatibility.
checkTouched()
Call to WikiPage function for backwards compatibility.
doDelete( $reason, $suppress=false)
Perform a deletion and output success or failure messages.
getHiddenCategories()
Call to WikiPage function for backwards compatibility.
static newFromWikiPage(WikiPage $page, IContextSource $context)
Create an Article object of the appropriate class for the given page.
doViewUpdates(User $user, $oldid=0)
Call to WikiPage function for backwards compatibility.
getContext()
Gets the context this Article is executed in.
getCategories()
Call to WikiPage function for backwards compatibility.
commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser=null)
getOldIDFromRequest()
Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.
doEditContent(Content $content, $summary, $flags=0, $baseRevId=false, User $user=null, $serialFormat=null)
Call to WikiPage function for backwards compatibility.
getParserOutput( $oldid=null, User $user=null)
#-
insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user=null)
Call to WikiPage function for backwards compatibility.
doPurge()
Call to WikiPage function for backwards compatibility.
getRedirectedFrom()
Get the page this view was redirected from.
getUserText( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
insertOn( $dbw, $pageId=null)
Call to WikiPage function for backwards compatibility.
updateRevisionOn( $dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
Call to WikiPage function for backwards compatibility.
IContextSource $mContext
The context this Article is executed in.
fetchContentObject()
Get text content object Does NOT follow redirects.
supportsSections()
Call to WikiPage function for backwards compatibility.
string $mContent
Text of the revision we are working on.
pageDataFromTitle( $dbr, $title, $options=[])
Call to WikiPage function for backwards compatibility.
getContentHandler()
Call to WikiPage function for backwards compatibility.
updateCategoryCounts(array $added, array $deleted, $id=0)
Call to WikiPage function for backwards compatibility.
view()
This is the default action of the index.php entry point: just view the page of the given title.
loadPageData( $from='fromdb')
Call to WikiPage function for backwards compatibility.
getRobotPolicy( $action, $pOutput=null)
Get the robot policy to be used for the current view.
doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user)
protectDescriptionLog(array $limit, array $expiry)
Call to WikiPage function for backwards compatibility.
clearPreparedEdit()
Call to WikiPage function for backwards compatibility.
__construct(Title $title, $oldId=null)
Constructor and clear the article.
static purgePatrolFooterCache( $articleID)
Purge the cache used to check if it is worth showing the patrol footer For example,...
followRedirect()
Call to WikiPage function for backwards compatibility.
prepareContentForEdit(Content $content, $revision=null, User $user=null, $serialFormat=null, $useCache=true)
Call to WikiPage function for backwards compatibility.
replaceSectionAtRev( $sectionId, Content $sectionContent, $sectionTitle='', $baseRevId=null)
Call to WikiPage function for backwards compatibility.
getAutoDeleteReason(&$hasHistory)
Call to WikiPage function for backwards compatibility.
getLinksTimestamp()
Call to WikiPage function for backwards compatibility.
protectDescription(array $limit, array $expiry)
Call to WikiPage function for backwards compatibility.
getOldestRevision()
Call to WikiPage function for backwards compatibility.
static onArticleEdit( $title)
setTimestamp( $ts)
Call to WikiPage function for backwards compatibility.
getTitle()
Get the title object of the article.
getActionOverrides()
Call to WikiPage function for backwards compatibility.
doEditUpdates(Revision $revision, User $user, array $options=[])
Call to WikiPage function for backwards compatibility.
getLastPurgeTimestamp()
Call to WikiPage function for backwards compatibility.
adjustDisplayTitle(ParserOutput $pOutput)
Adjust title for pages with displaytitle, -{T|}- or language conversion.
updateIfNewerOn( $dbw, $revision)
Call to WikiPage function for backwards compatibility.
getLatest()
Call to WikiPage function for backwards compatibility.
pageDataFromId( $dbr, $id, $options=[])
Call to WikiPage function for backwards compatibility.
insertRedirect()
Call to WikiPage function for backwards compatibility.
doDeleteUpdates( $id, Content $content=null)
Call to WikiPage function for backwards compatibility.
getContributors()
Call to WikiPage function for backwards compatibility.
showDeletedRevisionHeader()
If the revision requested for view is deleted, check permissions.
isCountable( $editInfo=false)
Call to WikiPage function for backwards compatibility.
getParserOptions()
Get parser options suitable for rendering the primary article wikitext.
getCreator( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
getComment( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Content $mContentObject
Content of the revision we are working on.
getContentModel()
Call to WikiPage function for backwards compatibility.
static getRedirectHeaderHtml(Language $lang, $target, $forceKnown=false)
Return the HTML for the top of a redirect page.
protect()
action=protect handler
lockAndGetLatest()
Call to WikiPage function for backwards compatibility.
isCurrent()
Returns true if the currently-referenced revision is the current edit to this page (and it exists).
updateRestrictions( $limit=[], $reason='', &$cascade=0, $expiry=[])
showMissingArticle()
Show the error text for a missing article.
getUndoContent(Revision $undo, Revision $undoafter=null)
Call to WikiPage function for backwards compatibility.
__set( $fname, $fvalue)
Use PHP's magic __set handler to handle setting of raw WikiPage fields for backwards compatibility.
doDeleteArticle( $reason, $suppress=false, $u1=null, $u2=null, &$error='')
getId()
Call to WikiPage function for backwards compatibility.
unprotect()
action=unprotect handler (alias)
int $mRevIdFetched
Revision ID of revision we are working on.
isRedirect()
Call to WikiPage function for backwards compatibility.
static onArticleCreate( $title)
confirmDelete( $reason)
Output deletion confirmation dialog.
getPage()
Get the WikiPage object of this instance.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getTouched()
Call to WikiPage function for backwards compatibility.
getRevision()
Call to WikiPage function for backwards compatibility.
string bool $mRedirectUrl
URL to redirect to or false if none.
getTimestamp()
Call to WikiPage function for backwards compatibility.
static newFromID( $id)
Constructor from a page id.
getRedirectTarget()
Call to WikiPage function for backwards compatibility.
getUser( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
int null $mOldId
The oldid of the article that is to be shown, 0 for the current revision.
static formatRobotPolicy( $policy)
Converts a String robot policy into an associative array, to allow merging of several policies using ...
Revision $mRevision
Revision we are working on.
viewRedirect( $target, $appendSubtitle=true, $forceKnown=false)
Return the HTML for the top of a redirect page.
insertRedirectEntry(Title $rt, $oldLatest=null)
Call to WikiPage function for backwards compatibility.
triggerOpportunisticLinksUpdate(ParserOutput $parserOutput)
Call to WikiPage function for backwards compatibility.
static onArticleDelete( $title)
makeParserOptions( $context)
Call to WikiPage function for backwards compatibility.
showPatrolFooter()
If patrol is possible, output a patrol UI box.
setOldSubtitle( $oldid=0)
Generate the navigation links when browsing through an article revisions It shows the information as:...
ParserOptions $mParserOptions
ParserOptions object for $wgUser articles.
showViewFooter()
Show the footer section of an ordinary page view.
WikiPage $mPage
The WikiPage object of this instance.
loadFromRow( $data, $from)
Call to WikiPage function for backwards compatibility.
setRedirectedFrom(Title $from)
Tell the page view functions that this view was redirected from another page on the wiki.
isFileCacheable( $mode=HTMLFileCache::MODE_NORMAL)
Check if the page can be cached.
tryFileCache()
checkLastModified returns true if it has taken care of all output to the client that is necessary for...
getRevIdFetched()
Use this to fetch the rev ID used on page views.
replaceSectionContent( $sectionId, Content $sectionContent, $sectionTitle='', $edittime=null)
Call to WikiPage function for backwards compatibility.
showNamespaceHeader()
Show a header specific to the namespace currently being viewed, like [[MediaWiki:Talkpagetext]].
__get( $fname)
Use PHP's magic __get handler to handle accessing of raw WikiPage fields for backwards compatibility.
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
hasViewableContent()
Call to WikiPage function for backwards compatibility.
getContentObject()
Returns a Content object representing the pages effective display content, not necessarily the revisi...
showDiffPage()
Show a diff page according to current request variables.
getMinorEdit()
Call to WikiPage function for backwards compatibility.
setParserOptions(ParserOptions $options)
Override the ParserOptions used to render the primary article wikitext.
render()
Handle action=render.
showRedirectedFromHeader()
If this request is a redirect view, send "redirected from" subtitle to the output.
exists()
Call to WikiPage function for backwards compatibility.
setContext( $context)
Sets the context this Article is executed in.
getRedirectURL( $rt)
Call to WikiPage function for backwards compatibility.
bool $mContentLoaded
Is the content ($mContent) already loaded?
getDeletionUpdates(Content $content=null)
Call to WikiPage function for backwards compatibility.
doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user=null)
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Special handling for category description pages, showing pages, subcategories and file that belong to...
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
const POST_EDIT_COOKIE_KEY_PREFIX
Prefix of key for cookie used to pass post-edit state.
Page view caching in the file system.
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
Class for viewing MediaWiki file description pages.
Internationalisation code.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
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.
static revUserTools( $rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
static getRevDeleteLink(User $user, Revision $rev, Title $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Class to simplify the use of log pages.
Wrapper allowing us to handle a system message as a Content object.
Set options of the Parser.
Show an error when a user tries to do something they do not have the necessary permissions for.
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
static isInRCLifespan( $timestamp, $tolerance=0)
Check whether the given timestamp is new enough to have a RC row with a given tolerance as the recent...
static newFromConds( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
static getMain()
Static methods.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
static makeUrl( $name, $urlaction='')
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
Class representing a MediaWiki article and history.
static onArticleEdit(Title $title, Revision $revision=null)
Purge caches on page update etc.
static onArticleDelete(Title $title)
Clears caches when article is deleted.
static selectFields()
Return the list of revision fields that should be selected to create a new page.
getTitle()
Get the title object of the article.
static onArticleCreate(Title $title)
The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of ...
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
when a variable name is used in a it is silently declared as a new local masking the global
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
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, 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. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
the array() calling protocol came about after MediaWiki 1.4rc1.
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 as strings Extensions should add to this list prev or next refreshes the diff cache $unhide
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
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 & $options
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
namespace and then decline to actually register it file or subcat img or subcat $title
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 unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
null for the local wiki Added in
it s the revision text itself In either if gzip is the revision text is gzipped $flags
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
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 & $html
usually copyright or history_copyright This message must be in HTML not wikitext & $link
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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
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
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
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
returning false will NOT prevent logging $e
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
Base interface for content objects.
Interface for objects which can provide a MediaWiki context on request.
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
if(!isset( $args[0])) $lang