Go to the documentation of this file.
91 $this->mOldId = $oldId;
92 $this->mPage = $this->
newPage( $title );
110 return $t ==
null ? null :
new static(
$t );
129 switch (
$title->getNamespace() ) {
173 $this->mRedirectedFrom = $from;
182 return $this->mPage->getTitle();
199 $this->mContentLoaded =
false;
201 $this->mRedirectedFrom =
null; #
Title object if set
202 $this->mRevIdFetched = 0;
203 $this->mRedirectUrl =
false;
205 $this->mPage->clear();
224 if ( $this->mPage->getId() === 0 ) {
225 # If this is a MediaWiki:x message, then load the messages
226 # and return the message value for x.
228 $text = $this->
getTitle()->getDefaultMessageText();
229 if ( $text ===
false ) {
235 $message = $this->
getContext()->getUser()->isLoggedIn() ?
'noarticletext' :
'noarticletextanon';
250 if ( is_null( $this->mOldId ) ) {
263 $this->mRedirectUrl =
false;
266 $oldid =
$request->getIntOrNull(
'oldid' );
268 if ( $oldid ===
null ) {
272 if ( $oldid !== 0 ) {
273 # Load the given revision and check whether the page is another one.
274 # In that case, update this instance to reflect the change.
275 if ( $oldid === $this->mPage->getLatest() ) {
276 $this->mRevision = $this->mPage->getRevision();
279 if ( $this->mRevision !==
null ) {
281 if ( $this->mPage->getId() != $this->mRevision->getPage() ) {
282 $function = [ get_class( $this->mPage ),
'newFromID' ];
283 $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
289 if (
$request->getVal(
'direction' ) ==
'next' ) {
290 $nextid = $this->
getTitle()->getNextRevisionID( $oldid );
293 $this->mRevision =
null;
295 $this->mRedirectUrl = $this->
getTitle()->getFullURL(
'redirect=no' );
297 } elseif (
$request->getVal(
'direction' ) ==
'prev' ) {
298 $previd = $this->
getTitle()->getPreviousRevisionID( $oldid );
301 $this->mRevision =
null;
321 if ( $this->mContentLoaded ) {
325 $this->mContentLoaded =
true;
326 $this->mContent =
null;
330 # Pre-fill content with error message so that if something
331 # fails we'll have something telling us what we intended.
333 $this->mContentObject =
new MessageContent(
'missing-revision', [ $oldid ] );
336 # $this->mRevision might already be fetched by getOldIDFromRequest()
337 if ( !$this->mRevision ) {
339 if ( !$this->mRevision ) {
340 wfDebug( __METHOD__ .
" failed to retrieve specified revision, id $oldid\n" );
345 $oldid = $this->mPage->getLatest();
347 wfDebug( __METHOD__ .
" failed to find page data for title " .
348 $this->
getTitle()->getPrefixedText() .
"\n" );
352 # Update error message with correct oldid
353 $this->mContentObject =
new MessageContent(
'missing-revision', [ $oldid ] );
355 $this->mRevision = $this->mPage->getRevision();
357 if ( !$this->mRevision ) {
358 wfDebug( __METHOD__ .
" failed to retrieve current page, rev_id $oldid\n" );
366 $content = $this->mRevision->getContent(
372 wfDebug( __METHOD__ .
" failed to retrieve content of revision " .
373 $this->mRevision->getId() .
"\n" );
377 $this->mContentObject = $content;
378 $this->mRevIdFetched = $this->mRevision->getId();
381 $articlePage = $this;
384 'ArticleAfterFetchContentObject',
385 [ &$articlePage, &$this->mContentObject ]
397 # If no oldid, this is the current version.
402 return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent();
424 if ( $this->mRevIdFetched ) {
427 return $this->mPage->getLatest();
438 # Get variables from query string
439 # As side effect this will load the revision and update the title
440 # in a revision ID is passed in the request, so this should remain
441 # the first call of this method even if $oldid is used way below.
445 # Another whitelist check in case getOldID() is altering the title
446 $permErrors = $this->
getTitle()->getUserPermissionsErrors(
'read',
$user );
447 if (
count( $permErrors ) ) {
448 wfDebug( __METHOD__ .
": denied on secondary read check\n" );
452 $outputPage = $this->
getContext()->getOutput();
453 # getOldID() may as well want us to redirect somewhere else
454 if ( $this->mRedirectUrl ) {
455 $outputPage->redirect( $this->mRedirectUrl );
456 wfDebug( __METHOD__ .
": redirecting due to oldid\n" );
461 # If we got diff in the query, we want to see a diff page instead of the article.
462 if ( $this->
getContext()->getRequest()->getCheck(
'diff' ) ) {
463 wfDebug( __METHOD__ .
": showing diff page\n" );
469 # Set page title (may be overridden by DISPLAYTITLE)
470 $outputPage->setPageTitle( $this->
getTitle()->getPrefixedText() );
472 $outputPage->setArticleFlag(
true );
473 # Allow frames by default
474 $outputPage->allowClickjacking();
476 $parserCache = MediaWikiServices::getInstance()->getParserCache();
480 # Render printable version, use printable version cache
481 if ( $outputPage->isPrintable() ) {
482 $parserOptions->setIsPrintable(
true );
483 $poOptions[
'enableSectionEditLinks'] =
false;
484 } elseif ( $this->disableSectionEditForRender
487 $poOptions[
'enableSectionEditLinks'] =
false;
490 # Try client and file cache
491 if ( !
$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) {
492 # Try to stream the output from file cache
494 wfDebug( __METHOD__ .
": done file cache\n" );
495 # tell wgOut that output is taken care of
496 $outputPage->disable();
497 $this->mPage->doViewUpdates(
$user, $oldid );
503 # Should the parser cache be used?
504 $useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid );
505 wfDebug(
'Article::view using parser cache: ' . ( $useParserCache ?
'yes' :
'no' ) .
"\n" );
506 if (
$user->getStubThreshold() ) {
507 MediaWikiServices::getInstance()->getStatsdDataFactory()->increment(
'pcache_miss_stub' );
513 # Iterate through the possible ways of constructing the output text.
514 # Keep going until $outputDone is set, or we run out of things to do.
517 $this->mParserOutput =
false;
519 while ( !$outputDone && ++$pass ) {
523 $articlePage = $this;
524 Hooks::run(
'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
527 # Early abort if the page doesn't exist
528 if ( !$this->mPage->exists() ) {
529 wfDebug( __METHOD__ .
": showing missing article\n" );
531 $this->mPage->doViewUpdates(
$user );
535 # Try the parser cache
536 if ( $useParserCache ) {
537 $this->mParserOutput = $parserCache->get( $this->mPage, $parserOptions );
539 if ( $this->mParserOutput !==
false ) {
541 wfDebug( __METHOD__ .
": showing parser cache contents for current rev permalink\n" );
544 wfDebug( __METHOD__ .
": showing parser cache contents\n" );
546 $outputPage->addParserOutput( $this->mParserOutput, $poOptions );
547 # Ensure that UI elements requiring revision ID have
548 # the correct version information.
549 $outputPage->setRevisionId( $this->mPage->getLatest() );
550 # Preload timestamp to avoid a DB hit
551 $cachedTimestamp = $this->mParserOutput->getTimestamp();
552 if ( $cachedTimestamp !==
null ) {
553 $outputPage->setRevisionTimestamp( $cachedTimestamp );
554 $this->mPage->setTimestamp( $cachedTimestamp );
561 # This will set $this->mRevision if needed
564 # Are we looking at an old revision
565 if ( $oldid && $this->mRevision ) {
569 wfDebug( __METHOD__ .
": cannot view deleted revision\n" );
574 # Ensure that UI elements requiring revision ID have
575 # the correct version information.
577 # Preload timestamp to avoid a DB hit
578 $outputPage->setRevisionTimestamp( $this->mPage->getTimestamp() );
580 # Pages containing custom CSS or JavaScript get special treatment
581 if ( $this->
getTitle()->isSiteConfigPage() || $this->
getTitle()->isUserConfigPage() ) {
582 $dir = $this->
getContext()->getLanguage()->getDir();
585 $outputPage->wrapWikiMsg(
586 "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
589 } elseif ( !
Hooks::run(
'ArticleContentViewCustom',
592 # Allow extensions do their own custom view for certain pages
597 # Run the parse, protected by a pool counter
598 wfDebug( __METHOD__ .
": doing uncached parse\n" );
604 if ( !$poolArticleView->execute() ) {
605 $error = $poolArticleView->getError();
607 $outputPage->clearHTML();
608 $outputPage->enableClientCache(
false );
609 $outputPage->setRobotPolicy(
'noindex,nofollow' );
611 $errortext = $error->getWikiText(
false,
'view-pool-error' );
614 # Connection or timeout error
618 $this->mParserOutput = $poolArticleView->getParserOutput();
619 $outputPage->addParserOutput( $this->mParserOutput, $poOptions );
620 if ( $content->getRedirectTarget() ) {
621 $outputPage->addSubtitle(
"<span id=\"redirectsub\">" .
622 $this->
getContext()->msg(
'redirectpagesub' )->parse() .
"</span>" );
625 # Don't cache a dirty ParserOutput object
626 if ( $poolArticleView->getIsDirty() ) {
627 $outputPage->setCdnMaxage( 0 );
628 $outputPage->addHTML(
"<!-- parser cache is expired, " .
629 "sending anyway due to pool overload-->\n" );
634 # Should be unreachable, but just in case...
640 # Get the ParserOutput actually *displayed* here.
641 # Note that $this->mParserOutput is the *current*/oldid version output.
642 $pOutput = ( $outputDone instanceof ParserOutput )
644 : $this->mParserOutput;
646 # Adjust title for main page & pages with displaytitle
651 # For the main page, overwrite the <title> element with the con-
652 # tents of 'pagetitle-view-mainpage' instead of the default (if
654 # This message always exists because it is in the i18n files
655 if ( $this->
getTitle()->isMainPage() ) {
656 $msg =
wfMessage(
'pagetitle-view-mainpage' )->inContentLanguage();
657 if ( !$msg->isDisabled() ) {
658 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->
text() );
662 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
663 # This could use getTouched(), but that could be scary for major template edits.
666 # Check for any __NOINDEX__ tags on the page using $pOutput
668 $outputPage->setIndexPolicy( $policy[
'index'] );
669 $outputPage->setFollowPolicy( $policy[
'follow'] );
672 $this->mPage->doViewUpdates(
$user, $oldid );
674 # Load the postEdit module if the user just saved this revision
675 # See also EditPage::setPostEditCookie
678 $postEdit =
$request->getCookie( $cookieKey );
680 # Clear the cookie. This also prevents caching of the response.
681 $request->response()->clearCookie( $cookieKey );
682 $outputPage->addJsConfigVars(
'wgPostEdit', $postEdit );
683 $outputPage->addModules(
'mediawiki.action.view.postEdit' );
692 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
693 $titleText = $pOutput->getTitleText();
694 if ( strval( $titleText ) !==
'' ) {
695 $this->
getContext()->getOutput()->setPageTitle( $titleText );
708 $diffOnly =
$request->getBool(
'diffonly',
$user->getOption(
'diffonly' ) );
709 $purge =
$request->getVal(
'action' ) ==
'purge';
717 $msg = $this->
getContext()->msg(
'difference-missing-revision' )
721 $this->
getContext()->getOutput()->addHTML( $msg );
725 $contentHandler =
$rev->getContentHandler();
726 $de = $contentHandler->createDifferenceEngine(
736 $this->mRevIdFetched = $de->mNewid;
737 $de->showDiffPage( $diffOnly );
741 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
743 $this->mPage->doViewUpdates(
$user, (
int)$new );
756 $ns = $this->
getTitle()->getNamespace();
758 # Don't index user and user talk pages for blocked users (T13443)
760 $specificTarget =
null;
762 $titleText = $this->
getTitle()->getText();
764 $vagueTarget = $titleText;
766 $specificTarget = $titleText;
770 'index' =>
'noindex',
771 'follow' =>
'nofollow'
776 if ( $this->mPage->getId() === 0 || $this->
getOldID() ) {
777 # Non-articles (special pages etc), and old revisions
779 'index' =>
'noindex',
780 'follow' =>
'nofollow'
782 } elseif ( $this->
getContext()->getOutput()->isPrintable() ) {
783 # Discourage indexing of printable versions, but encourage following
785 'index' =>
'noindex',
788 } elseif ( $this->
getContext()->getRequest()->getInt(
'curid' ) ) {
789 # For ?curid=x urls, disallow indexing
791 'index' =>
'noindex',
796 # Otherwise, construct the policy based on the various config variables.
800 # Honour customised robot policies for this namespace
801 $policy = array_merge(
806 if ( $this->
getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
807 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
808 # a final sanity check that we have really got the parser output.
809 $policy = array_merge(
811 [
'index' => $pOutput->getIndexPolicy() ]
816 # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
817 $policy = array_merge(
834 if ( is_array( $policy ) ) {
836 } elseif ( !$policy ) {
840 $policy = explode(
',', $policy );
841 $policy = array_map(
'trim', $policy );
844 foreach ( $policy
as $var ) {
845 if ( in_array( $var, [
'index',
'noindex' ] ) ) {
846 $arr[
'index'] = $var;
847 } elseif ( in_array( $var, [
'follow',
'nofollow' ] ) ) {
848 $arr[
'follow'] = $var;
866 $outputPage =
$context->getOutput();
868 $rdfrom =
$request->getVal(
'rdfrom' );
872 unset(
$query[
'rdfrom'] );
876 $query[
'redirect'] =
'no';
880 if ( isset( $this->mRedirectedFrom ) ) {
882 $articlePage = $this;
886 if (
Hooks::run(
'ArticleViewRedirect', [ &$articlePage ] ) ) {
888 $this->mRedirectedFrom,
891 [
'redirect' =>
'no' ]
894 $outputPage->addSubtitle(
"<span class=\"mw-redirectedfrom\">" .
895 $context->msg(
'redirectedfrom' )->rawParams( $redir )->parse()
900 $outputPage->addJsConfigVars( [
901 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
903 $outputPage->addModules(
'mediawiki.action.view.redirect' );
906 $outputPage->setCanonicalUrl( $this->
getTitle()->getCanonicalURL() );
909 $outputPage->setRedirectedFrom( $this->mRedirectedFrom );
913 } elseif ( $rdfrom ) {
918 $outputPage->addSubtitle(
"<span class=\"mw-redirectedfrom\">" .
919 $context->msg(
'redirectedfrom' )->rawParams( $redir )->parse()
923 $outputPage->addJsConfigVars( [
924 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
926 $outputPage->addModules(
'mediawiki.action.view.redirect' );
940 if ( $this->
getTitle()->isTalkPage() ) {
941 if ( !
wfMessage(
'talkpageheader' )->isDisabled() ) {
942 $this->
getContext()->getOutput()->wrapWikiMsg(
943 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
954 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
958 $this->
getContext()->getOutput()->addWikiMsg(
'anontalkpagetext' );
964 Hooks::run(
'ArticleViewFooter', [ $this, $patrolFooterShown ] );
979 $outputPage = $this->
getContext()->getOutput();
992 if ( $this->mRevision
1001 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1002 $key =
$cache->makeKey(
'unpatrollable-page',
$title->getArticleID() );
1003 if (
$cache->get( $key ) ) {
1008 $oldestRevisionTimestamp =
$dbr->selectField(
1010 'MIN( rev_timestamp )',
1011 [
'rev_page' =>
$title->getArticleID() ],
1020 $recentPageCreation =
false;
1021 if ( $oldestRevisionTimestamp
1025 $recentPageCreation =
true;
1029 'rc_timestamp' => $oldestRevisionTimestamp,
1030 'rc_namespace' =>
$title->getNamespace(),
1031 'rc_cur_id' =>
$title->getArticleID()
1037 $markPatrolledMsg =
wfMessage(
'markaspatrolledtext' );
1045 $recentFileUpload =
false;
1049 $newestUploadTimestamp =
$dbr->selectField(
1051 'MAX( img_timestamp )',
1052 [
'img_name' =>
$title->getDBkey() ],
1055 if ( $newestUploadTimestamp
1059 $recentFileUpload =
true;
1063 'rc_log_type' =>
'upload',
1064 'rc_timestamp' => $newestUploadTimestamp,
1066 'rc_cur_id' =>
$title->getArticleID()
1072 $markPatrolledMsg =
wfMessage(
'markaspatrolledtext-file' );
1077 if ( !$recentPageCreation && !$recentFileUpload ) {
1082 $cache->set( $key,
'1' );
1094 if ( $rc->getAttribute(
'rc_patrolled' ) ) {
1099 $cache->set( $key,
'1' );
1104 if ( $rc->getPerformer()->equals(
$user ) ) {
1110 $outputPage->preventClickjacking();
1112 $outputPage->addModules(
'mediawiki.page.patrol.ajax' );
1117 $markPatrolledMsg->escaped(),
1120 'action' =>
'markpatrolled',
1121 'rcid' => $rc->getAttribute(
'rc_id' ),
1125 $outputPage->addHTML(
1126 "<div class='patrollink' data-mw='interface'>" .
1127 wfMessage(
'markaspatrolledlink' )->rawParams(
$link )->escaped() .
1141 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1142 $cache->delete(
$cache->makeKey(
'unpatrollable-page', $articleID ) );
1152 $outputPage = $this->
getContext()->getOutput();
1154 $validUserPage =
false;
1158 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1162 $rootPart = explode(
'/',
$title->getText() )[0];
1168 $outputPage->wrapWikiMsg(
"<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1171 # Show log extract if the user is currently blocked
1179 'showIfEmpty' =>
false,
1181 'blocked-notice-logextract',
1182 $user->getName() # Support GENDER
in notice
1186 $validUserPage = !
$title->isSubpage();
1188 $validUserPage = !
$title->isSubpage();
1192 Hooks::run(
'ShowMissingArticle', [ $this ] );
1194 # Show delete and move logs if there were any such events.
1195 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1196 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1197 $cache = MediaWikiServices::getInstance()->getMainObjectStash();
1198 $key =
$cache->makeKey(
'page-recent-delete', md5(
$title->getPrefixedText() ) );
1199 $loggedIn = $this->
getContext()->getUser()->isLoggedIn();
1200 $sessionExists = $this->
getContext()->getRequest()->getSession()->isPersistent();
1201 if ( $loggedIn ||
$cache->get( $key ) || $sessionExists ) {
1202 $logTypes = [
'delete',
'move',
'protect' ];
1206 $conds = [
'log_action != ' .
$dbr->addQuotes(
'revision' ) ];
1208 Hooks::run(
'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1217 'showIfEmpty' =>
false,
1218 'msgKey' => [ $loggedIn || $sessionExists
1219 ?
'moveddeleted-notice'
1220 :
'moveddeleted-notice-recent'
1226 if ( !$this->mPage->hasViewableContent() &&
$wgSend404Code && !$validUserPage ) {
1229 $this->
getContext()->getRequest()->response()->statusHeader( 404 );
1234 $outputPage->setIndexPolicy( $policy[
'index'] );
1235 $outputPage->setFollowPolicy( $policy[
'follow'] );
1237 $hookResult =
Hooks::run(
'BeforeDisplayNoArticleText', [ $this ] );
1239 if ( !$hookResult ) {
1243 # Show error message
1249 $text =
wfMessage(
'missing-revision', $oldid )->plain();
1250 } elseif (
$title->quickUserCan(
'create', $this->getContext()->getUser() )
1251 &&
$title->quickUserCan(
'edit', $this->getContext()->getUser() )
1253 $message = $this->
getContext()->getUser()->isLoggedIn() ?
'noarticletext' :
'noarticletextanon';
1256 $text =
wfMessage(
'noarticletext-nopermission' )->plain();
1259 $dir = $this->
getContext()->getLanguage()->getDir();
1262 'class' =>
"noarticletext mw-content-$dir",
1265 ] ) .
"\n$text\n</div>" );
1281 $outputPage = $this->
getContext()->getOutput();
1285 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1286 'rev-deleted-text-permission' );
1290 } elseif ( $this->
getContext()->getRequest()->getInt(
'unhide' ) != 1 ) {
1291 # Give explanation and add a link to view the revision...
1292 $oldid = intval( $this->
getOldID() );
1293 $link = $this->
getTitle()->getFullURL(
"oldid={$oldid}&unhide=1" );
1295 'rev-suppressed-text-unhide' :
'rev-deleted-text-unhide';
1296 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1303 'rev-suppressed-text-view' :
'rev-deleted-text-view';
1304 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1320 $articlePage = $this;
1322 if ( !
Hooks::run(
'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1329 # Cascade unhide param in links for easy deletion browsing
1332 $extraParams[
'unhide'] = 1;
1335 if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
1341 $timestamp = $revision->getTimestamp();
1343 $current = ( $oldid == $this->mPage->getLatest() );
1344 $language =
$context->getLanguage();
1347 $td = $language->userTimeAndDate( $timestamp,
$user );
1348 $tddate = $language->userDate( $timestamp,
$user );
1349 $tdtime = $language->userTime( $timestamp,
$user );
1351 # Show user links if allowed to see them. If hidden, then show them only if requested...
1354 $infomsg = $current && !
$context->msg(
'revision-info-current' )->isDisabled()
1355 ?
'revision-info-current'
1358 $outputPage =
$context->getOutput();
1359 $revisionInfo =
"<div id=\"mw-{$infomsg}\">" .
1361 ->rawParams( $userlinks )
1362 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1368 ?
$context->msg(
'currentrevisionlink' )->escaped()
1371 $context->msg(
'currentrevisionlink' )->escaped(),
1376 ?
$context->msg(
'diff' )->escaped()
1379 $context->msg(
'diff' )->escaped(),
1386 $prev = $this->
getTitle()->getPreviousRevisionID( $oldid );
1390 $context->msg(
'previousrevision' )->escaped(),
1393 'direction' =>
'prev',
1397 :
$context->msg(
'previousrevision' )->escaped();
1401 $context->msg(
'diff' )->escaped(),
1408 :
$context->msg(
'diff' )->escaped();
1409 $nextlink = $current
1410 ?
$context->msg(
'nextrevision' )->escaped()
1413 $context->msg(
'nextrevision' )->escaped(),
1416 'direction' =>
'next',
1420 $nextdiff = $current
1421 ?
$context->msg(
'diff' )->escaped()
1424 $context->msg(
'diff' )->escaped(),
1433 if ( $cdel !==
'' ) {
1438 $outputPage->addSubtitle(
"<div class=\"mw-revision\">" . $revisionInfo .
1439 "<div id=\"mw-revision-nav\">" . $cdel .
1440 $context->msg(
'revision-nav' )->rawParams(
1441 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1442 )->escaped() .
"</div></div>" );
1458 public function viewRedirect( $target, $appendSubtitle =
true, $forceKnown =
false ) {
1461 if ( $appendSubtitle ) {
1464 $out->addModuleStyles(
'mediawiki.action.view.redirectPage' );
1465 return static::getRedirectHeaderHtml(
$lang, $target, $forceKnown );
1481 if ( !is_array( $target ) ) {
1482 $target = [ $target ];
1485 $html =
'<ul class="redirectText">';
1490 htmlspecialchars(
$title->getFullText() ),
1493 $title->isRedirect() ? [
'redirect' =>
'no' ] : [],
1494 ( $forceKnown ? [
'known',
'noclasses' ] : [] )
1499 $redirectToText =
wfMessage(
'redirectto' )->inLanguage(
$lang )->escaped();
1501 return '<div class="redirectMsg">' .
1502 '<p>' . $redirectToText .
'</p>' .
1517 'namespace-' . $this->
getTitle()->getNamespace() .
'-helppage'
1521 if ( !$msg->isDisabled() ) {
1523 $out->addHelpLink( $helpUrl,
true );
1525 $out->addHelpLink( $to, $overrideBaseUrl );
1533 $this->
getContext()->getRequest()->response()->header(
'X-Robots-Tag: noindex' );
1534 $this->
getContext()->getOutput()->setArticleBodyOnly(
true );
1535 $this->disableSectionEditForRender =
true;
1557 public function delete() {
1558 # This code desperately needs to be totally rewritten
1566 $permissionErrors =
$title->getUserPermissionsErrors(
'delete',
$user );
1567 if (
count( $permissionErrors ) ) {
1571 # Read-only check...
1576 # Better double-check that it hasn't been deleted yet!
1577 $this->mPage->loadPageData(
1578 $request->wasPosted() ? WikiPage::READ_LATEST : WikiPage::READ_NORMAL
1580 if ( !$this->mPage->exists() ) {
1581 $deleteLogPage =
new LogPage(
'delete' );
1582 $outputPage =
$context->getOutput();
1583 $outputPage->setPageTitle(
$context->msg(
'cannotdelete-title',
$title->getPrefixedText() ) );
1584 $outputPage->wrapWikiMsg(
"<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1587 $outputPage->addHTML(
1588 Xml::element(
'h2',
null, $deleteLogPage->getName()->text() )
1599 $deleteReasonList =
$request->getText(
'wpDeleteReasonList',
'other' );
1600 $deleteReason =
$request->getText(
'wpReason' );
1602 if ( $deleteReasonList ==
'other' ) {
1603 $reason = $deleteReason;
1604 } elseif ( $deleteReason !=
'' ) {
1606 $colonseparator =
wfMessage(
'colon-separator' )->inContentLanguage()->text();
1607 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1609 $reason = $deleteReasonList;
1613 [
'delete', $this->
getTitle()->getPrefixedText() ] )
1615 # Flag to hide all contents of the archived revisions
1616 $suppress =
$request->getCheck(
'wpSuppress' ) &&
$user->isAllowed(
'suppressrevision' );
1618 $this->
doDelete( $reason, $suppress );
1626 $hasHistory =
false;
1630 }
catch ( Exception
$e ) {
1631 # if a page is horribly broken, we still want to be able to
1632 # delete it. So be lenient about errors here.
1633 wfDebug(
"Error while building auto delete summary: $e" );
1639 if ( $hasHistory ) {
1648 $revisions = $edits = (int)
$dbr->selectField(
1651 [
'rev_page' =>
$title->getArticleID() ],
1657 '<strong class="mw-delete-warning-revisions">' .
1658 $context->msg(
'historywarning' )->numParams( $revisions )->parse() .
1660 $context->msg(
'history' )->escaped(),
1662 [
'action' =>
'history' ] ) .
1666 if (
$title->isBigDeletion() ) {
1668 $context->getOutput()->wrapWikiMsg(
"<div class='error'>\n$1\n</div>\n",
1670 'delete-warning-toobig',
1686 wfDebug(
"Article::confirmDelete\n" );
1690 $outputPage = $ctx->getOutput();
1691 $outputPage->setPageTitle(
wfMessage(
'delete-confirm',
$title->getPrefixedText() ) );
1692 $outputPage->addBacklinkSubtitle(
$title );
1693 $outputPage->setRobotPolicy(
'noindex,nofollow' );
1694 $outputPage->addModules(
'mediawiki.action.delete' );
1696 $backlinkCache =
$title->getBacklinkCache();
1697 if ( $backlinkCache->hasLinks(
'pagelinks' ) || $backlinkCache->hasLinks(
'templatelinks' ) ) {
1698 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1699 'deleting-backlinks-warning' );
1702 $subpageQueryLimit = 51;
1703 $subpages =
$title->getSubpages( $subpageQueryLimit );
1704 $subpageCount =
count( $subpages );
1705 if ( $subpageCount > 0 ) {
1706 $outputPage->wrapWikiMsg(
"<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1707 [
'deleting-subpages-warning', Message::numParam( $subpageCount ) ] );
1709 $outputPage->addWikiMsg(
'confirmdeletetext' );
1711 Hooks::run(
'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1714 $checkWatch =
$user->getBoolOption(
'watchdeletion' ) ||
$user->isWatched(
$title );
1716 $outputPage->enableOOUI();
1719 $ctx->msg(
'deletereason-dropdown' )->inContentLanguage()->text(),
1720 [
'other' => $ctx->msg(
'deletereasonotherlist' )->inContentLanguage()->text() ]
1724 $fields[] =
new OOUI\FieldLayout(
1725 new OOUI\DropdownInputWidget( [
1726 'name' =>
'wpDeleteReasonList',
1727 'inputId' =>
'wpDeleteReasonList',
1729 'infusable' =>
true,
1734 'label' => $ctx->msg(
'deletecomment' )->text(),
1743 $oldCommentSchema = $conf->get(
'CommentTableSchemaMigrationStage' ) ===
MIGRATION_OLD;
1744 $fields[] =
new OOUI\FieldLayout(
1745 new OOUI\TextInputWidget( [
1746 'name' =>
'wpReason',
1747 'inputId' =>
'wpReason',
1750 'infusable' =>
true,
1752 'autofocus' =>
true,
1755 'label' => $ctx->msg(
'deleteotherreason' )->text(),
1760 if (
$user->isLoggedIn() ) {
1761 $fields[] =
new OOUI\FieldLayout(
1762 new OOUI\CheckboxInputWidget( [
1763 'name' =>
'wpWatch',
1764 'inputId' =>
'wpWatch',
1766 'selected' => $checkWatch,
1769 'label' => $ctx->msg(
'watchthis' )->text(),
1770 'align' =>
'inline',
1771 'infusable' =>
true,
1776 if (
$user->isAllowed(
'suppressrevision' ) ) {
1777 $fields[] =
new OOUI\FieldLayout(
1778 new OOUI\CheckboxInputWidget( [
1779 'name' =>
'wpSuppress',
1780 'inputId' =>
'wpSuppress',
1784 'label' => $ctx->msg(
'revdelete-suppress' )->text(),
1785 'align' =>
'inline',
1786 'infusable' =>
true,
1791 $fields[] =
new OOUI\FieldLayout(
1792 new OOUI\ButtonInputWidget( [
1793 'name' =>
'wpConfirmB',
1794 'inputId' =>
'wpConfirmB',
1796 'value' => $ctx->msg(
'deletepage' )->text(),
1797 'label' => $ctx->msg(
'deletepage' )->text(),
1798 'flags' => [
'primary',
'destructive' ],
1806 $fieldset =
new OOUI\FieldsetLayout( [
1807 'label' => $ctx->msg(
'delete-legend' )->text(),
1808 'id' =>
'mw-delete-table',
1812 $form =
new OOUI\FormLayout( [
1814 'action' =>
$title->getLocalURL(
'action=delete' ),
1815 'id' =>
'deleteconfirm',
1817 $form->appendContent(
1819 new OOUI\HtmlSnippet(
1824 $outputPage->addHTML(
1825 new OOUI\PanelLayout( [
1826 'classes' => [
'deletepage-wrapper' ],
1827 'expanded' =>
false,
1834 if (
$user->isAllowed(
'editinterface' ) ) {
1836 $ctx->msg(
'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1837 wfMessage(
'delete-edit-reasonlist' )->escaped(),
1839 [
'action' =>
'edit' ]
1841 $outputPage->addHTML(
'<p class="mw-delete-editreasons">' .
$link .
'</p>' );
1844 $deleteLogPage =
new LogPage(
'delete' );
1845 $outputPage->addHTML(
Xml::element(
'h2',
null, $deleteLogPage->getName()->text() ) );
1854 public function doDelete( $reason, $suppress =
false ) {
1857 $outputPage =
$context->getOutput();
1859 $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0,
true, $error,
$user );
1862 $deleted = $this->
getTitle()->getPrefixedText();
1864 $outputPage->setPageTitle(
wfMessage(
'actioncomplete' ) );
1865 $outputPage->setRobotPolicy(
'noindex,nofollow' );
1867 $loglink =
'[[Special:Log/delete|' .
wfMessage(
'deletionlog' )->text() .
']]';
1869 $outputPage->addWikiMsg(
'deletedtext',
wfEscapeWikiText( $deleted ), $loglink );
1873 $outputPage->returnToMain(
false );
1875 $outputPage->setPageTitle(
1877 $this->
getTitle()->getPrefixedText() )
1880 if ( $error ==
'' ) {
1881 $outputPage->addWikiText(
1882 "<div class=\"error mw-error-cannotdelete\">\n" .
$status->getWikiText() .
"\n</div>"
1884 $deleteLogPage =
new LogPage(
'delete' );
1885 $outputPage->addHTML(
Xml::element(
'h2',
null, $deleteLogPage->getName()->text() ) );
1893 $outputPage->addHTML( $error );
1908 static $called =
false;
1911 wfDebug(
"Article::tryFileCache(): called twice!?\n" );
1918 if (
$cache->isCacheGood( $this->mPage->getTouched() ) ) {
1919 wfDebug(
"Article::tryFileCache(): about to load file\n" );
1923 wfDebug(
"Article::tryFileCache(): starting buffer\n" );
1924 ob_start( [ &
$cache,
'saveToFileCache' ] );
1927 wfDebug(
"Article::tryFileCache(): not cacheable\n" );
1942 $cacheable = $this->mPage->getId()
1943 && !$this->mRedirectedFrom && !$this->
getTitle()->isRedirect();
1947 $articlePage = $this;
1948 $cacheable =
Hooks::run(
'IsFileCacheable', [ &$articlePage ] );
1971 if (
$user ===
null ) {
1974 $parserOptions = $this->mPage->makeParserOptions(
$user );
1977 return $this->mPage->getParserOutput( $parserOptions, $oldid );
1987 if ( $this->mParserOptions ) {
1988 throw new MWException(
"can't change parser options after they have already been set" );
1992 $this->mParserOptions = clone
$options;
2000 if ( !$this->mParserOptions ) {
2001 $this->mParserOptions = $this->mPage->makeParserOptions( $this->
getContext() );
2027 wfDebug( __METHOD__ .
" called and \$mContext is null. " .
2028 "Return RequestContext::getMain(); for sanity\n" );
2041 if ( property_exists( $this->mPage,
$fname ) ) {
2042 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2043 return $this->mPage->$fname;
2045 trigger_error(
'Inaccessible property via __get(): ' .
$fname, E_USER_NOTICE );
2056 if ( property_exists( $this->mPage,
$fname ) ) {
2057 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2058 $this->mPage->$fname = $fvalue;
2060 } elseif ( !in_array(
$fname, [
'mContext',
'mPage' ] ) ) {
2061 $this->mPage->$fname = $fvalue;
2063 trigger_error(
'Inaccessible property via __set(): ' .
$fname, E_USER_NOTICE );
2072 return $this->mPage->checkFlags( $flags );
2080 return $this->mPage->checkTouched();
2088 $this->mPage->clearPreparedEdit();
2096 $reason, $suppress =
false, $u1 =
null, $u2 =
null, &$error =
'',
User $user =
null,
2099 return $this->mPage->doDeleteArticleReal(
2100 $reason, $suppress, $u1, $u2, $error,
$user, $tags
2109 return $this->mPage->doDeleteUpdates( $id, $content );
2121 return $this->mPage->doEditContent( $content, $summary, $flags, $baseRevId,
2122 $user, $serialFormat
2131 return $this->mPage->doEditUpdates( $revision,
$user,
$options );
2141 return $this->mPage->doPurge();
2149 $this->mPage->doViewUpdates(
$user, $oldid );
2157 return $this->mPage->exists();
2165 return $this->mPage->followRedirect();
2173 return $this->mPage->getActionOverrides();
2181 return $this->mPage->getAutoDeleteReason( $hasHistory );
2189 return $this->mPage->getCategories();
2197 return $this->mPage->getComment( $audience,
$user );
2205 return $this->mPage->getContentHandler();
2213 return $this->mPage->getContentModel();
2221 return $this->mPage->getContributors();
2229 return $this->mPage->getCreator( $audience,
$user );
2237 return $this->mPage->getDeletionUpdates( $content );
2245 return $this->mPage->getHiddenCategories();
2253 return $this->mPage->getId();
2261 return $this->mPage->getLatest();
2269 return $this->mPage->getLinksTimestamp();
2277 return $this->mPage->getMinorEdit();
2285 return $this->mPage->getOldestRevision();
2293 return $this->mPage->getRedirectTarget();
2301 return $this->mPage->getRedirectURL( $rt );
2309 return $this->mPage->getRevision();
2317 return $this->mPage->getTimestamp();
2325 return $this->mPage->getTouched();
2333 return $this->mPage->getUndoContent( $undo, $undoafter );
2341 return $this->mPage->getUser( $audience,
$user );
2349 return $this->mPage->getUserText( $audience,
$user );
2357 return $this->mPage->hasViewableContent();
2365 return $this->mPage->insertOn( $dbw, $pageId );
2373 array $expiry, $cascade, $reason,
$user =
null
2375 return $this->mPage->insertProtectNullRevision( $revCommentMsg, $limit,
2376 $expiry, $cascade, $reason,
$user
2385 return $this->mPage->insertRedirect();
2393 return $this->mPage->insertRedirectEntry( $rt, $oldLatest );
2401 return $this->mPage->isCountable( $editInfo );
2409 return $this->mPage->isRedirect();
2417 return $this->mPage->loadFromRow( $data, $from );
2425 $this->mPage->loadPageData( $from );
2433 return $this->mPage->lockAndGetLatest();
2441 return $this->mPage->makeParserOptions(
$context );
2449 return $this->mPage->pageDataFromId(
$dbr, $id,
$options );
2466 $serialFormat =
null, $useCache =
true
2468 return $this->mPage->prepareContentForEdit(
2469 $content, $revision,
$user,
2470 $serialFormat, $useCache
2479 return $this->mPage->protectDescription( $limit, $expiry );
2487 return $this->mPage->protectDescriptionLog( $limit, $expiry );
2495 $sectionTitle =
'', $baseRevId =
null
2497 return $this->mPage->replaceSectionAtRev( $sectionId, $sectionContent,
2498 $sectionTitle, $baseRevId
2507 $sectionId,
Content $sectionContent, $sectionTitle =
'', $edittime =
null
2509 return $this->mPage->replaceSectionContent(
2510 $sectionId, $sectionContent, $sectionTitle, $edittime
2519 return $this->mPage->setTimestamp( $ts );
2527 return $this->mPage->shouldCheckParserCache( $parserOptions, $oldId );
2535 return $this->mPage->supportsSections();
2543 return $this->mPage->triggerOpportunisticLinksUpdate( $parserOutput );
2551 return $this->mPage->updateCategoryCounts( $added, $deleted, $id );
2559 return $this->mPage->updateIfNewerOn( $dbw, $revision );
2567 return $this->mPage->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect );
2575 $lastRevIsRedirect =
null
2577 return $this->mPage->updateRevisionOn( $dbw, $revision, $lastRevision,
2593 return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason,
$user );
2604 &$cascade = 0, $expiry = []
2606 return $this->mPage->doUpdateRestrictions(
2624 $reason, $suppress =
false, $u1 =
null, $u2 =
null, &$error =
''
2626 return $this->mPage->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2640 return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails,
$user );
2652 $guser = is_null( $guser ) ? $this->
getContext()->getUser() : $guser;
2653 return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2661 $title = $this->mPage->getTitle();
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
$wgSend404Code
Some web hosts attempt to rewrite all responses with a 404 (not found) status code,...
showMissingArticle()
Show the error text for a missing article.
checkFlags( $flags)
Call to WikiPage function for backwards compatibility.
Set options of the Parser.
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
static errorBox( $html, $heading='')
Return an error box.
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 account $user
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
isRedirect()
Call to WikiPage function for backwards compatibility.
getCategories()
Call to WikiPage function for backwards compatibility.
static formatRobotPolicy( $policy)
Converts a String robot policy into an associative array, to allow merging of several policies using ...
getRedirectTarget()
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.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
doDeleteUpdates( $id, Content $content=null)
Call to WikiPage function for backwards compatibility.
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
static listDropDownOptionsOoui( $options)
Convert options for a drop-down box into a format accepted by OOUI\DropdownInputWidget etc.
getContentModel()
Call to WikiPage function for backwards compatibility.
getUserText( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
getLinksTimestamp()
Call to WikiPage function for backwards compatibility.
bool $disableSectionEditForRender
Whether render() was called.
getOldIDFromRequest()
Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.
showPatrolFooter()
If patrol is possible, output a patrol UI box.
if(!isset( $args[0])) $lang
static newFromConds( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
tryFileCache()
checkLastModified returns true if it has taken care of all output to the client that is necessary for...
getContentHandler()
Call to WikiPage function for backwards compatibility.
clearPreparedEdit()
Call to WikiPage function for backwards compatibility.
Page view caching in the file system.
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
lockAndGetLatest()
Call to WikiPage function for backwards compatibility.
ParserOutput $mParserOutput
supportsSections()
Call to WikiPage function for backwards compatibility.
getOldestRevision()
Call to WikiPage function for backwards compatibility.
getDeletionUpdates(Content $content=null)
Call to WikiPage function for backwards compatibility.
checkTouched()
Call to WikiPage function for backwards compatibility.
getRevision()
Call to WikiPage function for backwards compatibility.
Special handling for category description pages, showing pages, subcategories and file that belong to...
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Class representing a MediaWiki article and history.
getRobotPolicy( $action, $pOutput=null)
Get the robot policy to be used for the current view.
doDeleteArticle( $reason, $suppress=false, $u1=null, $u2=null, &$error='')
getCreator( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
wfReadOnly()
Check whether the wiki is in read-only mode.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
showDiffPage()
Show a diff page according to current request variables.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
$wgArticleRobotPolicies
Robot policies per article.
Class for viewing MediaWiki file description pages.
Show an error when a user tries to do something they do not have the necessary permissions for.
confirmDelete( $reason)
Output deletion confirmation dialog.
IContextSource $mContext
The context this Article is executed in.
updateCategoryCounts(array $added, array $deleted, $id=0)
Call to WikiPage function for backwards compatibility.
adjustDisplayTitle(ParserOutput $pOutput)
Adjust title for pages with displaytitle, -{T|}- or language conversion.
showNamespaceHeader()
Show a header specific to the namespace currently being viewed, like [[MediaWiki:Talkpagetext]].
shouldCheckParserCache(ParserOptions $parserOptions, $oldId)
Call to WikiPage function for backwards compatibility.
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
static openElement( $element, $attribs=null)
This opens an XML element.
Content $mContentObject
Content of the revision we are working on.
$wgUseNPPatrol
Use new page patrolling to check new pages on Special:Newpages.
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
protectDescriptionLog(array $limit, array $expiry)
Call to WikiPage function for backwards compatibility.
unprotect()
action=unprotect handler (alias)
insertRedirect()
Call to WikiPage function for backwards compatibility.
null for the 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
getRedirectedFrom()
Get the page this view was redirected from.
fetchContentObject()
Get text content object Does NOT follow redirects.
updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect=null)
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.
getTouched()
Call to WikiPage function for backwards compatibility.
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
namespace and then decline to actually register it file or subcat img or subcat $title
getTitle()
Get the title object of the article.
updateRevisionOn( $dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
Call to WikiPage function for backwards compatibility.
render()
Handle action=render.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user=null)
Call to WikiPage function for backwards compatibility.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
exists()
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.
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static revUserTools( $rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
__construct(Title $title, $oldId=null)
Constructor and clear the article.
null for the wiki Added in
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
showDeletedRevisionHeader()
If the revision requested for view is deleted, check permissions.
isFileCacheable( $mode=HTMLFileCache::MODE_NORMAL)
Check if the page can be cached.
doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user=null)
getTitle()
Get the title object of the article.
Class to simplify the use of log pages.
setOldSubtitle( $oldid=0)
Generate the navigation links when browsing through an article revisions It shows the information as:...
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
getPage()
Get the WikiPage object of this instance.
getContext()
Gets the context this Article is executed in.
static isIP( $name)
Does the string match an anonymous IP address?
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
getComment( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
pageDataFromId( $dbr, $id, $options=[])
Call to WikiPage function for backwards compatibility.
insertOn( $dbw, $pageId=null)
Call to WikiPage function for backwards compatibility.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
getRedirectURL( $rt)
Call to WikiPage function for backwards compatibility.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
static newFromID( $id)
Constructor from a page id.
getUndoContent(Revision $undo, Revision $undoafter=null)
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.
$wgDeleteRevisionsLimit
Optional to restrict deletion of pages with higher revision counts to users with the 'bigdelete' perm...
int $mRevIdFetched
Revision ID of revision we are working on.
doEditContent(Content $content, $summary, $flags=0, $baseRevId=false, User $user=null, $serialFormat=null)
Call to WikiPage function for backwards compatibility.
$wgUseFilePatrol
Use file patrolling to check new files on Special:Newfiles.
getLatest()
Call to WikiPage function for backwards compatibility.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
isCurrent()
Returns true if the currently-referenced revision is the current edit to this page (and it exists).
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 makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
getAutoDeleteReason(&$hasHistory)
Call to WikiPage function for backwards compatibility.
bool $mContentLoaded
Is the content ($mContent) already loaded?
setParserOptions(ParserOptions $options)
Override the ParserOptions used to render the primary article wikitext.
isCountable( $editInfo=false)
Call to WikiPage function for backwards compatibility.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Title $mRedirectedFrom
Title from which we were redirected here.
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
doDelete( $reason, $suppress=false)
Perform a deletion and output success or failure messages.
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
doPurge()
Call to WikiPage function for backwards compatibility.
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.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
hasViewableContent()
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.
getContributors()
Call to WikiPage function for backwards compatibility.
loadFromRow( $data, $from)
Call to WikiPage function for backwards compatibility.
static getRevDeleteLink(User $user, Revision $rev, Title $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
protect()
action=protect handler
getTimestamp()
Call to WikiPage function for backwards compatibility.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getMinorEdit()
Call to WikiPage function for backwards compatibility.
commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser=null)
$wgNamespaceRobotPolicies
Robot policies per namespaces.
getParserOutput( $oldid=null, User $user=null)
#-
ParserOptions $mParserOptions
ParserOptions object for $wgUser articles.
getUser( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
getContentObject()
Returns a Content object representing the pages effective display content, not necessarily the revisi...
followRedirect()
Call to WikiPage function for backwards compatibility.
getHiddenCategories()
Call to WikiPage function for backwards compatibility.
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
static getMain()
Get the RequestContext object associated with the main request.
static isValid( $ip)
Validate an IP address.
setTimestamp( $ts)
Call to WikiPage function for backwards compatibility.
Interface for objects which can provide a MediaWiki context on request.
__get( $fname)
Use PHP's magic __get handler to handle accessing of raw WikiPage fields for backwards compatibility.
Base interface for content objects.
replaceSectionAtRev( $sectionId, Content $sectionContent, $sectionTitle='', $baseRevId=null)
Call to WikiPage function for backwards compatibility.
null for the 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
Represents a title within MediaWiki.
static makeUrl( $name, $urlaction='')
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
replaceSectionContent( $sectionId, Content $sectionContent, $sectionTitle='', $edittime=null)
Call to WikiPage function for backwards compatibility.
getRevIdFetched()
Use this to fetch the rev ID used on page views.
Wrapper allowing us to handle a system message as a Content object.
$wgEnableWriteAPI
Allow the API to be used to perform write operations (page edits, rollback, etc.) when an authorised ...
makeParserOptions( $context)
Call to WikiPage function for backwards compatibility.
showRedirectedFromHeader()
If this request is a redirect view, send "redirected from" subtitle to the output.
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
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...
usually copyright or history_copyright This message must be in HTML not wikitext & $link
getId()
Call to WikiPage function for backwards compatibility.
getActionOverrides()
Call to WikiPage function for backwards compatibility.
string bool $mRedirectUrl
URL to redirect to or false if none.
doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user)
updateRestrictions( $limit=[], $reason='', &$cascade=0, $expiry=[])
Revision $mRevision
Revision we are working on.
protectDescription(array $limit, array $expiry)
Call to WikiPage function for backwards compatibility.
getParserOptions()
Get parser options suitable for rendering the primary article wikitext.
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). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. '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
$wgRedirectSources
If local interwikis are set up which allow redirects, set this regexp to restrict URLs which will be ...
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 "<
updateIfNewerOn( $dbw, $revision)
Call to WikiPage function for backwards compatibility.
Class for viewing MediaWiki article and history.
pageDataFromTitle( $dbr, $title, $options=[])
Call to WikiPage function for backwards compatibility.
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 MediaWikiServices
$wgDebugToolbar
Display the new debugging toolbar.
triggerOpportunisticLinksUpdate(ParserOutput $parserOutput)
Call to WikiPage function for backwards compatibility.
$wgEnableAPI
Enable the MediaWiki API for convenient access to machine-readable data via api.php.
const POST_EDIT_COOKIE_KEY_PREFIX
Prefix of key for cookie used to pass post-edit state.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
setContext( $context)
Sets the context this Article is executed in.
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
insertRedirectEntry(Title $rt, $oldLatest=null)
Call to WikiPage function for backwards compatibility.
$wgDefaultRobotPolicy
Default robot policy.
getRevisionFetched()
Get the fetched Revision object depending on request parameters or null on failure.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
viewRedirect( $target, $appendSubtitle=true, $forceKnown=false)
Return the HTML for the top of a redirect page.
loadPageData( $from='fromdb')
Call to WikiPage function for backwards compatibility.
Internationalisation code.
doEditUpdates(Revision $revision, User $user, array $options=[])
Call to WikiPage function for backwards compatibility.
string $mContent
Text of the revision we are working on.
__set( $fname, $fvalue)
Use PHP's magic __set handler to handle setting of raw WikiPage fields for backwards compatibility.
showViewFooter()
Show the footer section of an ordinary page view.
WikiPage $mPage
The WikiPage object of this instance.
the array() calling protocol came about after MediaWiki 1.4rc1.
static getRedirectHeaderHtml(Language $lang, $target, $forceKnown=false)
Return the HTML for the top of a redirect page.
doDeleteArticleReal( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $user=null, $tags=[])
Call to WikiPage function for backwards compatibility.
static listDropDownOptions( $list, $params=[])
Build options for a drop-down box from a textual list.
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
generateReason(&$hasHistory)
static purgePatrolFooterCache( $articleID)
Purge the cache used to check if it is worth showing the patrol footer For example,...
doViewUpdates(User $user, $oldid=0)
Call to WikiPage function for backwards compatibility.
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