3 * User interface for page actions.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 use MediaWiki\MediaWikiServices
;
25 * Class for viewing MediaWiki article and history.
27 * This maintains WikiPage functions for backwards compatibility.
29 * @todo Move and rewrite code to an Action class
31 * See design.txt for an overview.
32 * Note: edit user interface and cache support functions have been
33 * moved to separate EditPage and HTMLFileCache classes.
35 class Article
implements Page
{
37 * @var IContextSource|null The context this Article is executed in.
38 * If null, REquestContext::getMain() is used.
42 /** @var WikiPage The WikiPage object of this instance */
46 * @var ParserOptions|null ParserOptions object for $wgUser articles.
47 * Initialized by getParserOptions by calling $this->mPage->makeParserOptions().
49 public $mParserOptions;
52 * @var string|null Text of the revision we are working on
58 * @var Content|null Content of the revision we are working on.
59 * Initialized by fetchContentObject().
62 public $mContentObject;
64 /** @var bool Is the content ($mContent) already loaded? */
65 public $mContentLoaded = false;
67 /** @var int|null The oldid of the article that is to be shown, 0 for the current revision */
70 /** @var Title|null Title from which we were redirected here, if any. */
71 public $mRedirectedFrom = null;
73 /** @var string|bool URL to redirect to or false if none */
74 public $mRedirectUrl = false;
76 /** @var int Revision ID of revision we are working on */
77 public $mRevIdFetched = 0;
80 * @var Revision|null Revision we are working on. Initialized by getOldIDFromRequest()
81 * or fetchContentObject().
83 public $mRevision = null;
86 * @var ParserOutput|null|false The ParserOutput generated for viewing the page,
87 * initialized by view(). If no ParserOutput could be generated, this is set to false.
89 public $mParserOutput;
92 * @var bool Whether render() was called. With the way subclasses work
93 * here, there doesn't seem to be any other way to stop calling
94 * OutputPage::enableSectionEditLinks() and still have it work as it did before.
96 private $disableSectionEditForRender = false;
99 * Constructor and clear the article
100 * @param Title $title Reference to a Title object.
101 * @param int|null $oldId Revision ID, null to fetch from request, zero for current
103 public function __construct( Title
$title, $oldId = null ) {
104 $this->mOldId
= $oldId;
105 $this->mPage
= $this->newPage( $title );
109 * @param Title $title
112 protected function newPage( Title
$title ) {
113 return new WikiPage( $title );
117 * Constructor from a page id
118 * @param int $id Article ID to load
119 * @return Article|null
121 public static function newFromID( $id ) {
122 $t = Title
::newFromID( $id );
123 return $t == null ?
null : new static( $t );
127 * Create an Article object of the appropriate class for the given page.
129 * @param Title $title
130 * @param IContextSource $context
133 public static function newFromTitle( $title, IContextSource
$context ) {
134 if ( NS_MEDIA
== $title->getNamespace() ) {
135 // FIXME: where should this go?
136 $title = Title
::makeTitle( NS_FILE
, $title->getDBkey() );
140 Hooks
::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
142 switch ( $title->getNamespace() ) {
144 $page = new ImagePage( $title );
147 $page = new CategoryPage( $title );
150 $page = new Article( $title );
153 $page->setContext( $context );
159 * Create an Article object of the appropriate class for the given page.
161 * @param WikiPage $page
162 * @param IContextSource $context
165 public static function newFromWikiPage( WikiPage
$page, IContextSource
$context ) {
166 $article = self
::newFromTitle( $page->getTitle(), $context );
167 $article->mPage
= $page; // override to keep process cached vars
172 * Get the page this view was redirected from
176 public function getRedirectedFrom() {
177 return $this->mRedirectedFrom
;
181 * Tell the page view functions that this view was redirected
182 * from another page on the wiki.
185 public function setRedirectedFrom( Title
$from ) {
186 $this->mRedirectedFrom
= $from;
190 * Get the title object of the article
192 * @return Title Title object of this page
194 public function getTitle() {
195 return $this->mPage
->getTitle();
199 * Get the WikiPage object of this instance
204 public function getPage() {
211 public function clear() {
212 $this->mContentLoaded
= false;
214 $this->mRedirectedFrom
= null; # Title object if set
215 $this->mRevIdFetched
= 0;
216 $this->mRedirectUrl
= false;
218 $this->mPage
->clear();
222 * Returns a Content object representing the pages effective display content,
223 * not necessarily the revision's content!
225 * Note that getContent does not follow redirects anymore.
226 * If you need to fetch redirectable content easily, try
227 * the shortcut in WikiPage::getRedirectTarget()
229 * This function has side effects! Do not use this function if you
230 * only want the real revision text if any.
232 * @return Content Return the content of this revision
236 protected function getContentObject() {
237 if ( $this->mPage
->getId() === 0 ) {
238 # If this is a MediaWiki:x message, then load the messages
239 # and return the message value for x.
240 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI
) {
241 $text = $this->getTitle()->getDefaultMessageText();
242 if ( $text === false ) {
246 $content = ContentHandler
::makeContent( $text, $this->getTitle() );
248 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
249 $content = new MessageContent( $message, null, 'parsemag' );
252 $this->fetchContentObject();
253 $content = $this->mContentObject
;
260 * @return int The oldid of the article that is to be shown, 0 for the current revision
262 public function getOldID() {
263 if ( is_null( $this->mOldId
) ) {
264 $this->mOldId
= $this->getOldIDFromRequest();
267 return $this->mOldId
;
271 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
273 * @return int The old id for the request
275 public function getOldIDFromRequest() {
276 $this->mRedirectUrl
= false;
278 $request = $this->getContext()->getRequest();
279 $oldid = $request->getIntOrNull( 'oldid' );
281 if ( $oldid === null ) {
285 if ( $oldid !== 0 ) {
286 # Load the given revision and check whether the page is another one.
287 # In that case, update this instance to reflect the change.
288 if ( $oldid === $this->mPage
->getLatest() ) {
289 $this->mRevision
= $this->mPage
->getRevision();
291 $this->mRevision
= Revision
::newFromId( $oldid );
292 if ( $this->mRevision
!== null ) {
293 // Revision title doesn't match the page title given?
294 if ( $this->mPage
->getId() != $this->mRevision
->getPage() ) {
295 $function = get_class( $this->mPage
). '::newFromID';
296 $this->mPage
= $function( $this->mRevision
->getPage() );
302 if ( $request->getVal( 'direction' ) == 'next' ) {
303 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
306 $this->mRevision
= null;
308 $this->mRedirectUrl
= $this->getTitle()->getFullURL( 'redirect=no' );
310 } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
311 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
314 $this->mRevision
= null;
322 * Get text content object
323 * Does *NOT* follow redirects.
324 * @todo When is this null?
326 * @note Code that wants to retrieve page content from the database should
327 * use WikiPage::getContent().
329 * @return Content|null|bool
333 protected function fetchContentObject() {
334 if ( $this->mContentLoaded
) {
335 return $this->mContentObject
;
338 $this->mContentLoaded
= true;
339 $this->mContent
= null;
341 $oldid = $this->getOldID();
343 # Pre-fill content with error message so that if something
344 # fails we'll have something telling us what we intended.
345 // XXX: this isn't page content but a UI message. horrible.
346 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
349 # $this->mRevision might already be fetched by getOldIDFromRequest()
350 if ( !$this->mRevision
) {
351 $this->mRevision
= Revision
::newFromId( $oldid );
352 if ( !$this->mRevision
) {
353 wfDebug( __METHOD__
. " failed to retrieve specified revision, id $oldid\n" );
358 $oldid = $this->mPage
->getLatest();
360 wfDebug( __METHOD__
. " failed to find page data for title " .
361 $this->getTitle()->getPrefixedText() . "\n" );
365 # Update error message with correct oldid
366 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
368 $this->mRevision
= $this->mPage
->getRevision();
370 if ( !$this->mRevision
) {
371 wfDebug( __METHOD__
. " failed to retrieve current page, rev_id $oldid\n" );
376 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
377 // We should instead work with the Revision object when we need it...
378 // Loads if user is allowed
379 $content = $this->mRevision
->getContent(
380 Revision
::FOR_THIS_USER
,
381 $this->getContext()->getUser()
385 wfDebug( __METHOD__
. " failed to retrieve content of revision " .
386 $this->mRevision
->getId() . "\n" );
390 $this->mContentObject
= $content;
391 $this->mRevIdFetched
= $this->mRevision
->getId();
393 // Avoid PHP 7.1 warning of passing $this by reference
394 $articlePage = $this;
397 'ArticleAfterFetchContentObject',
398 [ &$articlePage, &$this->mContentObject
]
401 return $this->mContentObject
;
405 * Returns true if the currently-referenced revision is the current edit
406 * to this page (and it exists).
409 public function isCurrent() {
410 # If no oldid, this is the current version.
411 if ( $this->getOldID() == 0 ) {
415 return $this->mPage
->exists() && $this->mRevision
&& $this->mRevision
->isCurrent();
419 * Get the fetched Revision object depending on request parameters or null
423 * @return Revision|null
425 public function getRevisionFetched() {
426 $this->fetchContentObject();
428 return $this->mRevision
;
432 * Use this to fetch the rev ID used on page views
434 * @return int Revision ID of last article revision
436 public function getRevIdFetched() {
437 if ( $this->mRevIdFetched
) {
438 return $this->mRevIdFetched
;
440 return $this->mPage
->getLatest();
445 * This is the default action of the index.php entry point: just view the
446 * page of the given title.
448 public function view() {
449 global $wgUseFileCache, $wgDebugToolbar;
451 # Get variables from query string
452 # As side effect this will load the revision and update the title
453 # in a revision ID is passed in the request, so this should remain
454 # the first call of this method even if $oldid is used way below.
455 $oldid = $this->getOldID();
457 $user = $this->getContext()->getUser();
458 # Another whitelist check in case getOldID() is altering the title
459 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
460 if ( count( $permErrors ) ) {
461 wfDebug( __METHOD__
. ": denied on secondary read check\n" );
462 throw new PermissionsError( 'read', $permErrors );
465 $outputPage = $this->getContext()->getOutput();
466 # getOldID() may as well want us to redirect somewhere else
467 if ( $this->mRedirectUrl
) {
468 $outputPage->redirect( $this->mRedirectUrl
);
469 wfDebug( __METHOD__
. ": redirecting due to oldid\n" );
474 # If we got diff in the query, we want to see a diff page instead of the article.
475 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
476 wfDebug( __METHOD__
. ": showing diff page\n" );
477 $this->showDiffPage();
482 # Set page title (may be overridden by DISPLAYTITLE)
483 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
485 $outputPage->setArticleFlag( true );
486 # Allow frames by default
487 $outputPage->allowClickjacking();
489 $parserCache = MediaWikiServices
::getInstance()->getParserCache();
491 $parserOptions = $this->getParserOptions();
493 # Render printable version, use printable version cache
494 if ( $outputPage->isPrintable() ) {
495 $parserOptions->setIsPrintable( true );
496 $poOptions['enableSectionEditLinks'] = false;
497 } elseif ( $this->disableSectionEditForRender
498 ||
!$this->isCurrent() ||
!$this->getTitle()->quickUserCan( 'edit', $user )
500 $poOptions['enableSectionEditLinks'] = false;
503 # Try client and file cache
504 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage
->checkTouched() ) {
505 # Try to stream the output from file cache
506 if ( $wgUseFileCache && $this->tryFileCache() ) {
507 wfDebug( __METHOD__
. ": done file cache\n" );
508 # tell wgOut that output is taken care of
509 $outputPage->disable();
510 $this->mPage
->doViewUpdates( $user, $oldid );
516 # Should the parser cache be used?
517 $useParserCache = $this->mPage
->shouldCheckParserCache( $parserOptions, $oldid );
518 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ?
'yes' : 'no' ) . "\n" );
519 if ( $user->getStubThreshold() ) {
520 MediaWikiServices
::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
523 $this->showRedirectedFromHeader();
524 $this->showNamespaceHeader();
526 # Iterate through the possible ways of constructing the output text.
527 # Keep going until $outputDone is set, or we run out of things to do.
530 $this->mParserOutput
= false;
532 while ( !$outputDone && ++
$pass ) {
535 // Avoid PHP 7.1 warning of passing $this by reference
536 $articlePage = $this;
537 Hooks
::run( 'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
540 # Early abort if the page doesn't exist
541 if ( !$this->mPage
->exists() ) {
542 wfDebug( __METHOD__
. ": showing missing article\n" );
543 $this->showMissingArticle();
544 $this->mPage
->doViewUpdates( $user );
548 # Try the parser cache
549 if ( $useParserCache ) {
550 $this->mParserOutput
= $parserCache->get( $this->mPage
, $parserOptions );
552 if ( $this->mParserOutput
!== false ) {
554 wfDebug( __METHOD__
. ": showing parser cache contents for current rev permalink\n" );
555 $this->setOldSubtitle( $oldid );
557 wfDebug( __METHOD__
. ": showing parser cache contents\n" );
559 $outputPage->addParserOutput( $this->mParserOutput
, $poOptions );
560 # Ensure that UI elements requiring revision ID have
561 # the correct version information.
562 $outputPage->setRevisionId( $this->mPage
->getLatest() );
563 # Preload timestamp to avoid a DB hit
564 $cachedTimestamp = $this->mParserOutput
->getTimestamp();
565 if ( $cachedTimestamp !== null ) {
566 $outputPage->setRevisionTimestamp( $cachedTimestamp );
567 $this->mPage
->setTimestamp( $cachedTimestamp );
574 # This will set $this->mRevision if needed
575 $this->fetchContentObject();
577 # Are we looking at an old revision
578 if ( $oldid && $this->mRevision
) {
579 $this->setOldSubtitle( $oldid );
581 if ( !$this->showDeletedRevisionHeader() ) {
582 wfDebug( __METHOD__
. ": cannot view deleted revision\n" );
587 # Ensure that UI elements requiring revision ID have
588 # the correct version information.
589 $outputPage->setRevisionId( $this->getRevIdFetched() );
590 # Preload timestamp to avoid a DB hit
591 $outputPage->setRevisionTimestamp( $this->mPage
->getTimestamp() );
593 # Pages containing custom CSS or JavaScript get special treatment
594 if ( $this->getTitle()->isSiteConfigPage() ||
$this->getTitle()->isUserConfigPage() ) {
595 $dir = $this->getContext()->getLanguage()->getDir();
596 $lang = $this->getContext()->getLanguage()->getHtmlCode();
598 $outputPage->wrapWikiMsg(
599 "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
602 } elseif ( !Hooks
::run( 'ArticleContentViewCustom',
603 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] )
605 # Allow extensions do their own custom view for certain pages
610 # Run the parse, protected by a pool counter
611 wfDebug( __METHOD__
. ": doing uncached parse\n" );
613 $content = $this->getContentObject();
614 $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
615 $this->getRevIdFetched(), $useParserCache, $content );
617 if ( !$poolArticleView->execute() ) {
618 $error = $poolArticleView->getError();
620 $outputPage->clearHTML(); // for release() errors
621 $outputPage->enableClientCache( false );
622 $outputPage->setRobotPolicy( 'noindex,nofollow' );
624 $errortext = $error->getWikiText( false, 'view-pool-error' );
625 $outputPage->addWikiText( Html
::errorBox( $errortext ) );
627 # Connection or timeout error
631 $this->mParserOutput
= $poolArticleView->getParserOutput();
632 $outputPage->addParserOutput( $this->mParserOutput
, $poOptions );
633 if ( $content->getRedirectTarget() ) {
634 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
635 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
638 # Don't cache a dirty ParserOutput object
639 if ( $poolArticleView->getIsDirty() ) {
640 $outputPage->setCdnMaxage( 0 );
641 $outputPage->addHTML( "<!-- parser cache is expired, " .
642 "sending anyway due to pool overload-->\n" );
647 # Should be unreachable, but just in case...
653 # Get the ParserOutput actually *displayed* here.
654 # Note that $this->mParserOutput is the *current*/oldid version output.
655 $pOutput = ( $outputDone instanceof ParserOutput
)
656 ?
$outputDone // object fetched by hook
657 : $this->mParserOutput ?
: null; // ParserOutput or null, avoid false
659 # Adjust title for main page & pages with displaytitle
661 $this->adjustDisplayTitle( $pOutput );
664 # For the main page, overwrite the <title> element with the con-
665 # tents of 'pagetitle-view-mainpage' instead of the default (if
667 # This message always exists because it is in the i18n files
668 if ( $this->getTitle()->isMainPage() ) {
669 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
670 if ( !$msg->isDisabled() ) {
671 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
675 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
676 # This could use getTouched(), but that could be scary for major template edits.
677 $outputPage->adaptCdnTTL( $this->mPage
->getTimestamp(), IExpiringStore
::TTL_DAY
);
679 # Check for any __NOINDEX__ tags on the page using $pOutput
680 $policy = $this->getRobotPolicy( 'view', $pOutput );
681 $outputPage->setIndexPolicy( $policy['index'] );
682 $outputPage->setFollowPolicy( $policy['follow'] );
684 $this->showViewFooter();
685 $this->mPage
->doViewUpdates( $user, $oldid );
687 # Load the postEdit module if the user just saved this revision
688 # See also EditPage::setPostEditCookie
689 $request = $this->getContext()->getRequest();
690 $cookieKey = EditPage
::POST_EDIT_COOKIE_KEY_PREFIX
. $this->getRevIdFetched();
691 $postEdit = $request->getCookie( $cookieKey );
693 # Clear the cookie. This also prevents caching of the response.
694 $request->response()->clearCookie( $cookieKey );
695 $outputPage->addJsConfigVars( 'wgPostEdit', $postEdit );
696 $outputPage->addModules( 'mediawiki.action.view.postEdit' );
701 * Adjust title for pages with displaytitle, -{T|}- or language conversion
702 * @param ParserOutput $pOutput
704 public function adjustDisplayTitle( ParserOutput
$pOutput ) {
705 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
706 $titleText = $pOutput->getTitleText();
707 if ( strval( $titleText ) !== '' ) {
708 $this->getContext()->getOutput()->setPageTitle( $titleText );
713 * Show a diff page according to current request variables. For use within
714 * Article::view() only, other callers should use the DifferenceEngine class.
716 protected function showDiffPage() {
717 $request = $this->getContext()->getRequest();
718 $user = $this->getContext()->getUser();
719 $diff = $request->getVal( 'diff' );
720 $rcid = $request->getVal( 'rcid' );
721 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
722 $purge = $request->getVal( 'action' ) == 'purge';
723 $unhide = $request->getInt( 'unhide' ) == 1;
724 $oldid = $this->getOldID();
726 $rev = $this->getRevisionFetched();
729 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
730 $msg = $this->getContext()->msg( 'difference-missing-revision' )
734 $this->getContext()->getOutput()->addHTML( $msg );
738 $contentHandler = $rev->getContentHandler();
739 $de = $contentHandler->createDifferenceEngine(
748 // DifferenceEngine directly fetched the revision:
749 $this->mRevIdFetched
= $de->getNewid();
750 $de->showDiffPage( $diffOnly );
752 // Run view updates for the newer revision being diffed (and shown
753 // below the diff if not $diffOnly).
754 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
755 // New can be false, convert it to 0 - this conveniently means the latest revision
756 $this->mPage
->doViewUpdates( $user, (int)$new );
760 * Get the robot policy to be used for the current view
761 * @param string $action The action= GET parameter
762 * @param ParserOutput|null $pOutput
763 * @return array The policy that should be set
764 * @todo actions other than 'view'
766 public function getRobotPolicy( $action, ParserOutput
$pOutput = null ) {
767 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
769 $ns = $this->getTitle()->getNamespace();
771 # Don't index user and user talk pages for blocked users (T13443)
772 if ( ( $ns == NS_USER ||
$ns == NS_USER_TALK
) && !$this->getTitle()->isSubpage() ) {
773 $specificTarget = null;
775 $titleText = $this->getTitle()->getText();
776 if ( IP
::isValid( $titleText ) ) {
777 $vagueTarget = $titleText;
779 $specificTarget = $titleText;
781 if ( Block
::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block
) {
783 'index' => 'noindex',
784 'follow' => 'nofollow'
789 if ( $this->mPage
->getId() === 0 ||
$this->getOldID() ) {
790 # Non-articles (special pages etc), and old revisions
792 'index' => 'noindex',
793 'follow' => 'nofollow'
795 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
796 # Discourage indexing of printable versions, but encourage following
798 'index' => 'noindex',
801 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
802 # For ?curid=x urls, disallow indexing
804 'index' => 'noindex',
809 # Otherwise, construct the policy based on the various config variables.
810 $policy = self
::formatRobotPolicy( $wgDefaultRobotPolicy );
812 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
813 # Honour customised robot policies for this namespace
814 $policy = array_merge(
816 self
::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
819 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
820 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
821 # a final sanity check that we have really got the parser output.
822 $policy = array_merge(
824 [ 'index' => $pOutput->getIndexPolicy() ]
828 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
829 # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
830 $policy = array_merge(
832 self
::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
840 * Converts a String robot policy into an associative array, to allow
841 * merging of several policies using array_merge().
842 * @param array|string $policy Returns empty array on null/false/'', transparent
843 * to already-converted arrays, converts string.
844 * @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
846 public static function formatRobotPolicy( $policy ) {
847 if ( is_array( $policy ) ) {
849 } elseif ( !$policy ) {
853 $policy = explode( ',', $policy );
854 $policy = array_map( 'trim', $policy );
857 foreach ( $policy as $var ) {
858 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
859 $arr['index'] = $var;
860 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
861 $arr['follow'] = $var;
869 * If this request is a redirect view, send "redirected from" subtitle to
870 * the output. Returns true if the header was needed, false if this is not
871 * a redirect view. Handles both local and remote redirects.
875 public function showRedirectedFromHeader() {
876 global $wgRedirectSources;
878 $context = $this->getContext();
879 $outputPage = $context->getOutput();
880 $request = $context->getRequest();
881 $rdfrom = $request->getVal( 'rdfrom' );
883 // Construct a URL for the current page view, but with the target title
884 $query = $request->getValues();
885 unset( $query['rdfrom'] );
886 unset( $query['title'] );
887 if ( $this->getTitle()->isRedirect() ) {
888 // Prevent double redirects
889 $query['redirect'] = 'no';
891 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
893 if ( isset( $this->mRedirectedFrom
) ) {
894 // Avoid PHP 7.1 warning of passing $this by reference
895 $articlePage = $this;
897 // This is an internally redirected page view.
898 // We'll need a backlink to the source page for navigation.
899 if ( Hooks
::run( 'ArticleViewRedirect', [ &$articlePage ] ) ) {
900 $redir = Linker
::linkKnown(
901 $this->mRedirectedFrom
,
904 [ 'redirect' => 'no' ]
907 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
908 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
911 // Add the script to update the displayed URL and
912 // set the fragment if one was specified in the redirect
913 $outputPage->addJsConfigVars( [
914 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
916 $outputPage->addModules( 'mediawiki.action.view.redirect' );
918 // Add a <link rel="canonical"> tag
919 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
921 // Tell the output object that the user arrived at this article through a redirect
922 $outputPage->setRedirectedFrom( $this->mRedirectedFrom
);
926 } elseif ( $rdfrom ) {
927 // This is an externally redirected view, from some other wiki.
928 // If it was reported from a trusted site, supply a backlink.
929 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
930 $redir = Linker
::makeExternalLink( $rdfrom, $rdfrom );
931 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
932 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
935 // Add the script to update the displayed URL
936 $outputPage->addJsConfigVars( [
937 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
939 $outputPage->addModules( 'mediawiki.action.view.redirect' );
949 * Show a header specific to the namespace currently being viewed, like
950 * [[MediaWiki:Talkpagetext]]. For Article::view().
952 public function showNamespaceHeader() {
953 if ( $this->getTitle()->isTalkPage() ) {
954 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
955 $this->getContext()->getOutput()->wrapWikiMsg(
956 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
964 * Show the footer section of an ordinary page view
966 public function showViewFooter() {
967 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
968 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
969 && IP
::isValid( $this->getTitle()->getText() )
971 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
974 // Show a footer allowing the user to patrol the shown revision or page if possible
975 $patrolFooterShown = $this->showPatrolFooter();
977 Hooks
::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
981 * If patrol is possible, output a patrol UI box. This is called from the
982 * footer section of ordinary page views. If patrol is not possible or not
983 * desired, does nothing.
984 * Side effect: When the patrol link is build, this method will call
985 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
989 public function showPatrolFooter() {
990 global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol;
992 // Allow hooks to decide whether to not output this at all
993 if ( !Hooks
::run( 'ArticleShowPatrolFooter', [ $this ] ) ) {
997 $outputPage = $this->getContext()->getOutput();
998 $user = $this->getContext()->getUser();
999 $title = $this->getTitle();
1002 if ( !$title->quickUserCan( 'patrol', $user )
1003 ||
!( $wgUseRCPatrol ||
$wgUseNPPatrol
1004 ||
( $wgUseFilePatrol && $title->inNamespace( NS_FILE
) ) )
1006 // Patrolling is disabled or the user isn't allowed to
1010 if ( $this->mRevision
1011 && !RecentChange
::isInRCLifespan( $this->mRevision
->getTimestamp(), 21600 )
1013 // The current revision is already older than what could be in the RC table
1014 // 6h tolerance because the RC might not be cleaned out regularly
1018 // Check for cached results
1019 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
1020 $key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() );
1021 if ( $cache->get( $key ) ) {
1025 $dbr = wfGetDB( DB_REPLICA
);
1026 $oldestRevisionTimestamp = $dbr->selectField(
1028 'MIN( rev_timestamp )',
1029 [ 'rev_page' => $title->getArticleID() ],
1033 // New page patrol: Get the timestamp of the oldest revison which
1034 // the revision table holds for the given page. Then we look
1035 // whether it's within the RC lifespan and if it is, we try
1036 // to get the recentchanges row belonging to that entry
1037 // (with rc_new = 1).
1038 $recentPageCreation = false;
1039 if ( $oldestRevisionTimestamp
1040 && RecentChange
::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
1042 // 6h tolerance because the RC might not be cleaned out regularly
1043 $recentPageCreation = true;
1044 $rc = RecentChange
::newFromConds(
1047 'rc_timestamp' => $oldestRevisionTimestamp,
1048 'rc_namespace' => $title->getNamespace(),
1049 'rc_cur_id' => $title->getArticleID()
1054 // Use generic patrol message for new pages
1055 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1059 // File patrol: Get the timestamp of the latest upload for this page,
1060 // check whether it is within the RC lifespan and if it is, we try
1061 // to get the recentchanges row belonging to that entry
1062 // (with rc_type = RC_LOG, rc_log_type = upload).
1063 $recentFileUpload = false;
1064 if ( ( !$rc ||
$rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1065 && $title->getNamespace() === NS_FILE
) {
1066 // Retrieve timestamp of most recent upload
1067 $newestUploadTimestamp = $dbr->selectField(
1069 'MAX( img_timestamp )',
1070 [ 'img_name' => $title->getDBkey() ],
1073 if ( $newestUploadTimestamp
1074 && RecentChange
::isInRCLifespan( $newestUploadTimestamp, 21600 )
1076 // 6h tolerance because the RC might not be cleaned out regularly
1077 $recentFileUpload = true;
1078 $rc = RecentChange
::newFromConds(
1080 'rc_type' => RC_LOG
,
1081 'rc_log_type' => 'upload',
1082 'rc_timestamp' => $newestUploadTimestamp,
1083 'rc_namespace' => NS_FILE
,
1084 'rc_cur_id' => $title->getArticleID()
1089 // Use patrol message specific to files
1090 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1095 if ( !$recentPageCreation && !$recentFileUpload ) {
1096 // Page creation and latest upload (for files) is too old to be in RC
1098 // We definitely can't patrol so cache the information
1099 // When a new file version is uploaded, the cache is cleared
1100 $cache->set( $key, '1' );
1106 // Don't cache: This can be hit if the page gets accessed very fast after
1107 // its creation / latest upload or in case we have high replica DB lag. In case
1108 // the revision is too old, we will already return above.
1112 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1113 // Patrolled RC entry around
1115 // Cache the information we gathered above in case we can't patrol
1116 // Don't cache in case we can patrol as this could change
1117 $cache->set( $key, '1' );
1122 if ( $rc->getPerformer()->equals( $user ) ) {
1123 // Don't show a patrol link for own creations/uploads. If the user could
1124 // patrol them, they already would be patrolled
1128 $outputPage->preventClickjacking();
1129 if ( $user->isAllowed( 'writeapi' ) ) {
1130 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1133 $link = Linker
::linkKnown(
1135 $markPatrolledMsg->escaped(),
1138 'action' => 'markpatrolled',
1139 'rcid' => $rc->getAttribute( 'rc_id' ),
1143 $outputPage->addHTML(
1144 "<div class='patrollink' data-mw='interface'>" .
1145 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1153 * Purge the cache used to check if it is worth showing the patrol footer
1154 * For example, it is done during re-uploads when file patrol is used.
1155 * @param int $articleID ID of the article to purge
1158 public static function purgePatrolFooterCache( $articleID ) {
1159 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
1160 $cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) );
1164 * Show the error text for a missing article. For articles in the MediaWiki
1165 * namespace, show the default message text. To be called from Article::view().
1167 public function showMissingArticle() {
1168 global $wgSend404Code;
1170 $outputPage = $this->getContext()->getOutput();
1171 // Whether the page is a root user page of an existing user (but not a subpage)
1172 $validUserPage = false;
1174 $title = $this->getTitle();
1176 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1177 if ( $title->getNamespace() == NS_USER
1178 ||
$title->getNamespace() == NS_USER_TALK
1180 $rootPart = explode( '/', $title->getText() )[0];
1181 $user = User
::newFromName( $rootPart, false /* allow IP users */ );
1182 $ip = User
::isIP( $rootPart );
1183 $block = Block
::newFromTarget( $user, $user );
1185 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1186 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1187 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1188 } elseif ( !is_null( $block ) && $block->getType() != Block
::TYPE_AUTO
) {
1189 # Show log extract if the user is currently blocked
1190 LogEventsList
::showLogExtract(
1193 MWNamespace
::getCanonicalName( NS_USER
) . ':' . $block->getTarget(),
1197 'showIfEmpty' => false,
1199 'blocked-notice-logextract',
1200 $user->getName() # Support GENDER in notice
1204 $validUserPage = !$title->isSubpage();
1206 $validUserPage = !$title->isSubpage();
1210 Hooks
::run( 'ShowMissingArticle', [ $this ] );
1212 # Show delete and move logs if there were any such events.
1213 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1214 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1215 $cache = MediaWikiServices
::getInstance()->getMainObjectStash();
1216 $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1217 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1218 $sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
1219 if ( $loggedIn ||
$cache->get( $key ) ||
$sessionExists ) {
1220 $logTypes = [ 'delete', 'move', 'protect' ];
1222 $dbr = wfGetDB( DB_REPLICA
);
1224 $conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
1225 // Give extensions a chance to hide their (unrelated) log entries
1226 Hooks
::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1227 LogEventsList
::showLogExtract(
1235 'showIfEmpty' => false,
1236 'msgKey' => [ $loggedIn ||
$sessionExists
1237 ?
'moveddeleted-notice'
1238 : 'moveddeleted-notice-recent'
1244 if ( !$this->mPage
->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1245 // If there's no backing content, send a 404 Not Found
1246 // for better machine handling of broken links.
1247 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1250 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1251 $policy = $this->getRobotPolicy( 'view' );
1252 $outputPage->setIndexPolicy( $policy['index'] );
1253 $outputPage->setFollowPolicy( $policy['follow'] );
1255 $hookResult = Hooks
::run( 'BeforeDisplayNoArticleText', [ $this ] );
1257 if ( !$hookResult ) {
1261 # Show error message
1262 $oldid = $this->getOldID();
1263 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI
&& $title->hasSourceText() ) {
1264 $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
1267 $text = wfMessage( 'missing-revision', $oldid )->plain();
1268 } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1269 && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1271 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
1272 $text = wfMessage( $message )->plain();
1274 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1277 $dir = $this->getContext()->getLanguage()->getDir();
1278 $lang = $this->getContext()->getLanguage()->getHtmlCode();
1279 $outputPage->addWikiText( Xml
::openElement( 'div', [
1280 'class' => "noarticletext mw-content-$dir",
1283 ] ) . "\n$text\n</div>" );
1288 * If the revision requested for view is deleted, check permissions.
1289 * Send either an error message or a warning header to the output.
1291 * @return bool True if the view is allowed, false if not.
1293 public function showDeletedRevisionHeader() {
1294 if ( !$this->mRevision
->isDeleted( Revision
::DELETED_TEXT
) ) {
1299 $outputPage = $this->getContext()->getOutput();
1300 $user = $this->getContext()->getUser();
1301 // If the user is not allowed to see it...
1302 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
, $user ) ) {
1303 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1304 'rev-deleted-text-permission' );
1307 // If the user needs to confirm that they want to see it...
1308 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1309 # Give explanation and add a link to view the revision...
1310 $oldid = intval( $this->getOldID() );
1311 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1312 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1313 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1314 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1318 // We are allowed to see...
1320 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1321 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1322 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1329 * Generate the navigation links when browsing through an article revisions
1330 * It shows the information as:
1331 * Revision as of \<date\>; view current revision
1332 * \<- Previous version | Next Version -\>
1334 * @param int $oldid Revision ID of this article revision
1336 public function setOldSubtitle( $oldid = 0 ) {
1337 // Avoid PHP 7.1 warning of passing $this by reference
1338 $articlePage = $this;
1340 if ( !Hooks
::run( 'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1344 $context = $this->getContext();
1345 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1347 # Cascade unhide param in links for easy deletion browsing
1350 $extraParams['unhide'] = 1;
1353 if ( $this->mRevision
&& $this->mRevision
->getId() === $oldid ) {
1354 $revision = $this->mRevision
;
1356 $revision = Revision
::newFromId( $oldid );
1359 $timestamp = $revision->getTimestamp();
1361 $current = ( $oldid == $this->mPage
->getLatest() );
1362 $language = $context->getLanguage();
1363 $user = $context->getUser();
1365 $td = $language->userTimeAndDate( $timestamp, $user );
1366 $tddate = $language->userDate( $timestamp, $user );
1367 $tdtime = $language->userTime( $timestamp, $user );
1369 # Show user links if allowed to see them. If hidden, then show them only if requested...
1370 $userlinks = Linker
::revUserTools( $revision, !$unhide );
1372 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1373 ?
'revision-info-current'
1376 $outputPage = $context->getOutput();
1377 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1378 $context->msg( $infomsg, $td )
1379 ->rawParams( $userlinks )
1380 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1381 ->rawParams( Linker
::revComment( $revision, true, true ) )
1386 ?
$context->msg( 'currentrevisionlink' )->escaped()
1387 : Linker
::linkKnown(
1389 $context->msg( 'currentrevisionlink' )->escaped(),
1394 ?
$context->msg( 'diff' )->escaped()
1395 : Linker
::linkKnown(
1397 $context->msg( 'diff' )->escaped(),
1404 $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1406 ? Linker
::linkKnown(
1408 $context->msg( 'previousrevision' )->escaped(),
1411 'direction' => 'prev',
1415 : $context->msg( 'previousrevision' )->escaped();
1417 ? Linker
::linkKnown(
1419 $context->msg( 'diff' )->escaped(),
1426 : $context->msg( 'diff' )->escaped();
1427 $nextlink = $current
1428 ?
$context->msg( 'nextrevision' )->escaped()
1429 : Linker
::linkKnown(
1431 $context->msg( 'nextrevision' )->escaped(),
1434 'direction' => 'next',
1438 $nextdiff = $current
1439 ?
$context->msg( 'diff' )->escaped()
1440 : Linker
::linkKnown(
1442 $context->msg( 'diff' )->escaped(),
1450 $cdel = Linker
::getRevDeleteLink( $user, $revision, $this->getTitle() );
1451 if ( $cdel !== '' ) {
1455 // the outer div is need for styling the revision info and nav in MobileFrontend
1456 $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1457 "<div id=\"mw-revision-nav\">" . $cdel .
1458 $context->msg( 'revision-nav' )->rawParams(
1459 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1460 )->escaped() . "</div></div>" );
1464 * Return the HTML for the top of a redirect page
1466 * Chances are you should just be using the ParserOutput from
1467 * WikitextContent::getParserOutput instead of calling this for redirects.
1469 * @param Title|array $target Destination(s) to redirect
1470 * @param bool $appendSubtitle [optional]
1471 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1472 * @return string Containing HTML with redirect link
1474 * @deprecated since 1.30
1476 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1477 $lang = $this->getTitle()->getPageLanguage();
1478 $out = $this->getContext()->getOutput();
1479 if ( $appendSubtitle ) {
1480 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1482 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1483 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1487 * Return the HTML for the top of a redirect page
1489 * Chances are you should just be using the ParserOutput from
1490 * WikitextContent::getParserOutput instead of calling this for redirects.
1493 * @param Language $lang
1494 * @param Title|array $target Destination(s) to redirect
1495 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1496 * @return string Containing HTML with redirect link
1498 public static function getRedirectHeaderHtml( Language
$lang, $target, $forceKnown = false ) {
1499 if ( !is_array( $target ) ) {
1500 $target = [ $target ];
1503 $html = '<ul class="redirectText">';
1504 /** @var Title $title */
1505 foreach ( $target as $title ) {
1506 $html .= '<li>' . Linker
::link(
1508 htmlspecialchars( $title->getFullText() ),
1510 // Make sure wiki page redirects are not followed
1511 $title->isRedirect() ?
[ 'redirect' => 'no' ] : [],
1512 ( $forceKnown ?
[ 'known', 'noclasses' ] : [] )
1517 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1519 return '<div class="redirectMsg">' .
1520 '<p>' . $redirectToText . '</p>' .
1526 * Adds help link with an icon via page indicators.
1527 * Link target can be overridden by a local message containing a wikilink:
1528 * the message key is: 'namespace-' + namespace number + '-helppage'.
1529 * @param string $to Target MediaWiki.org page title or encoded URL.
1530 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
1533 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1535 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1538 $out = $this->getContext()->getOutput();
1539 if ( !$msg->isDisabled() ) {
1540 $helpUrl = Skin
::makeUrl( $msg->plain() );
1541 $out->addHelpLink( $helpUrl, true );
1543 $out->addHelpLink( $to, $overrideBaseUrl );
1548 * Handle action=render
1550 public function render() {
1551 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1552 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1553 $this->disableSectionEditForRender
= true;
1558 * action=protect handler
1560 public function protect() {
1561 $form = new ProtectionForm( $this );
1566 * action=unprotect handler (alias)
1568 public function unprotect() {
1573 * UI entry point for page deletion
1575 public function delete() {
1576 # This code desperately needs to be totally rewritten
1578 $title = $this->getTitle();
1579 $context = $this->getContext();
1580 $user = $context->getUser();
1581 $request = $context->getRequest();
1584 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1585 if ( count( $permissionErrors ) ) {
1586 throw new PermissionsError( 'delete', $permissionErrors );
1589 # Read-only check...
1590 if ( wfReadOnly() ) {
1591 throw new ReadOnlyError
;
1594 # Better double-check that it hasn't been deleted yet!
1595 $this->mPage
->loadPageData(
1596 $request->wasPosted() ? WikiPage
::READ_LATEST
: WikiPage
::READ_NORMAL
1598 if ( !$this->mPage
->exists() ) {
1599 $deleteLogPage = new LogPage( 'delete' );
1600 $outputPage = $context->getOutput();
1601 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1602 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1603 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1605 $outputPage->addHTML(
1606 Xml
::element( 'h2', null, $deleteLogPage->getName()->text() )
1608 LogEventsList
::showLogExtract(
1617 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1618 $deleteReason = $request->getText( 'wpReason' );
1620 if ( $deleteReasonList == 'other' ) {
1621 $reason = $deleteReason;
1622 } elseif ( $deleteReason != '' ) {
1623 // Entry from drop down menu + additional comment
1624 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1625 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1627 $reason = $deleteReasonList;
1630 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1631 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1633 # Flag to hide all contents of the archived revisions
1634 $suppress = $request->getCheck( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1636 $this->doDelete( $reason, $suppress );
1638 WatchAction
::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1643 // Generate deletion reason
1644 $hasHistory = false;
1647 $reason = $this->generateReason( $hasHistory );
1648 } catch ( Exception
$e ) {
1649 # if a page is horribly broken, we still want to be able to
1650 # delete it. So be lenient about errors here.
1651 wfDebug( "Error while building auto delete summary: $e" );
1656 // If the page has a history, insert a warning
1657 if ( $hasHistory ) {
1658 $title = $this->getTitle();
1660 // The following can use the real revision count as this is only being shown for users
1661 // that can delete this page.
1662 // This, as a side-effect, also makes sure that the following query isn't being run for
1663 // pages with a larger history, unless the user has the 'bigdelete' right
1664 // (and is about to delete this page).
1665 $dbr = wfGetDB( DB_REPLICA
);
1666 $revisions = $edits = (int)$dbr->selectField(
1669 [ 'rev_page' => $title->getArticleID() ],
1673 // @todo FIXME: i18n issue/patchwork message
1674 $context->getOutput()->addHTML(
1675 '<strong class="mw-delete-warning-revisions">' .
1676 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1677 $context->msg( 'word-separator' )->escaped() . Linker
::linkKnown( $title,
1678 $context->msg( 'history' )->escaped(),
1680 [ 'action' => 'history' ] ) .
1684 if ( $title->isBigDeletion() ) {
1685 global $wgDeleteRevisionsLimit;
1686 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1688 'delete-warning-toobig',
1689 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1695 $this->confirmDelete( $reason );
1699 * Output deletion confirmation dialog
1700 * @todo FIXME: Move to another file?
1701 * @param string $reason Prefilled reason
1703 public function confirmDelete( $reason ) {
1704 wfDebug( "Article::confirmDelete\n" );
1706 $title = $this->getTitle();
1707 $ctx = $this->getContext();
1708 $outputPage = $ctx->getOutput();
1709 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1710 $outputPage->addBacklinkSubtitle( $title );
1711 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1712 $outputPage->addModules( 'mediawiki.action.delete' );
1714 $backlinkCache = $title->getBacklinkCache();
1715 if ( $backlinkCache->hasLinks( 'pagelinks' ) ||
$backlinkCache->hasLinks( 'templatelinks' ) ) {
1716 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1717 'deleting-backlinks-warning' );
1720 $subpageQueryLimit = 51;
1721 $subpages = $title->getSubpages( $subpageQueryLimit );
1722 $subpageCount = count( $subpages );
1723 if ( $subpageCount > 0 ) {
1724 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1725 [ 'deleting-subpages-warning', Message
::numParam( $subpageCount ) ] );
1727 $outputPage->addWikiMsg( 'confirmdeletetext' );
1729 Hooks
::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1731 $user = $this->getContext()->getUser();
1732 $checkWatch = $user->getBoolOption( 'watchdeletion' ) ||
$user->isWatched( $title );
1734 $outputPage->enableOOUI();
1736 $options = Xml
::listDropDownOptions(
1737 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->text(),
1738 [ 'other' => $ctx->msg( 'deletereasonotherlist' )->inContentLanguage()->text() ]
1740 $options = Xml
::listDropDownOptionsOoui( $options );
1742 $fields[] = new OOUI\
FieldLayout(
1743 new OOUI\
DropdownInputWidget( [
1744 'name' => 'wpDeleteReasonList',
1745 'inputId' => 'wpDeleteReasonList',
1747 'infusable' => true,
1749 'options' => $options
1752 'label' => $ctx->msg( 'deletecomment' )->text(),
1757 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
1758 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
1759 // Unicode codepoints (or 255 UTF-8 bytes for old schema).
1760 $conf = $this->getContext()->getConfig();
1761 $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD
;
1762 $fields[] = new OOUI\
FieldLayout(
1763 new OOUI\
TextInputWidget( [
1764 'name' => 'wpReason',
1765 'inputId' => 'wpReason',
1767 'maxLength' => $oldCommentSchema ?
255 : CommentStore
::COMMENT_CHARACTER_LIMIT
,
1768 'infusable' => true,
1770 'autofocus' => true,
1773 'label' => $ctx->msg( 'deleteotherreason' )->text(),
1778 if ( $user->isLoggedIn() ) {
1779 $fields[] = new OOUI\
FieldLayout(
1780 new OOUI\
CheckboxInputWidget( [
1781 'name' => 'wpWatch',
1782 'inputId' => 'wpWatch',
1784 'selected' => $checkWatch,
1787 'label' => $ctx->msg( 'watchthis' )->text(),
1788 'align' => 'inline',
1789 'infusable' => true,
1794 if ( $user->isAllowed( 'suppressrevision' ) ) {
1795 $fields[] = new OOUI\
FieldLayout(
1796 new OOUI\
CheckboxInputWidget( [
1797 'name' => 'wpSuppress',
1798 'inputId' => 'wpSuppress',
1802 'label' => $ctx->msg( 'revdelete-suppress' )->text(),
1803 'align' => 'inline',
1804 'infusable' => true,
1809 $fields[] = new OOUI\
FieldLayout(
1810 new OOUI\
ButtonInputWidget( [
1811 'name' => 'wpConfirmB',
1812 'inputId' => 'wpConfirmB',
1814 'value' => $ctx->msg( 'deletepage' )->text(),
1815 'label' => $ctx->msg( 'deletepage' )->text(),
1816 'flags' => [ 'primary', 'destructive' ],
1824 $fieldset = new OOUI\
FieldsetLayout( [
1825 'label' => $ctx->msg( 'delete-legend' )->text(),
1826 'id' => 'mw-delete-table',
1830 $form = new OOUI\
FormLayout( [
1832 'action' => $title->getLocalURL( 'action=delete' ),
1833 'id' => 'deleteconfirm',
1835 $form->appendContent(
1837 new OOUI\
HtmlSnippet(
1838 Html
::hidden( 'wpEditToken', $user->getEditToken( [ 'delete', $title->getPrefixedText() ] ) )
1842 $outputPage->addHTML(
1843 new OOUI\
PanelLayout( [
1844 'classes' => [ 'deletepage-wrapper' ],
1845 'expanded' => false,
1852 if ( $user->isAllowed( 'editinterface' ) ) {
1853 $link = Linker
::linkKnown(
1854 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1855 wfMessage( 'delete-edit-reasonlist' )->escaped(),
1857 [ 'action' => 'edit' ]
1859 $outputPage->addHTML( '<p class="mw-delete-editreasons">' . $link . '</p>' );
1862 $deleteLogPage = new LogPage( 'delete' );
1863 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1864 LogEventsList
::showLogExtract( $outputPage, 'delete', $title );
1868 * Perform a deletion and output success or failure messages
1869 * @param string $reason
1870 * @param bool $suppress
1872 public function doDelete( $reason, $suppress = false ) {
1874 $context = $this->getContext();
1875 $outputPage = $context->getOutput();
1876 $user = $context->getUser();
1877 $status = $this->mPage
->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
1879 if ( $status->isGood() ) {
1880 $deleted = $this->getTitle()->getPrefixedText();
1882 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1883 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1885 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1887 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1889 Hooks
::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
1891 $outputPage->returnToMain( false );
1893 $outputPage->setPageTitle(
1894 wfMessage( 'cannotdelete-title',
1895 $this->getTitle()->getPrefixedText() )
1898 if ( $error == '' ) {
1899 $outputPage->addWikiText(
1900 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1902 $deleteLogPage = new LogPage( 'delete' );
1903 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1905 LogEventsList
::showLogExtract(
1911 $outputPage->addHTML( $error );
1916 /* Caching functions */
1919 * checkLastModified returns true if it has taken care of all
1920 * output to the client that is necessary for this request.
1921 * (that is, it has sent a cached version of the page)
1923 * @return bool True if cached version send, false otherwise
1925 protected function tryFileCache() {
1926 static $called = false;
1929 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1934 if ( $this->isFileCacheable() ) {
1935 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
1936 if ( $cache->isCacheGood( $this->mPage
->getTouched() ) ) {
1937 wfDebug( "Article::tryFileCache(): about to load file\n" );
1938 $cache->loadFromFileCache( $this->getContext() );
1941 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1942 ob_start( [ &$cache, 'saveToFileCache' ] );
1945 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1952 * Check if the page can be cached
1953 * @param int $mode One of the HTMLFileCache::MODE_* constants (since 1.28)
1956 public function isFileCacheable( $mode = HTMLFileCache
::MODE_NORMAL
) {
1959 if ( HTMLFileCache
::useFileCache( $this->getContext(), $mode ) ) {
1960 $cacheable = $this->mPage
->getId()
1961 && !$this->mRedirectedFrom
&& !$this->getTitle()->isRedirect();
1962 // Extension may have reason to disable file caching on some pages.
1964 // Avoid PHP 7.1 warning of passing $this by reference
1965 $articlePage = $this;
1966 $cacheable = Hooks
::run( 'IsFileCacheable', [ &$articlePage ] );
1976 * Lightweight method to get the parser output for a page, checking the parser cache
1977 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1978 * consider, so it's not appropriate to use there.
1980 * @since 1.16 (r52326) for LiquidThreads
1982 * @param int|null $oldid Revision ID or null
1983 * @param User|null $user The relevant user
1984 * @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
1986 public function getParserOutput( $oldid = null, User
$user = null ) {
1987 // XXX: bypasses mParserOptions and thus setParserOptions()
1989 if ( $user === null ) {
1990 $parserOptions = $this->getParserOptions();
1992 $parserOptions = $this->mPage
->makeParserOptions( $user );
1995 return $this->mPage
->getParserOutput( $parserOptions, $oldid );
1999 * Override the ParserOptions used to render the primary article wikitext.
2001 * @param ParserOptions $options
2002 * @throws MWException If the parser options where already initialized.
2004 public function setParserOptions( ParserOptions
$options ) {
2005 if ( $this->mParserOptions
) {
2006 throw new MWException( "can't change parser options after they have already been set" );
2009 // clone, so if $options is modified later, it doesn't confuse the parser cache.
2010 $this->mParserOptions
= clone $options;
2014 * Get parser options suitable for rendering the primary article wikitext
2015 * @return ParserOptions
2017 public function getParserOptions() {
2018 if ( !$this->mParserOptions
) {
2019 $this->mParserOptions
= $this->mPage
->makeParserOptions( $this->getContext() );
2021 // Clone to allow modifications of the return value without affecting cache
2022 return clone $this->mParserOptions
;
2026 * Sets the context this Article is executed in
2028 * @param IContextSource $context
2031 public function setContext( $context ) {
2032 $this->mContext
= $context;
2036 * Gets the context this Article is executed in
2038 * @return IContextSource
2041 public function getContext() {
2042 if ( $this->mContext
instanceof IContextSource
) {
2043 return $this->mContext
;
2045 wfDebug( __METHOD__
. " called and \$mContext is null. " .
2046 "Return RequestContext::getMain(); for sanity\n" );
2047 return RequestContext
::getMain();
2052 * Use PHP's magic __get handler to handle accessing of
2053 * raw WikiPage fields for backwards compatibility.
2055 * @param string $fname Field name
2058 public function __get( $fname ) {
2059 if ( property_exists( $this->mPage
, $fname ) ) {
2060 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2061 return $this->mPage
->$fname;
2063 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE
);
2067 * Use PHP's magic __set handler to handle setting of
2068 * raw WikiPage fields for backwards compatibility.
2070 * @param string $fname Field name
2071 * @param mixed $fvalue New value
2073 public function __set( $fname, $fvalue ) {
2074 if ( property_exists( $this->mPage
, $fname ) ) {
2075 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2076 $this->mPage
->$fname = $fvalue;
2077 // Note: extensions may want to toss on new fields
2078 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
2079 $this->mPage
->$fname = $fvalue;
2081 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE
);
2086 * Call to WikiPage function for backwards compatibility.
2087 * @see WikiPage::checkFlags
2089 public function checkFlags( $flags ) {
2090 return $this->mPage
->checkFlags( $flags );
2094 * Call to WikiPage function for backwards compatibility.
2095 * @see WikiPage::checkTouched
2097 public function checkTouched() {
2098 return $this->mPage
->checkTouched();
2102 * Call to WikiPage function for backwards compatibility.
2103 * @see WikiPage::clearPreparedEdit
2105 public function clearPreparedEdit() {
2106 $this->mPage
->clearPreparedEdit();
2110 * Call to WikiPage function for backwards compatibility.
2111 * @see WikiPage::doDeleteArticleReal
2113 public function doDeleteArticleReal(
2114 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User
$user = null,
2117 return $this->mPage
->doDeleteArticleReal(
2118 $reason, $suppress, $u1, $u2, $error, $user, $tags
2123 * Call to WikiPage function for backwards compatibility.
2124 * @see WikiPage::doDeleteUpdates
2126 public function doDeleteUpdates(
2128 Content
$content = null,
2132 $this->mPage
->doDeleteUpdates( $id, $content, $revision, $user );
2136 * Call to WikiPage function for backwards compatibility.
2137 * @deprecated since 1.29. Use WikiPage::doEditContent() directly instead
2138 * @see WikiPage::doEditContent
2140 public function doEditContent( Content
$content, $summary, $flags = 0, $originalRevId = false,
2141 User
$user = null, $serialFormat = null
2143 wfDeprecated( __METHOD__
, '1.29' );
2144 return $this->mPage
->doEditContent( $content, $summary, $flags, $originalRevId,
2145 $user, $serialFormat
2150 * Call to WikiPage function for backwards compatibility.
2151 * @see WikiPage::doEditUpdates
2153 public function doEditUpdates( Revision
$revision, User
$user, array $options = [] ) {
2154 return $this->mPage
->doEditUpdates( $revision, $user, $options );
2158 * Call to WikiPage function for backwards compatibility.
2159 * @see WikiPage::doPurge
2160 * @note In 1.28 (and only 1.28), this took a $flags parameter that
2161 * controlled how much purging was done.
2163 public function doPurge() {
2164 return $this->mPage
->doPurge();
2168 * Call to WikiPage function for backwards compatibility.
2169 * @see WikiPage::doViewUpdates
2171 public function doViewUpdates( User
$user, $oldid = 0 ) {
2172 $this->mPage
->doViewUpdates( $user, $oldid );
2176 * Call to WikiPage function for backwards compatibility.
2177 * @see WikiPage::exists
2179 public function exists() {
2180 return $this->mPage
->exists();
2184 * Call to WikiPage function for backwards compatibility.
2185 * @see WikiPage::followRedirect
2187 public function followRedirect() {
2188 return $this->mPage
->followRedirect();
2192 * Call to WikiPage function for backwards compatibility.
2193 * @see ContentHandler::getActionOverrides
2195 public function getActionOverrides() {
2196 return $this->mPage
->getActionOverrides();
2200 * Call to WikiPage function for backwards compatibility.
2201 * @see WikiPage::getAutoDeleteReason
2203 public function getAutoDeleteReason( &$hasHistory ) {
2204 return $this->mPage
->getAutoDeleteReason( $hasHistory );
2208 * Call to WikiPage function for backwards compatibility.
2209 * @see WikiPage::getCategories
2211 public function getCategories() {
2212 return $this->mPage
->getCategories();
2216 * Call to WikiPage function for backwards compatibility.
2217 * @see WikiPage::getComment
2219 public function getComment( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2220 return $this->mPage
->getComment( $audience, $user );
2224 * Call to WikiPage function for backwards compatibility.
2225 * @see WikiPage::getContentHandler
2227 public function getContentHandler() {
2228 return $this->mPage
->getContentHandler();
2232 * Call to WikiPage function for backwards compatibility.
2233 * @see WikiPage::getContentModel
2235 public function getContentModel() {
2236 return $this->mPage
->getContentModel();
2240 * Call to WikiPage function for backwards compatibility.
2241 * @see WikiPage::getContributors
2243 public function getContributors() {
2244 return $this->mPage
->getContributors();
2248 * Call to WikiPage function for backwards compatibility.
2249 * @see WikiPage::getCreator
2251 public function getCreator( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2252 return $this->mPage
->getCreator( $audience, $user );
2256 * Call to WikiPage function for backwards compatibility.
2257 * @see WikiPage::getDeletionUpdates
2259 public function getDeletionUpdates( Content
$content = null ) {
2260 return $this->mPage
->getDeletionUpdates( $content );
2264 * Call to WikiPage function for backwards compatibility.
2265 * @see WikiPage::getHiddenCategories
2267 public function getHiddenCategories() {
2268 return $this->mPage
->getHiddenCategories();
2272 * Call to WikiPage function for backwards compatibility.
2273 * @see WikiPage::getId
2275 public function getId() {
2276 return $this->mPage
->getId();
2280 * Call to WikiPage function for backwards compatibility.
2281 * @see WikiPage::getLatest
2283 public function getLatest() {
2284 return $this->mPage
->getLatest();
2288 * Call to WikiPage function for backwards compatibility.
2289 * @see WikiPage::getLinksTimestamp
2291 public function getLinksTimestamp() {
2292 return $this->mPage
->getLinksTimestamp();
2296 * Call to WikiPage function for backwards compatibility.
2297 * @see WikiPage::getMinorEdit
2299 public function getMinorEdit() {
2300 return $this->mPage
->getMinorEdit();
2304 * Call to WikiPage function for backwards compatibility.
2305 * @see WikiPage::getOldestRevision
2307 public function getOldestRevision() {
2308 return $this->mPage
->getOldestRevision();
2312 * Call to WikiPage function for backwards compatibility.
2313 * @see WikiPage::getRedirectTarget
2315 public function getRedirectTarget() {
2316 return $this->mPage
->getRedirectTarget();
2320 * Call to WikiPage function for backwards compatibility.
2321 * @see WikiPage::getRedirectURL
2323 public function getRedirectURL( $rt ) {
2324 return $this->mPage
->getRedirectURL( $rt );
2328 * Call to WikiPage function for backwards compatibility.
2329 * @see WikiPage::getRevision
2331 public function getRevision() {
2332 return $this->mPage
->getRevision();
2336 * Call to WikiPage function for backwards compatibility.
2337 * @see WikiPage::getTimestamp
2339 public function getTimestamp() {
2340 return $this->mPage
->getTimestamp();
2344 * Call to WikiPage function for backwards compatibility.
2345 * @see WikiPage::getTouched
2347 public function getTouched() {
2348 return $this->mPage
->getTouched();
2352 * Call to WikiPage function for backwards compatibility.
2353 * @see WikiPage::getUndoContent
2355 public function getUndoContent( Revision
$undo, Revision
$undoafter = null ) {
2356 return $this->mPage
->getUndoContent( $undo, $undoafter );
2360 * Call to WikiPage function for backwards compatibility.
2361 * @see WikiPage::getUser
2363 public function getUser( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2364 return $this->mPage
->getUser( $audience, $user );
2368 * Call to WikiPage function for backwards compatibility.
2369 * @see WikiPage::getUserText
2371 public function getUserText( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2372 return $this->mPage
->getUserText( $audience, $user );
2376 * Call to WikiPage function for backwards compatibility.
2377 * @see WikiPage::hasViewableContent
2379 public function hasViewableContent() {
2380 return $this->mPage
->hasViewableContent();
2384 * Call to WikiPage function for backwards compatibility.
2385 * @see WikiPage::insertOn
2387 public function insertOn( $dbw, $pageId = null ) {
2388 return $this->mPage
->insertOn( $dbw, $pageId );
2392 * Call to WikiPage function for backwards compatibility.
2393 * @see WikiPage::insertProtectNullRevision
2395 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2396 array $expiry, $cascade, $reason, $user = null
2398 return $this->mPage
->insertProtectNullRevision( $revCommentMsg, $limit,
2399 $expiry, $cascade, $reason, $user
2404 * Call to WikiPage function for backwards compatibility.
2405 * @see WikiPage::insertRedirect
2407 public function insertRedirect() {
2408 return $this->mPage
->insertRedirect();
2412 * Call to WikiPage function for backwards compatibility.
2413 * @see WikiPage::insertRedirectEntry
2415 public function insertRedirectEntry( Title
$rt, $oldLatest = null ) {
2416 return $this->mPage
->insertRedirectEntry( $rt, $oldLatest );
2420 * Call to WikiPage function for backwards compatibility.
2421 * @see WikiPage::isCountable
2423 public function isCountable( $editInfo = false ) {
2424 return $this->mPage
->isCountable( $editInfo );
2428 * Call to WikiPage function for backwards compatibility.
2429 * @see WikiPage::isRedirect
2431 public function isRedirect() {
2432 return $this->mPage
->isRedirect();
2436 * Call to WikiPage function for backwards compatibility.
2437 * @see WikiPage::loadFromRow
2439 public function loadFromRow( $data, $from ) {
2440 return $this->mPage
->loadFromRow( $data, $from );
2444 * Call to WikiPage function for backwards compatibility.
2445 * @see WikiPage::loadPageData
2447 public function loadPageData( $from = 'fromdb' ) {
2448 $this->mPage
->loadPageData( $from );
2452 * Call to WikiPage function for backwards compatibility.
2453 * @see WikiPage::lockAndGetLatest
2455 public function lockAndGetLatest() {
2456 return $this->mPage
->lockAndGetLatest();
2460 * Call to WikiPage function for backwards compatibility.
2461 * @see WikiPage::makeParserOptions
2463 public function makeParserOptions( $context ) {
2464 return $this->mPage
->makeParserOptions( $context );
2468 * Call to WikiPage function for backwards compatibility.
2469 * @see WikiPage::pageDataFromId
2471 public function pageDataFromId( $dbr, $id, $options = [] ) {
2472 return $this->mPage
->pageDataFromId( $dbr, $id, $options );
2476 * Call to WikiPage function for backwards compatibility.
2477 * @see WikiPage::pageDataFromTitle
2479 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2480 return $this->mPage
->pageDataFromTitle( $dbr, $title, $options );
2484 * Call to WikiPage function for backwards compatibility.
2485 * @see WikiPage::prepareContentForEdit
2487 public function prepareContentForEdit(
2488 Content
$content, $revision = null, User
$user = null,
2489 $serialFormat = null, $useCache = true
2491 return $this->mPage
->prepareContentForEdit(
2492 $content, $revision, $user,
2493 $serialFormat, $useCache
2498 * Call to WikiPage function for backwards compatibility.
2499 * @see WikiPage::protectDescription
2501 public function protectDescription( array $limit, array $expiry ) {
2502 return $this->mPage
->protectDescription( $limit, $expiry );
2506 * Call to WikiPage function for backwards compatibility.
2507 * @see WikiPage::protectDescriptionLog
2509 public function protectDescriptionLog( array $limit, array $expiry ) {
2510 return $this->mPage
->protectDescriptionLog( $limit, $expiry );
2514 * Call to WikiPage function for backwards compatibility.
2515 * @see WikiPage::replaceSectionAtRev
2517 public function replaceSectionAtRev( $sectionId, Content
$sectionContent,
2518 $sectionTitle = '', $baseRevId = null
2520 return $this->mPage
->replaceSectionAtRev( $sectionId, $sectionContent,
2521 $sectionTitle, $baseRevId
2526 * Call to WikiPage function for backwards compatibility.
2527 * @see WikiPage::replaceSectionContent
2529 public function replaceSectionContent(
2530 $sectionId, Content
$sectionContent, $sectionTitle = '', $edittime = null
2532 return $this->mPage
->replaceSectionContent(
2533 $sectionId, $sectionContent, $sectionTitle, $edittime
2538 * Call to WikiPage function for backwards compatibility.
2539 * @see WikiPage::setTimestamp
2541 public function setTimestamp( $ts ) {
2542 return $this->mPage
->setTimestamp( $ts );
2546 * Call to WikiPage function for backwards compatibility.
2547 * @see WikiPage::shouldCheckParserCache
2549 public function shouldCheckParserCache( ParserOptions
$parserOptions, $oldId ) {
2550 return $this->mPage
->shouldCheckParserCache( $parserOptions, $oldId );
2554 * Call to WikiPage function for backwards compatibility.
2555 * @see WikiPage::supportsSections
2557 public function supportsSections() {
2558 return $this->mPage
->supportsSections();
2562 * Call to WikiPage function for backwards compatibility.
2563 * @see WikiPage::triggerOpportunisticLinksUpdate
2565 public function triggerOpportunisticLinksUpdate( ParserOutput
$parserOutput ) {
2566 return $this->mPage
->triggerOpportunisticLinksUpdate( $parserOutput );
2570 * Call to WikiPage function for backwards compatibility.
2571 * @see WikiPage::updateCategoryCounts
2573 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2574 return $this->mPage
->updateCategoryCounts( $added, $deleted, $id );
2578 * Call to WikiPage function for backwards compatibility.
2579 * @see WikiPage::updateIfNewerOn
2581 public function updateIfNewerOn( $dbw, $revision ) {
2582 return $this->mPage
->updateIfNewerOn( $dbw, $revision );
2586 * Call to WikiPage function for backwards compatibility.
2587 * @see WikiPage::updateRedirectOn
2589 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2590 return $this->mPage
->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect );
2594 * Call to WikiPage function for backwards compatibility.
2595 * @see WikiPage::updateRevisionOn
2597 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2598 $lastRevIsRedirect = null
2600 return $this->mPage
->updateRevisionOn( $dbw, $revision, $lastRevision,
2606 * @param array $limit
2607 * @param array $expiry
2608 * @param bool &$cascade
2609 * @param string $reason
2613 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2616 return $this->mPage
->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2620 * @param array $limit
2621 * @param string $reason
2622 * @param int &$cascade
2623 * @param array $expiry
2626 public function updateRestrictions( $limit = [], $reason = '',
2627 &$cascade = 0, $expiry = []
2629 return $this->mPage
->doUpdateRestrictions(
2634 $this->getContext()->getUser()
2639 * @param string $reason
2640 * @param bool $suppress
2641 * @param int|null $u1 Unused
2642 * @param bool|null $u2 Unused
2643 * @param string &$error
2646 public function doDeleteArticle(
2647 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2649 return $this->mPage
->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2653 * @param string $fromP
2654 * @param string $summary
2655 * @param string $token
2657 * @param array &$resultDetails
2658 * @param User|null $user
2661 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User
$user = null ) {
2662 $user = is_null( $user ) ?
$this->getContext()->getUser() : $user;
2663 return $this->mPage
->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2667 * @param string $fromP
2668 * @param string $summary
2670 * @param array &$resultDetails
2671 * @param User|null $guser
2674 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User
$guser = null ) {
2675 $guser = is_null( $guser ) ?
$this->getContext()->getUser() : $guser;
2676 return $this->mPage
->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2680 * @param bool &$hasHistory
2683 public function generateReason( &$hasHistory ) {
2684 $title = $this->mPage
->getTitle();
2685 $handler = ContentHandler
::getForTitle( $title );
2686 return $handler->getAutoDeleteReason( $title, $hasHistory );