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
24 * Class for viewing MediaWiki article and history.
26 * This maintains WikiPage functions for backwards compatibility.
28 * @todo Move and rewrite code to an Action class
30 * See design.txt for an overview.
31 * Note: edit user interface and cache support functions have been
32 * moved to separate EditPage and HTMLFileCache classes.
34 class Article
implements Page
{
35 /** @var IContextSource The context this Article is executed in */
38 /** @var WikiPage The WikiPage object of this instance */
41 /** @var ParserOptions ParserOptions object for $wgUser articles */
42 public $mParserOptions;
45 * @var string Text of the revision we are working on
51 * @var Content Content of the revision we are working on
54 public $mContentObject;
56 /** @var bool Is the content ($mContent) already loaded? */
57 public $mContentLoaded = false;
59 /** @var int|null The oldid of the article that is to be shown, 0 for the current revision */
62 /** @var Title Title from which we were redirected here */
63 public $mRedirectedFrom = null;
65 /** @var string|bool URL to redirect to or false if none */
66 public $mRedirectUrl = false;
68 /** @var int Revision ID of revision we are working on */
69 public $mRevIdFetched = 0;
71 /** @var Revision Revision we are working on */
72 public $mRevision = null;
74 /** @var ParserOutput */
75 public $mParserOutput;
78 * Constructor and clear the article
79 * @param Title $title Reference to a Title object.
80 * @param int $oldId Revision ID, null to fetch from request, zero for current
82 public function __construct( Title
$title, $oldId = null ) {
83 $this->mOldId
= $oldId;
84 $this->mPage
= $this->newPage( $title );
91 protected function newPage( Title
$title ) {
92 return new WikiPage( $title );
96 * Constructor from a page id
97 * @param int $id Article ID to load
98 * @return Article|null
100 public static function newFromID( $id ) {
101 $t = Title
::newFromID( $id );
102 # @todo FIXME: Doesn't inherit right
103 return $t == null ?
null : new self( $t );
104 # return $t == null ? null : new static( $t ); // PHP 5.3
108 * Create an Article object of the appropriate class for the given page.
110 * @param Title $title
111 * @param IContextSource $context
114 public static function newFromTitle( $title, IContextSource
$context ) {
115 if ( NS_MEDIA
== $title->getNamespace() ) {
116 // FIXME: where should this go?
117 $title = Title
::makeTitle( NS_FILE
, $title->getDBkey() );
121 Hooks
::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
123 switch ( $title->getNamespace() ) {
125 $page = new ImagePage( $title );
128 $page = new CategoryPage( $title );
131 $page = new Article( $title );
134 $page->setContext( $context );
140 * Create an Article object of the appropriate class for the given page.
142 * @param WikiPage $page
143 * @param IContextSource $context
146 public static function newFromWikiPage( WikiPage
$page, IContextSource
$context ) {
147 $article = self
::newFromTitle( $page->getTitle(), $context );
148 $article->mPage
= $page; // override to keep process cached vars
153 * Get the page this view was redirected from
157 public function getRedirectedFrom() {
158 return $this->mRedirectedFrom
;
162 * Tell the page view functions that this view was redirected
163 * from another page on the wiki.
166 public function setRedirectedFrom( Title
$from ) {
167 $this->mRedirectedFrom
= $from;
171 * Get the title object of the article
173 * @return Title Title object of this page
175 public function getTitle() {
176 return $this->mPage
->getTitle();
180 * Get the WikiPage object of this instance
185 public function getPage() {
192 public function clear() {
193 $this->mContentLoaded
= false;
195 $this->mRedirectedFrom
= null; # Title object if set
196 $this->mRevIdFetched
= 0;
197 $this->mRedirectUrl
= false;
199 $this->mPage
->clear();
203 * Note that getContent does not follow redirects anymore.
204 * If you need to fetch redirectable content easily, try
205 * the shortcut in WikiPage::getRedirectTarget()
207 * This function has side effects! Do not use this function if you
208 * only want the real revision text if any.
210 * @deprecated since 1.21; use WikiPage::getContent() instead
212 * @return string Return the text of this revision
214 public function getContent() {
215 ContentHandler
::deprecated( __METHOD__
, '1.21' );
216 $content = $this->getContentObject();
217 return ContentHandler
::getContentText( $content );
221 * Returns a Content object representing the pages effective display content,
222 * not necessarily the revision's content!
224 * Note that getContent does not follow redirects anymore.
225 * If you need to fetch redirectable content easily, try
226 * the shortcut in WikiPage::getRedirectTarget()
228 * This function has side effects! Do not use this function if you
229 * only want the real revision text if any.
231 * @return Content Return the content of this revision
235 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
= call_user_func( $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 of an article from database
323 * Does *NOT* follow redirects.
326 * @note This is really internal functionality that should really NOT be
327 * used by other functions. For accessing article content, use the WikiPage
328 * class, especially WikiBase::getContent(). However, a lot of legacy code
329 * uses this method to retrieve page text from the database, so the function
330 * has to remain public for now.
332 * @return string|bool String containing article contents, or false if null
333 * @deprecated since 1.21, use WikiPage::getContent() instead
335 function fetchContent() {
338 ContentHandler
::deprecated( __METHOD__
, '1.21' );
340 if ( $this->mContentLoaded
&& $this->mContent
) {
341 return $this->mContent
;
344 $content = $this->fetchContentObject();
350 // @todo Get rid of mContent everywhere!
351 $this->mContent
= ContentHandler
::getContentText( $content );
352 ContentHandler
::runLegacyHooks( 'ArticleAfterFetchContent', [ &$this, &$this->mContent
] );
354 return $this->mContent
;
358 * Get text content object
359 * Does *NOT* follow redirects.
360 * @todo When is this null?
362 * @note Code that wants to retrieve page content from the database should
363 * use WikiPage::getContent().
365 * @return Content|null|bool
369 protected function fetchContentObject() {
370 if ( $this->mContentLoaded
) {
371 return $this->mContentObject
;
374 $this->mContentLoaded
= true;
375 $this->mContent
= null;
377 $oldid = $this->getOldID();
379 # Pre-fill content with error message so that if something
380 # fails we'll have something telling us what we intended.
381 // XXX: this isn't page content but a UI message. horrible.
382 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
385 # $this->mRevision might already be fetched by getOldIDFromRequest()
386 if ( !$this->mRevision
) {
387 $this->mRevision
= Revision
::newFromId( $oldid );
388 if ( !$this->mRevision
) {
389 wfDebug( __METHOD__
. " failed to retrieve specified revision, id $oldid\n" );
394 $oldid = $this->mPage
->getLatest();
396 wfDebug( __METHOD__
. " failed to find page data for title " .
397 $this->getTitle()->getPrefixedText() . "\n" );
401 # Update error message with correct oldid
402 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
404 $this->mRevision
= $this->mPage
->getRevision();
406 if ( !$this->mRevision
) {
407 wfDebug( __METHOD__
. " failed to retrieve current page, rev_id $oldid\n" );
412 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
413 // We should instead work with the Revision object when we need it...
414 // Loads if user is allowed
415 $content = $this->mRevision
->getContent(
416 Revision
::FOR_THIS_USER
,
417 $this->getContext()->getUser()
421 wfDebug( __METHOD__
. " failed to retrieve content of revision " .
422 $this->mRevision
->getId() . "\n" );
426 $this->mContentObject
= $content;
427 $this->mRevIdFetched
= $this->mRevision
->getId();
429 Hooks
::run( 'ArticleAfterFetchContentObject', [ &$this, &$this->mContentObject
] );
431 return $this->mContentObject
;
435 * Returns true if the currently-referenced revision is the current edit
436 * to this page (and it exists).
439 public function isCurrent() {
440 # If no oldid, this is the current version.
441 if ( $this->getOldID() == 0 ) {
445 return $this->mPage
->exists() && $this->mRevision
&& $this->mRevision
->isCurrent();
449 * Get the fetched Revision object depending on request parameters or null
453 * @return Revision|null
455 public function getRevisionFetched() {
456 $this->fetchContentObject();
458 return $this->mRevision
;
462 * Use this to fetch the rev ID used on page views
464 * @return int Revision ID of last article revision
466 public function getRevIdFetched() {
467 if ( $this->mRevIdFetched
) {
468 return $this->mRevIdFetched
;
470 return $this->mPage
->getLatest();
475 * This is the default action of the index.php entry point: just view the
476 * page of the given title.
478 public function view() {
479 global $wgUseFileCache, $wgDebugToolbar;
481 # Get variables from query string
482 # As side effect this will load the revision and update the title
483 # in a revision ID is passed in the request, so this should remain
484 # the first call of this method even if $oldid is used way below.
485 $oldid = $this->getOldID();
487 $user = $this->getContext()->getUser();
488 # Another whitelist check in case getOldID() is altering the title
489 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
490 if ( count( $permErrors ) ) {
491 wfDebug( __METHOD__
. ": denied on secondary read check\n" );
492 throw new PermissionsError( 'read', $permErrors );
495 $outputPage = $this->getContext()->getOutput();
496 # getOldID() may as well want us to redirect somewhere else
497 if ( $this->mRedirectUrl
) {
498 $outputPage->redirect( $this->mRedirectUrl
);
499 wfDebug( __METHOD__
. ": redirecting due to oldid\n" );
504 # If we got diff in the query, we want to see a diff page instead of the article.
505 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
506 wfDebug( __METHOD__
. ": showing diff page\n" );
507 $this->showDiffPage();
512 # Set page title (may be overridden by DISPLAYTITLE)
513 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
515 $outputPage->setArticleFlag( true );
516 # Allow frames by default
517 $outputPage->allowClickjacking();
519 $parserCache = ParserCache
::singleton();
521 $parserOptions = $this->getParserOptions();
522 # Render printable version, use printable version cache
523 if ( $outputPage->isPrintable() ) {
524 $parserOptions->setIsPrintable( true );
525 $parserOptions->setEditSection( false );
526 } elseif ( !$this->isCurrent() ||
!$this->getTitle()->quickUserCan( 'edit', $user ) ) {
527 $parserOptions->setEditSection( false );
530 # Try client and file cache
531 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage
->checkTouched() ) {
532 # Try to stream the output from file cache
533 if ( $wgUseFileCache && $this->tryFileCache() ) {
534 wfDebug( __METHOD__
. ": done file cache\n" );
535 # tell wgOut that output is taken care of
536 $outputPage->disable();
537 $this->mPage
->doViewUpdates( $user, $oldid );
543 # Should the parser cache be used?
544 $useParserCache = $this->mPage
->shouldCheckParserCache( $parserOptions, $oldid );
545 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ?
'yes' : 'no' ) . "\n" );
546 if ( $user->getStubThreshold() ) {
547 $this->getContext()->getStats()->increment( 'pcache_miss_stub' );
550 $this->showRedirectedFromHeader();
551 $this->showNamespaceHeader();
553 # Iterate through the possible ways of constructing the output text.
554 # Keep going until $outputDone is set, or we run out of things to do.
557 $this->mParserOutput
= false;
559 while ( !$outputDone && ++
$pass ) {
562 Hooks
::run( 'ArticleViewHeader', [ &$this, &$outputDone, &$useParserCache ] );
565 # Early abort if the page doesn't exist
566 if ( !$this->mPage
->exists() ) {
567 wfDebug( __METHOD__
. ": showing missing article\n" );
568 $this->showMissingArticle();
569 $this->mPage
->doViewUpdates( $user );
573 # Try the parser cache
574 if ( $useParserCache ) {
575 $this->mParserOutput
= $parserCache->get( $this->mPage
, $parserOptions );
577 if ( $this->mParserOutput
!== false ) {
579 wfDebug( __METHOD__
. ": showing parser cache contents for current rev permalink\n" );
580 $this->setOldSubtitle( $oldid );
582 wfDebug( __METHOD__
. ": showing parser cache contents\n" );
584 $outputPage->addParserOutput( $this->mParserOutput
);
585 # Ensure that UI elements requiring revision ID have
586 # the correct version information.
587 $outputPage->setRevisionId( $this->mPage
->getLatest() );
588 # Preload timestamp to avoid a DB hit
589 $cachedTimestamp = $this->mParserOutput
->getTimestamp();
590 if ( $cachedTimestamp !== null ) {
591 $outputPage->setRevisionTimestamp( $cachedTimestamp );
592 $this->mPage
->setTimestamp( $cachedTimestamp );
599 # This will set $this->mRevision if needed
600 $this->fetchContentObject();
602 # Are we looking at an old revision
603 if ( $oldid && $this->mRevision
) {
604 $this->setOldSubtitle( $oldid );
606 if ( !$this->showDeletedRevisionHeader() ) {
607 wfDebug( __METHOD__
. ": cannot view deleted revision\n" );
612 # Ensure that UI elements requiring revision ID have
613 # the correct version information.
614 $outputPage->setRevisionId( $this->getRevIdFetched() );
615 # Preload timestamp to avoid a DB hit
616 $outputPage->setRevisionTimestamp( $this->mPage
->getTimestamp() );
618 # Pages containing custom CSS or JavaScript get special treatment
619 if ( $this->getTitle()->isCssOrJsPage() ||
$this->getTitle()->isCssJsSubpage() ) {
620 wfDebug( __METHOD__
. ": showing CSS/JS source\n" );
621 $this->showCssOrJsPage();
623 } elseif ( !Hooks
::run( 'ArticleContentViewCustom',
624 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
626 # Allow extensions do their own custom view for certain pages
628 } elseif ( !ContentHandler
::runLegacyHooks( 'ArticleViewCustom',
629 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
631 # Allow extensions do their own custom view for certain pages
636 # Run the parse, protected by a pool counter
637 wfDebug( __METHOD__
. ": doing uncached parse\n" );
639 $content = $this->getContentObject();
640 $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
641 $this->getRevIdFetched(), $useParserCache, $content );
643 if ( !$poolArticleView->execute() ) {
644 $error = $poolArticleView->getError();
646 $outputPage->clearHTML(); // for release() errors
647 $outputPage->enableClientCache( false );
648 $outputPage->setRobotPolicy( 'noindex,nofollow' );
650 $errortext = $error->getWikiText( false, 'view-pool-error' );
651 $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
653 # Connection or timeout error
657 $this->mParserOutput
= $poolArticleView->getParserOutput();
658 $outputPage->addParserOutput( $this->mParserOutput
);
659 if ( $content->getRedirectTarget() ) {
660 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
661 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
664 # Don't cache a dirty ParserOutput object
665 if ( $poolArticleView->getIsDirty() ) {
666 $outputPage->setCdnMaxage( 0 );
667 $outputPage->addHTML( "<!-- parser cache is expired, " .
668 "sending anyway due to pool overload-->\n" );
673 # Should be unreachable, but just in case...
679 # Get the ParserOutput actually *displayed* here.
680 # Note that $this->mParserOutput is the *current*/oldid version output.
681 $pOutput = ( $outputDone instanceof ParserOutput
)
682 ?
$outputDone // object fetched by hook
683 : $this->mParserOutput
;
685 # Adjust title for main page & pages with displaytitle
687 $this->adjustDisplayTitle( $pOutput );
690 # For the main page, overwrite the <title> element with the con-
691 # tents of 'pagetitle-view-mainpage' instead of the default (if
693 # This message always exists because it is in the i18n files
694 if ( $this->getTitle()->isMainPage() ) {
695 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
696 if ( !$msg->isDisabled() ) {
697 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
701 # Check for any __NOINDEX__ tags on the page using $pOutput
702 $policy = $this->getRobotPolicy( 'view', $pOutput );
703 $outputPage->setIndexPolicy( $policy['index'] );
704 $outputPage->setFollowPolicy( $policy['follow'] );
706 $this->showViewFooter();
707 $this->mPage
->doViewUpdates( $user, $oldid );
709 $outputPage->addModules( 'mediawiki.action.view.postEdit' );
714 * Adjust title for pages with displaytitle, -{T|}- or language conversion
715 * @param ParserOutput $pOutput
717 public function adjustDisplayTitle( ParserOutput
$pOutput ) {
718 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
719 $titleText = $pOutput->getTitleText();
720 if ( strval( $titleText ) !== '' ) {
721 $this->getContext()->getOutput()->setPageTitle( $titleText );
726 * Show a diff page according to current request variables. For use within
727 * Article::view() only, other callers should use the DifferenceEngine class.
730 protected function showDiffPage() {
731 $request = $this->getContext()->getRequest();
732 $user = $this->getContext()->getUser();
733 $diff = $request->getVal( 'diff' );
734 $rcid = $request->getVal( 'rcid' );
735 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
736 $purge = $request->getVal( 'action' ) == 'purge';
737 $unhide = $request->getInt( 'unhide' ) == 1;
738 $oldid = $this->getOldID();
740 $rev = $this->getRevisionFetched();
743 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
744 $msg = $this->getContext()->msg( 'difference-missing-revision' )
748 $this->getContext()->getOutput()->addHTML( $msg );
752 $contentHandler = $rev->getContentHandler();
753 $de = $contentHandler->createDifferenceEngine(
762 // DifferenceEngine directly fetched the revision:
763 $this->mRevIdFetched
= $de->mNewid
;
764 $de->showDiffPage( $diffOnly );
766 // Run view updates for the newer revision being diffed (and shown
767 // below the diff if not $diffOnly).
768 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
769 // New can be false, convert it to 0 - this conveniently means the latest revision
770 $this->mPage
->doViewUpdates( $user, (int)$new );
774 * Show a page view for a page formatted as CSS or JavaScript. To be called by
775 * Article::view() only.
777 * This exists mostly to serve the deprecated ShowRawCssJs hook (used to customize these views).
778 * It has been replaced by the ContentGetParserOutput hook, which lets you do the same but with
781 * @param bool $showCacheHint Whether to show a message telling the user
782 * to clear the browser cache (default: true).
784 protected function showCssOrJsPage( $showCacheHint = true ) {
785 $outputPage = $this->getContext()->getOutput();
787 if ( $showCacheHint ) {
788 $dir = $this->getContext()->getLanguage()->getDir();
789 $lang = $this->getContext()->getLanguage()->getHtmlCode();
791 $outputPage->wrapWikiMsg(
792 "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
797 $this->fetchContentObject();
799 if ( $this->mContentObject
) {
800 // Give hooks a chance to customise the output
801 if ( ContentHandler
::runLegacyHooks(
803 [ $this->mContentObject
, $this->getTitle(), $outputPage ] )
805 // If no legacy hooks ran, display the content of the parser output, including RL modules,
806 // but excluding metadata like categories and language links
807 $po = $this->mContentObject
->getParserOutput( $this->getTitle() );
808 $outputPage->addParserOutputContent( $po );
814 * Get the robot policy to be used for the current view
815 * @param string $action The action= GET parameter
816 * @param ParserOutput|null $pOutput
817 * @return array The policy that should be set
818 * @todo actions other than 'view'
820 public function getRobotPolicy( $action, $pOutput = null ) {
821 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
823 $ns = $this->getTitle()->getNamespace();
825 # Don't index user and user talk pages for blocked users (bug 11443)
826 if ( ( $ns == NS_USER ||
$ns == NS_USER_TALK
) && !$this->getTitle()->isSubpage() ) {
827 $specificTarget = null;
829 $titleText = $this->getTitle()->getText();
830 if ( IP
::isValid( $titleText ) ) {
831 $vagueTarget = $titleText;
833 $specificTarget = $titleText;
835 if ( Block
::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block
) {
837 'index' => 'noindex',
838 'follow' => 'nofollow'
843 if ( $this->mPage
->getId() === 0 ||
$this->getOldID() ) {
844 # Non-articles (special pages etc), and old revisions
846 'index' => 'noindex',
847 'follow' => 'nofollow'
849 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
850 # Discourage indexing of printable versions, but encourage following
852 'index' => 'noindex',
855 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
856 # For ?curid=x urls, disallow indexing
858 'index' => 'noindex',
863 # Otherwise, construct the policy based on the various config variables.
864 $policy = self
::formatRobotPolicy( $wgDefaultRobotPolicy );
866 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
867 # Honour customised robot policies for this namespace
868 $policy = array_merge(
870 self
::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
873 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
874 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
875 # a final sanity check that we have really got the parser output.
876 $policy = array_merge(
878 [ 'index' => $pOutput->getIndexPolicy() ]
882 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
883 # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
884 $policy = array_merge(
886 self
::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
894 * Converts a String robot policy into an associative array, to allow
895 * merging of several policies using array_merge().
896 * @param array|string $policy Returns empty array on null/false/'', transparent
897 * to already-converted arrays, converts string.
898 * @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
900 public static function formatRobotPolicy( $policy ) {
901 if ( is_array( $policy ) ) {
903 } elseif ( !$policy ) {
907 $policy = explode( ',', $policy );
908 $policy = array_map( 'trim', $policy );
911 foreach ( $policy as $var ) {
912 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
913 $arr['index'] = $var;
914 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
915 $arr['follow'] = $var;
923 * If this request is a redirect view, send "redirected from" subtitle to
924 * the output. Returns true if the header was needed, false if this is not
925 * a redirect view. Handles both local and remote redirects.
929 public function showRedirectedFromHeader() {
930 global $wgRedirectSources;
932 $context = $this->getContext();
933 $outputPage = $context->getOutput();
934 $request = $context->getRequest();
935 $rdfrom = $request->getVal( 'rdfrom' );
937 // Construct a URL for the current page view, but with the target title
938 $query = $request->getValues();
939 unset( $query['rdfrom'] );
940 unset( $query['title'] );
941 if ( $this->getTitle()->isRedirect() ) {
942 // Prevent double redirects
943 $query['redirect'] = 'no';
945 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
947 if ( isset( $this->mRedirectedFrom
) ) {
948 // This is an internally redirected page view.
949 // We'll need a backlink to the source page for navigation.
950 if ( Hooks
::run( 'ArticleViewRedirect', [ &$this ] ) ) {
951 $redir = Linker
::linkKnown(
952 $this->mRedirectedFrom
,
955 [ 'redirect' => 'no' ]
958 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
959 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
962 // Add the script to update the displayed URL and
963 // set the fragment if one was specified in the redirect
964 $outputPage->addJsConfigVars( [
965 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
967 $outputPage->addModules( 'mediawiki.action.view.redirect' );
969 // Add a <link rel="canonical"> tag
970 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
972 // Tell the output object that the user arrived at this article through a redirect
973 $outputPage->setRedirectedFrom( $this->mRedirectedFrom
);
977 } elseif ( $rdfrom ) {
978 // This is an externally redirected view, from some other wiki.
979 // If it was reported from a trusted site, supply a backlink.
980 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
981 $redir = Linker
::makeExternalLink( $rdfrom, $rdfrom );
982 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
983 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
986 // Add the script to update the displayed URL
987 $outputPage->addJsConfigVars( [
988 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
990 $outputPage->addModules( 'mediawiki.action.view.redirect' );
1000 * Show a header specific to the namespace currently being viewed, like
1001 * [[MediaWiki:Talkpagetext]]. For Article::view().
1003 public function showNamespaceHeader() {
1004 if ( $this->getTitle()->isTalkPage() ) {
1005 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
1006 $this->getContext()->getOutput()->wrapWikiMsg(
1007 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
1008 [ 'talkpageheader' ]
1015 * Show the footer section of an ordinary page view
1017 public function showViewFooter() {
1018 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
1019 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
1020 && IP
::isValid( $this->getTitle()->getText() )
1022 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
1025 // Show a footer allowing the user to patrol the shown revision or page if possible
1026 $patrolFooterShown = $this->showPatrolFooter();
1028 Hooks
::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
1032 * If patrol is possible, output a patrol UI box. This is called from the
1033 * footer section of ordinary page views. If patrol is not possible or not
1034 * desired, does nothing.
1035 * Side effect: When the patrol link is build, this method will call
1036 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
1040 public function showPatrolFooter() {
1041 global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
1043 $outputPage = $this->getContext()->getOutput();
1044 $user = $this->getContext()->getUser();
1045 $title = $this->getTitle();
1048 if ( !$title->quickUserCan( 'patrol', $user )
1049 ||
!( $wgUseRCPatrol ||
$wgUseNPPatrol
1050 ||
( $wgUseFilePatrol && $title->inNamespace( NS_FILE
) ) )
1052 // Patrolling is disabled or the user isn't allowed to
1056 if ( $this->mRevision
1057 && !RecentChange
::isInRCLifespan( $this->mRevision
->getTimestamp(), 21600 )
1059 // The current revision is already older than what could be in the RC table
1060 // 6h tolerance because the RC might not be cleaned out regularly
1064 // Check for cached results
1065 $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() );
1066 $cache = ObjectCache
::getMainWANInstance();
1067 if ( $cache->get( $key ) ) {
1071 $dbr = wfGetDB( DB_REPLICA
);
1072 $oldestRevisionTimestamp = $dbr->selectField(
1074 'MIN( rev_timestamp )',
1075 [ 'rev_page' => $title->getArticleID() ],
1079 // New page patrol: Get the timestamp of the oldest revison which
1080 // the revision table holds for the given page. Then we look
1081 // whether it's within the RC lifespan and if it is, we try
1082 // to get the recentchanges row belonging to that entry
1083 // (with rc_new = 1).
1084 $recentPageCreation = false;
1085 if ( $oldestRevisionTimestamp
1086 && RecentChange
::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
1088 // 6h tolerance because the RC might not be cleaned out regularly
1089 $recentPageCreation = true;
1090 $rc = RecentChange
::newFromConds(
1093 'rc_timestamp' => $oldestRevisionTimestamp,
1094 'rc_namespace' => $title->getNamespace(),
1095 'rc_cur_id' => $title->getArticleID()
1100 // Use generic patrol message for new pages
1101 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1105 // File patrol: Get the timestamp of the latest upload for this page,
1106 // check whether it is within the RC lifespan and if it is, we try
1107 // to get the recentchanges row belonging to that entry
1108 // (with rc_type = RC_LOG, rc_log_type = upload).
1109 $recentFileUpload = false;
1110 if ( ( !$rc ||
$rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1111 && $title->getNamespace() === NS_FILE
) {
1112 // Retrieve timestamp of most recent upload
1113 $newestUploadTimestamp = $dbr->selectField(
1115 'MAX( img_timestamp )',
1116 [ 'img_name' => $title->getDBkey() ],
1119 if ( $newestUploadTimestamp
1120 && RecentChange
::isInRCLifespan( $newestUploadTimestamp, 21600 )
1122 // 6h tolerance because the RC might not be cleaned out regularly
1123 $recentFileUpload = true;
1124 $rc = RecentChange
::newFromConds(
1126 'rc_type' => RC_LOG
,
1127 'rc_log_type' => 'upload',
1128 'rc_timestamp' => $newestUploadTimestamp,
1129 'rc_namespace' => NS_FILE
,
1130 'rc_cur_id' => $title->getArticleID()
1133 [ 'USE INDEX' => 'rc_timestamp' ]
1136 // Use patrol message specific to files
1137 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1142 if ( !$recentPageCreation && !$recentFileUpload ) {
1143 // Page creation and latest upload (for files) is too old to be in RC
1145 // We definitely can't patrol so cache the information
1146 // When a new file version is uploaded, the cache is cleared
1147 $cache->set( $key, '1' );
1153 // Don't cache: This can be hit if the page gets accessed very fast after
1154 // its creation / latest upload or in case we have high replica DB lag. In case
1155 // the revision is too old, we will already return above.
1159 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1160 // Patrolled RC entry around
1162 // Cache the information we gathered above in case we can't patrol
1163 // Don't cache in case we can patrol as this could change
1164 $cache->set( $key, '1' );
1169 if ( $rc->getPerformer()->equals( $user ) ) {
1170 // Don't show a patrol link for own creations/uploads. If the user could
1171 // patrol them, they already would be patrolled
1175 $rcid = $rc->getAttribute( 'rc_id' );
1177 $token = $user->getEditToken( $rcid );
1179 $outputPage->preventClickjacking();
1180 if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
1181 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1184 $link = Linker
::linkKnown(
1186 $markPatrolledMsg->escaped(),
1189 'action' => 'markpatrolled',
1195 $outputPage->addHTML(
1196 "<div class='patrollink' data-mw='interface'>" .
1197 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1205 * Purge the cache used to check if it is worth showing the patrol footer
1206 * For example, it is done during re-uploads when file patrol is used.
1207 * @param int $articleID ID of the article to purge
1210 public static function purgePatrolFooterCache( $articleID ) {
1211 $cache = ObjectCache
::getMainWANInstance();
1212 $cache->delete( wfMemcKey( 'unpatrollable-page', $articleID ) );
1216 * Show the error text for a missing article. For articles in the MediaWiki
1217 * namespace, show the default message text. To be called from Article::view().
1219 public function showMissingArticle() {
1220 global $wgSend404Code;
1222 $outputPage = $this->getContext()->getOutput();
1223 // Whether the page is a root user page of an existing user (but not a subpage)
1224 $validUserPage = false;
1226 $title = $this->getTitle();
1228 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1229 if ( $title->getNamespace() == NS_USER
1230 ||
$title->getNamespace() == NS_USER_TALK
1232 $rootPart = explode( '/', $title->getText() )[0];
1233 $user = User
::newFromName( $rootPart, false /* allow IP users*/ );
1234 $ip = User
::isIP( $rootPart );
1235 $block = Block
::newFromTarget( $user, $user );
1237 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1238 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1239 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1240 } elseif ( !is_null( $block ) && $block->getType() != Block
::TYPE_AUTO
) {
1241 # Show log extract if the user is currently blocked
1242 LogEventsList
::showLogExtract(
1245 MWNamespace
::getCanonicalName( NS_USER
) . ':' . $block->getTarget(),
1249 'showIfEmpty' => false,
1251 'blocked-notice-logextract',
1252 $user->getName() # Support GENDER in notice
1256 $validUserPage = !$title->isSubpage();
1258 $validUserPage = !$title->isSubpage();
1262 Hooks
::run( 'ShowMissingArticle', [ $this ] );
1264 # Show delete and move logs if there were any such events.
1265 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1266 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1267 $cache = ObjectCache
::getMainStashInstance();
1268 $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1269 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1270 if ( $loggedIn ||
$cache->get( $key ) ) {
1271 $logTypes = [ 'delete', 'move' ];
1272 $conds = [ "log_action != 'revision'" ];
1273 // Give extensions a chance to hide their (unrelated) log entries
1274 Hooks
::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1275 LogEventsList
::showLogExtract(
1283 'showIfEmpty' => false,
1284 'msgKey' => [ $loggedIn
1285 ?
'moveddeleted-notice'
1286 : 'moveddeleted-notice-recent'
1292 if ( !$this->mPage
->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1293 // If there's no backing content, send a 404 Not Found
1294 // for better machine handling of broken links.
1295 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1298 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1299 $policy = $this->getRobotPolicy( 'view' );
1300 $outputPage->setIndexPolicy( $policy['index'] );
1301 $outputPage->setFollowPolicy( $policy['follow'] );
1303 $hookResult = Hooks
::run( 'BeforeDisplayNoArticleText', [ $this ] );
1305 if ( !$hookResult ) {
1309 # Show error message
1310 $oldid = $this->getOldID();
1311 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI
&& $title->hasSourceText() ) {
1312 $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
1315 $text = wfMessage( 'missing-revision', $oldid )->plain();
1316 } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1317 && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1319 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
1320 $text = wfMessage( $message )->plain();
1322 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1325 $dir = $this->getContext()->getLanguage()->getDir();
1326 $lang = $this->getContext()->getLanguage()->getCode();
1327 $outputPage->addWikiText( Xml
::openElement( 'div', [
1328 'class' => "noarticletext mw-content-$dir",
1331 ] ) . "\n$text\n</div>" );
1336 * If the revision requested for view is deleted, check permissions.
1337 * Send either an error message or a warning header to the output.
1339 * @return bool True if the view is allowed, false if not.
1341 public function showDeletedRevisionHeader() {
1342 if ( !$this->mRevision
->isDeleted( Revision
::DELETED_TEXT
) ) {
1347 $outputPage = $this->getContext()->getOutput();
1348 $user = $this->getContext()->getUser();
1349 // If the user is not allowed to see it...
1350 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
, $user ) ) {
1351 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1352 'rev-deleted-text-permission' );
1355 // If the user needs to confirm that they want to see it...
1356 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1357 # Give explanation and add a link to view the revision...
1358 $oldid = intval( $this->getOldID() );
1359 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1360 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1361 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1362 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1366 // We are allowed to see...
1368 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1369 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1370 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1377 * Generate the navigation links when browsing through an article revisions
1378 * It shows the information as:
1379 * Revision as of \<date\>; view current revision
1380 * \<- Previous version | Next Version -\>
1382 * @param int $oldid Revision ID of this article revision
1384 public function setOldSubtitle( $oldid = 0 ) {
1385 if ( !Hooks
::run( 'DisplayOldSubtitle', [ &$this, &$oldid ] ) ) {
1389 $context = $this->getContext();
1390 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1392 # Cascade unhide param in links for easy deletion browsing
1395 $extraParams['unhide'] = 1;
1398 if ( $this->mRevision
&& $this->mRevision
->getId() === $oldid ) {
1399 $revision = $this->mRevision
;
1401 $revision = Revision
::newFromId( $oldid );
1404 $timestamp = $revision->getTimestamp();
1406 $current = ( $oldid == $this->mPage
->getLatest() );
1407 $language = $context->getLanguage();
1408 $user = $context->getUser();
1410 $td = $language->userTimeAndDate( $timestamp, $user );
1411 $tddate = $language->userDate( $timestamp, $user );
1412 $tdtime = $language->userTime( $timestamp, $user );
1414 # Show user links if allowed to see them. If hidden, then show them only if requested...
1415 $userlinks = Linker
::revUserTools( $revision, !$unhide );
1417 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1418 ?
'revision-info-current'
1421 $outputPage = $context->getOutput();
1422 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1423 $context->msg( $infomsg, $td )
1424 ->rawParams( $userlinks )
1425 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1426 ->rawParams( Linker
::revComment( $revision, true, true ) )
1431 ?
$context->msg( 'currentrevisionlink' )->escaped()
1432 : Linker
::linkKnown(
1434 $context->msg( 'currentrevisionlink' )->escaped(),
1439 ?
$context->msg( 'diff' )->escaped()
1440 : Linker
::linkKnown(
1442 $context->msg( 'diff' )->escaped(),
1449 $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1451 ? Linker
::linkKnown(
1453 $context->msg( 'previousrevision' )->escaped(),
1456 'direction' => 'prev',
1460 : $context->msg( 'previousrevision' )->escaped();
1462 ? Linker
::linkKnown(
1464 $context->msg( 'diff' )->escaped(),
1471 : $context->msg( 'diff' )->escaped();
1472 $nextlink = $current
1473 ?
$context->msg( 'nextrevision' )->escaped()
1474 : Linker
::linkKnown(
1476 $context->msg( 'nextrevision' )->escaped(),
1479 'direction' => 'next',
1483 $nextdiff = $current
1484 ?
$context->msg( 'diff' )->escaped()
1485 : Linker
::linkKnown(
1487 $context->msg( 'diff' )->escaped(),
1495 $cdel = Linker
::getRevDeleteLink( $user, $revision, $this->getTitle() );
1496 if ( $cdel !== '' ) {
1500 // the outer div is need for styling the revision info and nav in MobileFrontend
1501 $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1502 "<div id=\"mw-revision-nav\">" . $cdel .
1503 $context->msg( 'revision-nav' )->rawParams(
1504 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1505 )->escaped() . "</div></div>" );
1509 * Return the HTML for the top of a redirect page
1511 * Chances are you should just be using the ParserOutput from
1512 * WikitextContent::getParserOutput instead of calling this for redirects.
1514 * @param Title|array $target Destination(s) to redirect
1515 * @param bool $appendSubtitle [optional]
1516 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1517 * @return string Containing HTML with redirect link
1519 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1520 $lang = $this->getTitle()->getPageLanguage();
1521 $out = $this->getContext()->getOutput();
1522 if ( $appendSubtitle ) {
1523 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1525 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1526 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1530 * Return the HTML for the top of a redirect page
1532 * Chances are you should just be using the ParserOutput from
1533 * WikitextContent::getParserOutput instead of calling this for redirects.
1536 * @param Language $lang
1537 * @param Title|array $target Destination(s) to redirect
1538 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1539 * @return string Containing HTML with redirect link
1541 public static function getRedirectHeaderHtml( Language
$lang, $target, $forceKnown = false ) {
1542 if ( !is_array( $target ) ) {
1543 $target = [ $target ];
1546 $html = '<ul class="redirectText">';
1547 /** @var Title $title */
1548 foreach ( $target as $title ) {
1549 $html .= '<li>' . Linker
::link(
1551 htmlspecialchars( $title->getFullText() ),
1553 // Make sure wiki page redirects are not followed
1554 $title->isRedirect() ?
[ 'redirect' => 'no' ] : [],
1555 ( $forceKnown ?
[ 'known', 'noclasses' ] : [] )
1560 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1562 return '<div class="redirectMsg">' .
1563 '<p>' . $redirectToText . '</p>' .
1569 * Adds help link with an icon via page indicators.
1570 * Link target can be overridden by a local message containing a wikilink:
1571 * the message key is: 'namespace-' + namespace number + '-helppage'.
1572 * @param string $to Target MediaWiki.org page title or encoded URL.
1573 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
1576 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1578 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1581 $out = $this->getContext()->getOutput();
1582 if ( !$msg->isDisabled() ) {
1583 $helpUrl = Skin
::makeUrl( $msg->plain() );
1584 $out->addHelpLink( $helpUrl, true );
1586 $out->addHelpLink( $to, $overrideBaseUrl );
1591 * Handle action=render
1593 public function render() {
1594 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1595 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1596 $this->getContext()->getOutput()->enableSectionEditLinks( false );
1601 * action=protect handler
1603 public function protect() {
1604 $form = new ProtectionForm( $this );
1609 * action=unprotect handler (alias)
1611 public function unprotect() {
1616 * UI entry point for page deletion
1618 public function delete() {
1619 # This code desperately needs to be totally rewritten
1621 $title = $this->getTitle();
1622 $context = $this->getContext();
1623 $user = $context->getUser();
1624 $request = $context->getRequest();
1627 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1628 if ( count( $permissionErrors ) ) {
1629 throw new PermissionsError( 'delete', $permissionErrors );
1632 # Read-only check...
1633 if ( wfReadOnly() ) {
1634 throw new ReadOnlyError
;
1637 # Better double-check that it hasn't been deleted yet!
1638 $this->mPage
->loadPageData(
1639 $request->wasPosted() ? WikiPage
::READ_LATEST
: WikiPage
::READ_NORMAL
1641 if ( !$this->mPage
->exists() ) {
1642 $deleteLogPage = new LogPage( 'delete' );
1643 $outputPage = $context->getOutput();
1644 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1645 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1646 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1648 $outputPage->addHTML(
1649 Xml
::element( 'h2', null, $deleteLogPage->getName()->text() )
1651 LogEventsList
::showLogExtract(
1660 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1661 $deleteReason = $request->getText( 'wpReason' );
1663 if ( $deleteReasonList == 'other' ) {
1664 $reason = $deleteReason;
1665 } elseif ( $deleteReason != '' ) {
1666 // Entry from drop down menu + additional comment
1667 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1668 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1670 $reason = $deleteReasonList;
1673 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1674 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1676 # Flag to hide all contents of the archived revisions
1677 $suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1679 $this->doDelete( $reason, $suppress );
1681 WatchAction
::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1686 // Generate deletion reason
1687 $hasHistory = false;
1690 $reason = $this->generateReason( $hasHistory );
1691 } catch ( Exception
$e ) {
1692 # if a page is horribly broken, we still want to be able to
1693 # delete it. So be lenient about errors here.
1694 wfDebug( "Error while building auto delete summary: $e" );
1699 // If the page has a history, insert a warning
1700 if ( $hasHistory ) {
1701 $title = $this->getTitle();
1703 // The following can use the real revision count as this is only being shown for users
1704 // that can delete this page.
1705 // This, as a side-effect, also makes sure that the following query isn't being run for
1706 // pages with a larger history, unless the user has the 'bigdelete' right
1707 // (and is about to delete this page).
1708 $dbr = wfGetDB( DB_REPLICA
);
1709 $revisions = $edits = (int)$dbr->selectField(
1712 [ 'rev_page' => $title->getArticleID() ],
1716 // @todo FIXME: i18n issue/patchwork message
1717 $context->getOutput()->addHTML(
1718 '<strong class="mw-delete-warning-revisions">' .
1719 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1720 $context->msg( 'word-separator' )->escaped() . Linker
::linkKnown( $title,
1721 $context->msg( 'history' )->escaped(),
1723 [ 'action' => 'history' ] ) .
1727 if ( $title->isBigDeletion() ) {
1728 global $wgDeleteRevisionsLimit;
1729 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1731 'delete-warning-toobig',
1732 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1738 $this->confirmDelete( $reason );
1742 * Output deletion confirmation dialog
1743 * @todo FIXME: Move to another file?
1744 * @param string $reason Prefilled reason
1746 public function confirmDelete( $reason ) {
1747 wfDebug( "Article::confirmDelete\n" );
1749 $title = $this->getTitle();
1750 $ctx = $this->getContext();
1751 $outputPage = $ctx->getOutput();
1752 $useMediaWikiUIEverywhere = $ctx->getConfig()->get( 'UseMediaWikiUIEverywhere' );
1753 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1754 $outputPage->addBacklinkSubtitle( $title );
1755 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1756 $backlinkCache = $title->getBacklinkCache();
1757 if ( $backlinkCache->hasLinks( 'pagelinks' ) ||
$backlinkCache->hasLinks( 'templatelinks' ) ) {
1758 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1759 'deleting-backlinks-warning' );
1761 $outputPage->addWikiMsg( 'confirmdeletetext' );
1763 Hooks
::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1765 $user = $this->getContext()->getUser();
1767 if ( $user->isAllowed( 'suppressrevision' ) ) {
1768 $suppress = Html
::openElement( 'div', [ 'id' => 'wpDeleteSuppressRow' ] ) .
1769 Xml
::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
1770 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '4' ] ) .
1771 Html
::closeElement( 'div' );
1775 $checkWatch = $user->getBoolOption( 'watchdeletion' ) ||
$user->isWatched( $title );
1777 $form = Html
::openElement( 'form', [ 'method' => 'post',
1778 'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ] ) .
1779 Html
::openElement( 'fieldset', [ 'id' => 'mw-delete-table' ] ) .
1780 Html
::element( 'legend', null, wfMessage( 'delete-legend' )->text() ) .
1781 Html
::openElement( 'div', [ 'id' => 'mw-deleteconfirm-table' ] ) .
1782 Html
::openElement( 'div', [ 'id' => 'wpDeleteReasonListRow' ] ) .
1783 Html
::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
1786 'wpDeleteReasonList',
1787 wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
1788 wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(),
1793 Html
::closeElement( 'div' ) .
1794 Html
::openElement( 'div', [ 'id' => 'wpDeleteReasonRow' ] ) .
1795 Html
::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) .
1797 Html
::input( 'wpReason', $reason, 'text', [
1799 'maxlength' => '255',
1802 'class' => 'mw-ui-input-inline',
1805 Html
::closeElement( 'div' );
1807 # Disallow watching if user is not logged in
1808 if ( $user->isLoggedIn() ) {
1810 Xml
::checkLabel( wfMessage( 'watchthis' )->text(),
1811 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] );
1815 Html
::openElement( 'div' ) .
1817 Xml
::submitButton( wfMessage( 'deletepage' )->text(),
1819 'name' => 'wpConfirmB',
1820 'id' => 'wpConfirmB',
1822 'class' => $useMediaWikiUIEverywhere ?
'mw-ui-button mw-ui-destructive' : '',
1825 Html
::closeElement( 'div' ) .
1826 Html
::closeElement( 'div' ) .
1827 Xml
::closeElement( 'fieldset' ) .
1830 $user->getEditToken( [ 'delete', $title->getPrefixedText() ] )
1832 Xml
::closeElement( 'form' );
1834 if ( $user->isAllowed( 'editinterface' ) ) {
1835 $link = Linker
::linkKnown(
1836 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1837 wfMessage( 'delete-edit-reasonlist' )->escaped(),
1839 [ 'action' => 'edit' ]
1841 $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
1844 $outputPage->addHTML( $form );
1846 $deleteLogPage = new LogPage( 'delete' );
1847 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1848 LogEventsList
::showLogExtract( $outputPage, 'delete', $title );
1852 * Perform a deletion and output success or failure messages
1853 * @param string $reason
1854 * @param bool $suppress
1856 public function doDelete( $reason, $suppress = false ) {
1858 $context = $this->getContext();
1859 $outputPage = $context->getOutput();
1860 $user = $context->getUser();
1861 $status = $this->mPage
->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
1863 if ( $status->isGood() ) {
1864 $deleted = $this->getTitle()->getPrefixedText();
1866 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1867 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1869 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1871 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1873 Hooks
::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
1875 $outputPage->returnToMain( false );
1877 $outputPage->setPageTitle(
1878 wfMessage( 'cannotdelete-title',
1879 $this->getTitle()->getPrefixedText() )
1882 if ( $error == '' ) {
1883 $outputPage->addWikiText(
1884 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1886 $deleteLogPage = new LogPage( 'delete' );
1887 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1889 LogEventsList
::showLogExtract(
1895 $outputPage->addHTML( $error );
1900 /* Caching functions */
1903 * checkLastModified returns true if it has taken care of all
1904 * output to the client that is necessary for this request.
1905 * (that is, it has sent a cached version of the page)
1907 * @return bool True if cached version send, false otherwise
1909 protected function tryFileCache() {
1910 static $called = false;
1913 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1918 if ( $this->isFileCacheable() ) {
1919 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
1920 if ( $cache->isCacheGood( $this->mPage
->getTouched() ) ) {
1921 wfDebug( "Article::tryFileCache(): about to load file\n" );
1922 $cache->loadFromFileCache( $this->getContext() );
1925 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1926 ob_start( [ &$cache, 'saveToFileCache' ] );
1929 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1936 * Check if the page can be cached
1939 public function isFileCacheable() {
1942 if ( HTMLFileCache
::useFileCache( $this->getContext() ) ) {
1943 $cacheable = $this->mPage
->getId()
1944 && !$this->mRedirectedFrom
&& !$this->getTitle()->isRedirect();
1945 // Extension may have reason to disable file caching on some pages.
1947 $cacheable = Hooks
::run( 'IsFileCacheable', [ &$this ] );
1957 * Lightweight method to get the parser output for a page, checking the parser cache
1958 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1959 * consider, so it's not appropriate to use there.
1961 * @since 1.16 (r52326) for LiquidThreads
1963 * @param int|null $oldid Revision ID or null
1964 * @param User $user The relevant user
1965 * @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
1967 public function getParserOutput( $oldid = null, User
$user = null ) {
1968 // XXX: bypasses mParserOptions and thus setParserOptions()
1970 if ( $user === null ) {
1971 $parserOptions = $this->getParserOptions();
1973 $parserOptions = $this->mPage
->makeParserOptions( $user );
1976 return $this->mPage
->getParserOutput( $parserOptions, $oldid );
1980 * Override the ParserOptions used to render the primary article wikitext.
1982 * @param ParserOptions $options
1983 * @throws MWException If the parser options where already initialized.
1985 public function setParserOptions( ParserOptions
$options ) {
1986 if ( $this->mParserOptions
) {
1987 throw new MWException( "can't change parser options after they have already been set" );
1990 // clone, so if $options is modified later, it doesn't confuse the parser cache.
1991 $this->mParserOptions
= clone $options;
1995 * Get parser options suitable for rendering the primary article wikitext
1996 * @return ParserOptions
1998 public function getParserOptions() {
1999 if ( !$this->mParserOptions
) {
2000 $this->mParserOptions
= $this->mPage
->makeParserOptions( $this->getContext() );
2002 // Clone to allow modifications of the return value without affecting cache
2003 return clone $this->mParserOptions
;
2007 * Sets the context this Article is executed in
2009 * @param IContextSource $context
2012 public function setContext( $context ) {
2013 $this->mContext
= $context;
2017 * Gets the context this Article is executed in
2019 * @return IContextSource
2022 public function getContext() {
2023 if ( $this->mContext
instanceof IContextSource
) {
2024 return $this->mContext
;
2026 wfDebug( __METHOD__
. " called and \$mContext is null. " .
2027 "Return RequestContext::getMain(); for sanity\n" );
2028 return RequestContext
::getMain();
2033 * Use PHP's magic __get handler to handle accessing of
2034 * raw WikiPage fields for backwards compatibility.
2036 * @param string $fname Field name
2039 public function __get( $fname ) {
2040 if ( property_exists( $this->mPage
, $fname ) ) {
2041 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2042 return $this->mPage
->$fname;
2044 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE
);
2048 * Use PHP's magic __set handler to handle setting of
2049 * raw WikiPage fields for backwards compatibility.
2051 * @param string $fname Field name
2052 * @param mixed $fvalue New value
2054 public function __set( $fname, $fvalue ) {
2055 if ( property_exists( $this->mPage
, $fname ) ) {
2056 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2057 $this->mPage
->$fname = $fvalue;
2058 // Note: extensions may want to toss on new fields
2059 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
2060 $this->mPage
->$fname = $fvalue;
2062 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE
);
2067 * Call to WikiPage function for backwards compatibility.
2068 * @see WikiPage::checkFlags
2070 public function checkFlags( $flags ) {
2071 return $this->mPage
->checkFlags( $flags );
2075 * Call to WikiPage function for backwards compatibility.
2076 * @see WikiPage::checkTouched
2078 public function checkTouched() {
2079 return $this->mPage
->checkTouched();
2083 * Call to WikiPage function for backwards compatibility.
2084 * @see WikiPage::clearPreparedEdit
2086 public function clearPreparedEdit() {
2087 $this->mPage
->clearPreparedEdit();
2091 * Call to WikiPage function for backwards compatibility.
2092 * @see WikiPage::doDeleteArticleReal
2094 public function doDeleteArticleReal(
2095 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User
$user = null
2097 return $this->mPage
->doDeleteArticleReal(
2098 $reason, $suppress, $u1, $u2, $error, $user
2103 * Call to WikiPage function for backwards compatibility.
2104 * @see WikiPage::doDeleteUpdates
2106 public function doDeleteUpdates( $id, Content
$content = null ) {
2107 return $this->mPage
->doDeleteUpdates( $id, $content );
2111 * Call to WikiPage function for backwards compatibility.
2112 * @see WikiPage::doEdit
2114 public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
2115 ContentHandler
::deprecated( __METHOD__
, '1.21' );
2116 return $this->mPage
->doEdit( $text, $summary, $flags, $baseRevId, $user );
2120 * Call to WikiPage function for backwards compatibility.
2121 * @see WikiPage::doEditContent
2123 public function doEditContent( Content
$content, $summary, $flags = 0, $baseRevId = false,
2124 User
$user = null, $serialFormat = null
2126 return $this->mPage
->doEditContent( $content, $summary, $flags, $baseRevId,
2127 $user, $serialFormat
2132 * Call to WikiPage function for backwards compatibility.
2133 * @see WikiPage::doEditUpdates
2135 public function doEditUpdates( Revision
$revision, User
$user, array $options = [] ) {
2136 return $this->mPage
->doEditUpdates( $revision, $user, $options );
2140 * Call to WikiPage function for backwards compatibility.
2141 * @see WikiPage::doPurge
2143 public function doPurge() {
2144 return $this->mPage
->doPurge();
2148 * Call to WikiPage function for backwards compatibility.
2149 * @see WikiPage::doQuickEditContent
2151 public function doQuickEditContent(
2152 Content
$content, User
$user, $comment = '', $minor = false, $serialFormat = null
2154 return $this->mPage
->doQuickEditContent(
2155 $content, $user, $comment, $minor, $serialFormat
2160 * Call to WikiPage function for backwards compatibility.
2161 * @see WikiPage::doViewUpdates
2163 public function doViewUpdates( User
$user, $oldid = 0 ) {
2164 $this->mPage
->doViewUpdates( $user, $oldid );
2168 * Call to WikiPage function for backwards compatibility.
2169 * @see WikiPage::exists
2171 public function exists() {
2172 return $this->mPage
->exists();
2176 * Call to WikiPage function for backwards compatibility.
2177 * @see WikiPage::followRedirect
2179 public function followRedirect() {
2180 return $this->mPage
->followRedirect();
2184 * Call to WikiPage function for backwards compatibility.
2185 * @see ContentHandler::getActionOverrides
2187 public function getActionOverrides() {
2188 return $this->mPage
->getActionOverrides();
2192 * Call to WikiPage function for backwards compatibility.
2193 * @see WikiPage::getAutoDeleteReason
2195 public function getAutoDeleteReason( &$hasHistory ) {
2196 return $this->mPage
->getAutoDeleteReason( $hasHistory );
2200 * Call to WikiPage function for backwards compatibility.
2201 * @see WikiPage::getCategories
2203 public function getCategories() {
2204 return $this->mPage
->getCategories();
2208 * Call to WikiPage function for backwards compatibility.
2209 * @see WikiPage::getComment
2211 public function getComment( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2212 return $this->mPage
->getComment( $audience, $user );
2216 * Call to WikiPage function for backwards compatibility.
2217 * @see WikiPage::getContentHandler
2219 public function getContentHandler() {
2220 return $this->mPage
->getContentHandler();
2224 * Call to WikiPage function for backwards compatibility.
2225 * @see WikiPage::getContentModel
2227 public function getContentModel() {
2228 return $this->mPage
->getContentModel();
2232 * Call to WikiPage function for backwards compatibility.
2233 * @see WikiPage::getContributors
2235 public function getContributors() {
2236 return $this->mPage
->getContributors();
2240 * Call to WikiPage function for backwards compatibility.
2241 * @see WikiPage::getCreator
2243 public function getCreator( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2244 return $this->mPage
->getCreator( $audience, $user );
2248 * Call to WikiPage function for backwards compatibility.
2249 * @see WikiPage::getDeletionUpdates
2251 public function getDeletionUpdates( Content
$content = null ) {
2252 return $this->mPage
->getDeletionUpdates( $content );
2256 * Call to WikiPage function for backwards compatibility.
2257 * @see WikiPage::getHiddenCategories
2259 public function getHiddenCategories() {
2260 return $this->mPage
->getHiddenCategories();
2264 * Call to WikiPage function for backwards compatibility.
2265 * @see WikiPage::getId
2267 public function getId() {
2268 return $this->mPage
->getId();
2272 * Call to WikiPage function for backwards compatibility.
2273 * @see WikiPage::getLatest
2275 public function getLatest() {
2276 return $this->mPage
->getLatest();
2280 * Call to WikiPage function for backwards compatibility.
2281 * @see WikiPage::getLinksTimestamp
2283 public function getLinksTimestamp() {
2284 return $this->mPage
->getLinksTimestamp();
2288 * Call to WikiPage function for backwards compatibility.
2289 * @see WikiPage::getMinorEdit
2291 public function getMinorEdit() {
2292 return $this->mPage
->getMinorEdit();
2296 * Call to WikiPage function for backwards compatibility.
2297 * @see WikiPage::getOldestRevision
2299 public function getOldestRevision() {
2300 return $this->mPage
->getOldestRevision();
2304 * Call to WikiPage function for backwards compatibility.
2305 * @see WikiPage::getRedirectTarget
2307 public function getRedirectTarget() {
2308 return $this->mPage
->getRedirectTarget();
2312 * Call to WikiPage function for backwards compatibility.
2313 * @see WikiPage::getRedirectURL
2315 public function getRedirectURL( $rt ) {
2316 return $this->mPage
->getRedirectURL( $rt );
2320 * Call to WikiPage function for backwards compatibility.
2321 * @see WikiPage::getRevision
2323 public function getRevision() {
2324 return $this->mPage
->getRevision();
2328 * Call to WikiPage function for backwards compatibility.
2329 * @see WikiPage::getText
2331 public function getText( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2332 ContentHandler
::deprecated( __METHOD__
, '1.21' );
2333 return $this->mPage
->getText( $audience, $user );
2337 * Call to WikiPage function for backwards compatibility.
2338 * @see WikiPage::getTimestamp
2340 public function getTimestamp() {
2341 return $this->mPage
->getTimestamp();
2345 * Call to WikiPage function for backwards compatibility.
2346 * @see WikiPage::getTouched
2348 public function getTouched() {
2349 return $this->mPage
->getTouched();
2353 * Call to WikiPage function for backwards compatibility.
2354 * @see WikiPage::getUndoContent
2356 public function getUndoContent( Revision
$undo, Revision
$undoafter = null ) {
2357 return $this->mPage
->getUndoContent( $undo, $undoafter );
2361 * Call to WikiPage function for backwards compatibility.
2362 * @see WikiPage::getUser
2364 public function getUser( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2365 return $this->mPage
->getUser( $audience, $user );
2369 * Call to WikiPage function for backwards compatibility.
2370 * @see WikiPage::getUserText
2372 public function getUserText( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2373 return $this->mPage
->getUserText( $audience, $user );
2377 * Call to WikiPage function for backwards compatibility.
2378 * @see WikiPage::hasViewableContent
2380 public function hasViewableContent() {
2381 return $this->mPage
->hasViewableContent();
2385 * Call to WikiPage function for backwards compatibility.
2386 * @see WikiPage::insertOn
2388 public function insertOn( $dbw, $pageId = null ) {
2389 return $this->mPage
->insertOn( $dbw, $pageId );
2393 * Call to WikiPage function for backwards compatibility.
2394 * @see WikiPage::insertProtectNullRevision
2396 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2397 array $expiry, $cascade, $reason, $user = null
2399 return $this->mPage
->insertProtectNullRevision( $revCommentMsg, $limit,
2400 $expiry, $cascade, $reason, $user
2405 * Call to WikiPage function for backwards compatibility.
2406 * @see WikiPage::insertRedirect
2408 public function insertRedirect() {
2409 return $this->mPage
->insertRedirect();
2413 * Call to WikiPage function for backwards compatibility.
2414 * @see WikiPage::insertRedirectEntry
2416 public function insertRedirectEntry( Title
$rt, $oldLatest = null ) {
2417 return $this->mPage
->insertRedirectEntry( $rt, $oldLatest );
2421 * Call to WikiPage function for backwards compatibility.
2422 * @see WikiPage::isCountable
2424 public function isCountable( $editInfo = false ) {
2425 return $this->mPage
->isCountable( $editInfo );
2429 * Call to WikiPage function for backwards compatibility.
2430 * @see WikiPage::isRedirect
2432 public function isRedirect() {
2433 return $this->mPage
->isRedirect();
2437 * Call to WikiPage function for backwards compatibility.
2438 * @see WikiPage::loadFromRow
2440 public function loadFromRow( $data, $from ) {
2441 return $this->mPage
->loadFromRow( $data, $from );
2445 * Call to WikiPage function for backwards compatibility.
2446 * @see WikiPage::loadPageData
2448 public function loadPageData( $from = 'fromdb' ) {
2449 $this->mPage
->loadPageData( $from );
2453 * Call to WikiPage function for backwards compatibility.
2454 * @see WikiPage::lockAndGetLatest
2456 public function lockAndGetLatest() {
2457 return $this->mPage
->lockAndGetLatest();
2461 * Call to WikiPage function for backwards compatibility.
2462 * @see WikiPage::makeParserOptions
2464 public function makeParserOptions( $context ) {
2465 return $this->mPage
->makeParserOptions( $context );
2469 * Call to WikiPage function for backwards compatibility.
2470 * @see WikiPage::pageDataFromId
2472 public function pageDataFromId( $dbr, $id, $options = [] ) {
2473 return $this->mPage
->pageDataFromId( $dbr, $id, $options );
2477 * Call to WikiPage function for backwards compatibility.
2478 * @see WikiPage::pageDataFromTitle
2480 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2481 return $this->mPage
->pageDataFromTitle( $dbr, $title, $options );
2485 * Call to WikiPage function for backwards compatibility.
2486 * @see WikiPage::prepareContentForEdit
2488 public function prepareContentForEdit(
2489 Content
$content, $revision = null, User
$user = null,
2490 $serialFormat = null, $useCache = true
2492 return $this->mPage
->prepareContentForEdit(
2493 $content, $revision, $user,
2494 $serialFormat, $useCache
2499 * Call to WikiPage function for backwards compatibility.
2500 * @see WikiPage::prepareTextForEdit
2502 public function prepareTextForEdit( $text, $revid = null, User
$user = null ) {
2503 return $this->mPage
->prepareTextForEdit( $text, $revid, $user );
2507 * Call to WikiPage function for backwards compatibility.
2508 * @see WikiPage::protectDescription
2510 public function protectDescription( array $limit, array $expiry ) {
2511 return $this->mPage
->protectDescription( $limit, $expiry );
2515 * Call to WikiPage function for backwards compatibility.
2516 * @see WikiPage::protectDescriptionLog
2518 public function protectDescriptionLog( array $limit, array $expiry ) {
2519 return $this->mPage
->protectDescriptionLog( $limit, $expiry );
2523 * Call to WikiPage function for backwards compatibility.
2524 * @see WikiPage::replaceSectionAtRev
2526 public function replaceSectionAtRev( $sectionId, Content
$sectionContent,
2527 $sectionTitle = '', $baseRevId = null
2529 return $this->mPage
->replaceSectionAtRev( $sectionId, $sectionContent,
2530 $sectionTitle, $baseRevId
2535 * Call to WikiPage function for backwards compatibility.
2536 * @see WikiPage::replaceSectionContent
2538 public function replaceSectionContent(
2539 $sectionId, Content
$sectionContent, $sectionTitle = '', $edittime = null
2541 return $this->mPage
->replaceSectionContent(
2542 $sectionId, $sectionContent, $sectionTitle, $edittime
2547 * Call to WikiPage function for backwards compatibility.
2548 * @see WikiPage::setTimestamp
2550 public function setTimestamp( $ts ) {
2551 return $this->mPage
->setTimestamp( $ts );
2555 * Call to WikiPage function for backwards compatibility.
2556 * @see WikiPage::shouldCheckParserCache
2558 public function shouldCheckParserCache( ParserOptions
$parserOptions, $oldId ) {
2559 return $this->mPage
->shouldCheckParserCache( $parserOptions, $oldId );
2563 * Call to WikiPage function for backwards compatibility.
2564 * @see WikiPage::supportsSections
2566 public function supportsSections() {
2567 return $this->mPage
->supportsSections();
2571 * Call to WikiPage function for backwards compatibility.
2572 * @see WikiPage::triggerOpportunisticLinksUpdate
2574 public function triggerOpportunisticLinksUpdate( ParserOutput
$parserOutput ) {
2575 return $this->mPage
->triggerOpportunisticLinksUpdate( $parserOutput );
2579 * Call to WikiPage function for backwards compatibility.
2580 * @see WikiPage::updateCategoryCounts
2582 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2583 return $this->mPage
->updateCategoryCounts( $added, $deleted, $id );
2587 * Call to WikiPage function for backwards compatibility.
2588 * @see WikiPage::updateIfNewerOn
2590 public function updateIfNewerOn( $dbw, $revision ) {
2591 return $this->mPage
->updateIfNewerOn( $dbw, $revision );
2595 * Call to WikiPage function for backwards compatibility.
2596 * @see WikiPage::updateRedirectOn
2598 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2599 return $this->mPage
->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null );
2603 * Call to WikiPage function for backwards compatibility.
2604 * @see WikiPage::updateRevisionOn
2606 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2607 $lastRevIsRedirect = null
2609 return $this->mPage
->updateRevisionOn( $dbw, $revision, $lastRevision,
2615 * @param array $limit
2616 * @param array $expiry
2617 * @param bool $cascade
2618 * @param string $reason
2622 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2625 return $this->mPage
->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2629 * @param array $limit
2630 * @param string $reason
2631 * @param int $cascade
2632 * @param array $expiry
2635 public function updateRestrictions( $limit = [], $reason = '',
2636 &$cascade = 0, $expiry = []
2638 return $this->mPage
->doUpdateRestrictions(
2643 $this->getContext()->getUser()
2648 * @param string $reason
2649 * @param bool $suppress
2650 * @param int $u1 Unused
2651 * @param bool $u2 Unused
2652 * @param string $error
2655 public function doDeleteArticle(
2656 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2658 return $this->mPage
->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2662 * @param string $fromP
2663 * @param string $summary
2664 * @param string $token
2666 * @param array $resultDetails
2667 * @param User|null $user
2670 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User
$user = null ) {
2671 $user = is_null( $user ) ?
$this->getContext()->getUser() : $user;
2672 return $this->mPage
->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2676 * @param string $fromP
2677 * @param string $summary
2679 * @param array $resultDetails
2680 * @param User|null $guser
2683 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User
$guser = null ) {
2684 $guser = is_null( $guser ) ?
$this->getContext()->getUser() : $guser;
2685 return $this->mPage
->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2689 * @param bool $hasHistory
2692 public function generateReason( &$hasHistory ) {
2693 $title = $this->mPage
->getTitle();
2694 $handler = ContentHandler
::getForTitle( $title );
2695 return $handler->getAutoDeleteReason( $title, $hasHistory );
2701 * @deprecated since 1.24, use WikiPage::selectFields() instead
2703 public static function selectFields() {
2704 wfDeprecated( __METHOD__
, '1.24' );
2705 return WikiPage
::selectFields();
2709 * @param Title $title
2711 * @deprecated since 1.24, use WikiPage::onArticleCreate() instead
2713 public static function onArticleCreate( $title ) {
2714 wfDeprecated( __METHOD__
, '1.24' );
2715 WikiPage
::onArticleCreate( $title );
2719 * @param Title $title
2721 * @deprecated since 1.24, use WikiPage::onArticleDelete() instead
2723 public static function onArticleDelete( $title ) {
2724 wfDeprecated( __METHOD__
, '1.24' );
2725 WikiPage
::onArticleDelete( $title );
2729 * @param Title $title
2731 * @deprecated since 1.24, use WikiPage::onArticleEdit() instead
2733 public static function onArticleEdit( $title ) {
2734 wfDeprecated( __METHOD__
, '1.24' );
2735 WikiPage
::onArticleEdit( $title );
2739 * @param string $oldtext
2740 * @param string $newtext
2743 * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
2745 public static function getAutosummary( $oldtext, $newtext, $flags ) {
2746 return WikiPage
::getAutosummary( $oldtext, $newtext, $flags );