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
;
23 use MediaWiki\Storage\MutableRevisionRecord
;
24 use MediaWiki\Storage\RevisionRecord
;
27 * Class for viewing MediaWiki article and history.
29 * This maintains WikiPage functions for backwards compatibility.
31 * @todo Move and rewrite code to an Action class
33 * See design.txt for an overview.
34 * Note: edit user interface and cache support functions have been
35 * moved to separate EditPage and HTMLFileCache classes.
37 class Article
implements Page
{
39 * @var IContextSource|null The context this Article is executed in.
40 * If null, RequestContext::getMain() is used.
44 /** @var WikiPage|null The WikiPage object of this instance */
48 * @var ParserOptions|null ParserOptions object for $wgUser articles.
49 * Initialized by getParserOptions by calling $this->mPage->makeParserOptions().
51 public $mParserOptions;
54 * @var Content|null Content of the main slot of $this->mRevision.
55 * @note This variable is read only, setting it has no effect.
56 * Extensions that wish to override the output of Article::view should use a hook.
57 * @todo MCR: Remove in 1.33
58 * @deprecated since 1.32
61 public $mContentObject;
64 * @var bool Is the target revision loaded? Set by fetchRevisionRecord().
66 * @deprecated since 1.32. Whether content has been loaded should not be relevant to
67 * code outside this class.
69 public $mContentLoaded = false;
72 * @var int|null The oldid of the article that was requested to be shown,
73 * 0 for the current revision.
78 /** @var Title|null Title from which we were redirected here, if any. */
79 public $mRedirectedFrom = null;
81 /** @var string|bool URL to redirect to or false if none */
82 public $mRedirectUrl = false;
85 * @var int Revision ID of revision that was loaded.
87 * @deprecated since 1.32, use getRevIdFetched() instead.
89 public $mRevIdFetched = 0;
92 * @var Status|null represents the outcome of fetchRevisionRecord().
93 * $fetchResult->value is the RevisionRecord object, if the operation was successful.
95 * The information in $fetchResult is duplicated by the following deprecated public fields:
96 * $mRevIdFetched, $mContentLoaded. $mRevision (and $mContentObject) also typically duplicate
97 * information of the loaded revision, but may be overwritten by extensions or due to errors.
99 private $fetchResult = null;
102 * @var Revision|null Revision to be shown. Initialized by getOldIDFromRequest()
103 * or fetchContentObject(). Normally loaded from the database, but may be replaced
104 * by an extension, or be a fake representing an error message or some such.
105 * While the output of Article::view is typically based on this revision,
106 * it may be overwritten by error messages or replaced by extensions.
108 public $mRevision = null;
111 * @var ParserOutput|null|false The ParserOutput generated for viewing the page,
112 * initialized by view(). If no ParserOutput could be generated, this is set to false.
113 * @deprecated since 1.32
115 public $mParserOutput = null;
118 * @var bool Whether render() was called. With the way subclasses work
119 * here, there doesn't seem to be any other way to stop calling
120 * OutputPage::enableSectionEditLinks() and still have it work as it did before.
122 private $disableSectionEditForRender = false;
125 * Constructor and clear the article
126 * @param Title $title Reference to a Title object.
127 * @param int|null $oldId Revision ID, null to fetch from request, zero for current
129 public function __construct( Title
$title, $oldId = null ) {
130 $this->mOldId
= $oldId;
131 $this->mPage
= $this->newPage( $title );
135 * @param Title $title
138 protected function newPage( Title
$title ) {
139 return new WikiPage( $title );
143 * Constructor from a page id
144 * @param int $id Article ID to load
145 * @return Article|null
147 public static function newFromID( $id ) {
148 $t = Title
::newFromID( $id );
149 return $t == null ?
null : new static( $t );
153 * Create an Article object of the appropriate class for the given page.
155 * @param Title $title
156 * @param IContextSource $context
159 public static function newFromTitle( $title, IContextSource
$context ) {
160 if ( NS_MEDIA
== $title->getNamespace() ) {
161 // XXX: This should not be here, but where should it go?
162 $title = Title
::makeTitle( NS_FILE
, $title->getDBkey() );
166 Hooks
::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
168 switch ( $title->getNamespace() ) {
170 $page = new ImagePage( $title );
173 $page = new CategoryPage( $title );
176 $page = new Article( $title );
179 $page->setContext( $context );
185 * Create an Article object of the appropriate class for the given page.
187 * @param WikiPage $page
188 * @param IContextSource $context
191 public static function newFromWikiPage( WikiPage
$page, IContextSource
$context ) {
192 $article = self
::newFromTitle( $page->getTitle(), $context );
193 $article->mPage
= $page; // override to keep process cached vars
198 * Get the page this view was redirected from
202 public function getRedirectedFrom() {
203 return $this->mRedirectedFrom
;
207 * Tell the page view functions that this view was redirected
208 * from another page on the wiki.
211 public function setRedirectedFrom( Title
$from ) {
212 $this->mRedirectedFrom
= $from;
216 * Get the title object of the article
218 * @return Title Title object of this page
220 public function getTitle() {
221 return $this->mPage
->getTitle();
225 * Get the WikiPage object of this instance
230 public function getPage() {
237 public function clear() {
238 $this->mContentLoaded
= false;
240 $this->mRedirectedFrom
= null; # Title object if set
241 $this->mRevIdFetched
= 0;
242 $this->mRedirectUrl
= false;
243 $this->mRevision
= null;
244 $this->mContentObject
= null;
245 $this->fetchResult
= null;
247 // TODO hard-deprecate direct access to public fields
249 $this->mPage
->clear();
253 * Returns a Content object representing the pages effective display content,
254 * not necessarily the revision's content!
256 * Note that getContent does not follow redirects anymore.
257 * If you need to fetch redirectable content easily, try
258 * the shortcut in WikiPage::getRedirectTarget()
260 * This function has side effects! Do not use this function if you
261 * only want the real revision text if any.
263 * @deprecated since 1.32, use getRevisionFetched() or fetchRevisionRecord() instead.
269 protected function getContentObject() {
270 if ( $this->mPage
->getId() === 0 ) {
271 $content = $this->getSubstituteContent();
273 $this->fetchContentObject();
274 $content = $this->mContentObject
;
281 * Returns Content object to use when the page does not exist.
285 private function getSubstituteContent() {
286 # If this is a MediaWiki:x message, then load the messages
287 # and return the message value for x.
288 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI
) {
289 $text = $this->getTitle()->getDefaultMessageText();
290 if ( $text === false ) {
294 $content = ContentHandler
::makeContent( $text, $this->getTitle() );
296 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
297 $content = new MessageContent( $message, null, 'parsemag' );
304 * Returns ParserOutput to use when a page does not exist. In some cases, we still want to show
305 * "virtual" content, e.g. in the MediaWiki namespace, or in the File namespace for non-local
308 * @param ParserOptions $options
310 * @return ParserOutput
312 protected function getEmptyPageParserOutput( ParserOptions
$options ) {
313 $content = $this->getSubstituteContent();
315 return $content->getParserOutput( $this->getTitle(), 0, $options );
319 * @see getOldIDFromRequest()
320 * @see getRevIdFetched()
322 * @return int The oldid of the article that is was requested in the constructor or via the
323 * context's WebRequest.
325 public function getOldID() {
326 if ( is_null( $this->mOldId
) ) {
327 $this->mOldId
= $this->getOldIDFromRequest();
330 return $this->mOldId
;
334 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
336 * @return int The old id for the request
338 public function getOldIDFromRequest() {
339 $this->mRedirectUrl
= false;
341 $request = $this->getContext()->getRequest();
342 $oldid = $request->getIntOrNull( 'oldid' );
344 if ( $oldid === null ) {
348 if ( $oldid !== 0 ) {
349 # Load the given revision and check whether the page is another one.
350 # In that case, update this instance to reflect the change.
351 if ( $oldid === $this->mPage
->getLatest() ) {
352 $this->mRevision
= $this->mPage
->getRevision();
354 $this->mRevision
= Revision
::newFromId( $oldid );
355 if ( $this->mRevision
!== null ) {
356 // Revision title doesn't match the page title given?
357 if ( $this->mPage
->getId() != $this->mRevision
->getPage() ) {
358 $function = get_class( $this->mPage
) . '::newFromID';
359 $this->mPage
= $function( $this->mRevision
->getPage() );
365 if ( $request->getVal( 'direction' ) == 'next' ) {
366 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
369 $this->mRevision
= null;
371 $this->mRedirectUrl
= $this->getTitle()->getFullURL( 'redirect=no' );
373 } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
374 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
377 $this->mRevision
= null;
381 $this->mRevIdFetched
= $this->mRevision ?
$this->mRevision
->getId() : 0;
387 * Get text content object
388 * Does *NOT* follow redirects.
389 * @todo When is this null?
390 * @deprecated since 1.32, use fetchRevisionRecord() instead.
392 * @note Code that wants to retrieve page content from the database should
393 * use WikiPage::getContent().
395 * @return Content|null|bool
399 protected function fetchContentObject() {
400 if ( !$this->mContentLoaded
) {
401 $this->fetchRevisionRecord();
404 return $this->mContentObject
;
408 * Fetches the revision to work on.
409 * The revision is typically loaded from the database, but may also be a fake representing
410 * an error message or content supplied by an extension. Refer to $this->fetchResult for
411 * the revision actually loaded from the database, and any errors encountered while doing
414 * @return RevisionRecord|null
416 protected function fetchRevisionRecord() {
417 if ( $this->fetchResult
) {
418 return $this->mRevision ?
$this->mRevision
->getRevisionRecord() : null;
421 $this->mContentLoaded
= true;
422 $this->mContentObject
= null;
424 $oldid = $this->getOldID();
426 // $this->mRevision might already be fetched by getOldIDFromRequest()
427 if ( !$this->mRevision
) {
429 $this->mRevision
= $this->mPage
->getRevision();
431 if ( !$this->mRevision
) {
432 wfDebug( __METHOD__
. " failed to find page data for title " .
433 $this->getTitle()->getPrefixedText() . "\n" );
435 // Just for sanity, output for this case is done by showMissingArticle().
436 $this->fetchResult
= Status
::newFatal( 'noarticletext' );
437 $this->applyContentOverride( $this->makeFetchErrorContent() );
441 $this->mRevision
= Revision
::newFromId( $oldid );
443 if ( !$this->mRevision
) {
444 wfDebug( __METHOD__
. " failed to load revision, rev_id $oldid\n" );
446 $this->fetchResult
= Status
::newFatal( 'missing-revision', $oldid );
447 $this->applyContentOverride( $this->makeFetchErrorContent() );
453 $this->mRevIdFetched
= $this->mRevision
->getId();
454 $this->fetchResult
= Status
::newGood( $this->mRevision
);
456 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
, $this->getContext()->getUser() ) ) {
457 wfDebug( __METHOD__
. " failed to retrieve content of revision " .
458 $this->mRevision
->getId() . "\n" );
460 // Just for sanity, output for this case is done by showDeletedRevisionHeader().
461 $this->fetchResult
= Status
::newFatal( 'rev-deleted-text-permission' );
462 $this->applyContentOverride( $this->makeFetchErrorContent() );
466 if ( Hooks
::isRegistered( 'ArticleAfterFetchContentObject' ) ) {
467 $contentObject = $this->mRevision
->getContent(
468 Revision
::FOR_THIS_USER
,
469 $this->getContext()->getUser()
472 $hookContentObject = $contentObject;
474 // Avoid PHP 7.1 warning of passing $this by reference
475 $articlePage = $this;
478 'ArticleAfterFetchContentObject',
479 [ &$articlePage, &$hookContentObject ],
483 if ( $hookContentObject !== $contentObject ) {
484 // A hook handler is trying to override the content
485 $this->applyContentOverride( $hookContentObject );
490 $this->mContentObject
= $this->mRevision
->getContent(
491 Revision
::FOR_THIS_USER
,
492 $this->getContext()->getUser()
495 return $this->mRevision
->getRevisionRecord();
499 * Returns a Content object representing any error in $this->fetchContent, or null
500 * if there is no such error.
502 * @return Content|null
504 private function makeFetchErrorContent() {
505 if ( !$this->fetchResult ||
$this->fetchResult
->isOK() ) {
509 return new MessageContent( $this->fetchResult
->getMessage() );
513 * Applies a content override by constructing a fake Revision object and assigning
514 * it to mRevision. The fake revision will not have a user, timestamp or summary set.
516 * This mechanism exists mainly to accommodate extensions that use the
517 * ArticleAfterFetchContentObject. Once that hook has been removed, there should no longer
518 * be a need for a fake revision object. fetchRevisionRecord() presently also uses this mechanism
519 * to report errors, but that could be changed to use $this->fetchResult instead.
521 * @param Content $override Content to be used instead of the actual page content,
522 * coming from an extension or representing an error message.
524 private function applyContentOverride( Content
$override ) {
525 // Construct a fake revision
526 $rev = new MutableRevisionRecord( $this->getTitle() );
527 $rev->setContent( 'main', $override );
529 $this->mRevision
= new Revision( $rev );
532 $this->mContentObject
= $override;
536 * Returns true if the currently-referenced revision is the current edit
537 * to this page (and it exists).
540 public function isCurrent() {
541 # If no oldid, this is the current version.
542 if ( $this->getOldID() == 0 ) {
546 return $this->mPage
->exists() && $this->mRevision
&& $this->mRevision
->isCurrent();
550 * Get the fetched Revision object depending on request parameters or null
551 * on failure. The revision returned may be a fake representing an error message or
552 * wrapping content supplied by an extension. Refer to $this->fetchResult for the
553 * revision actually loaded from the database.
556 * @return Revision|null
558 public function getRevisionFetched() {
559 $this->fetchRevisionRecord();
561 if ( $this->fetchResult
->isOK() ) {
562 return $this->mRevision
;
567 * Use this to fetch the rev ID used on page views
569 * Before fetchRevisionRecord was called, this returns the page's latest revision,
570 * regardless of what getOldID() returns.
572 * @return int Revision ID of last article revision
574 public function getRevIdFetched() {
575 if ( $this->fetchResult
&& $this->fetchResult
->isOK() ) {
576 return $this->fetchResult
->value
->getId();
578 return $this->mPage
->getLatest();
583 * This is the default action of the index.php entry point: just view the
584 * page of the given title.
586 public function view() {
587 global $wgUseFileCache, $wgDebugToolbar;
589 # Get variables from query string
590 # As side effect this will load the revision and update the title
591 # in a revision ID is passed in the request, so this should remain
592 # the first call of this method even if $oldid is used way below.
593 $oldid = $this->getOldID();
595 $user = $this->getContext()->getUser();
596 # Another whitelist check in case getOldID() is altering the title
597 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
598 if ( count( $permErrors ) ) {
599 wfDebug( __METHOD__
. ": denied on secondary read check\n" );
600 throw new PermissionsError( 'read', $permErrors );
603 $outputPage = $this->getContext()->getOutput();
604 # getOldID() may as well want us to redirect somewhere else
605 if ( $this->mRedirectUrl
) {
606 $outputPage->redirect( $this->mRedirectUrl
);
607 wfDebug( __METHOD__
. ": redirecting due to oldid\n" );
612 # If we got diff in the query, we want to see a diff page instead of the article.
613 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
614 wfDebug( __METHOD__
. ": showing diff page\n" );
615 $this->showDiffPage();
620 # Set page title (may be overridden by DISPLAYTITLE)
621 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
623 $outputPage->setArticleFlag( true );
624 # Allow frames by default
625 $outputPage->allowClickjacking();
627 $parserCache = MediaWikiServices
::getInstance()->getParserCache();
629 $parserOptions = $this->getParserOptions();
631 # Render printable version, use printable version cache
632 if ( $outputPage->isPrintable() ) {
633 $parserOptions->setIsPrintable( true );
634 $poOptions['enableSectionEditLinks'] = false;
635 } elseif ( $this->disableSectionEditForRender
636 ||
!$this->isCurrent() ||
!$this->getTitle()->quickUserCan( 'edit', $user )
638 $poOptions['enableSectionEditLinks'] = false;
641 # Try client and file cache
642 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage
->checkTouched() ) {
643 # Try to stream the output from file cache
644 if ( $wgUseFileCache && $this->tryFileCache() ) {
645 wfDebug( __METHOD__
. ": done file cache\n" );
646 # tell wgOut that output is taken care of
647 $outputPage->disable();
648 $this->mPage
->doViewUpdates( $user, $oldid );
654 # Should the parser cache be used?
655 $useParserCache = $this->mPage
->shouldCheckParserCache( $parserOptions, $oldid );
656 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ?
'yes' : 'no' ) . "\n" );
657 if ( $user->getStubThreshold() ) {
658 MediaWikiServices
::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
661 $this->showRedirectedFromHeader();
662 $this->showNamespaceHeader();
664 # Iterate through the possible ways of constructing the output text.
665 # Keep going until $outputDone is set, or we run out of things to do.
668 $this->mParserOutput
= false;
670 while ( !$outputDone && ++
$pass ) {
673 // Avoid PHP 7.1 warning of passing $this by reference
674 $articlePage = $this;
675 Hooks
::run( 'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
678 # Early abort if the page doesn't exist
679 if ( !$this->mPage
->exists() ) {
680 wfDebug( __METHOD__
. ": showing missing article\n" );
681 $this->showMissingArticle();
682 $this->mPage
->doViewUpdates( $user );
686 # Try the parser cache
687 if ( $useParserCache ) {
688 $this->mParserOutput
= $parserCache->get( $this->mPage
, $parserOptions );
690 if ( $this->mParserOutput
!== false ) {
692 wfDebug( __METHOD__
. ": showing parser cache contents for current rev permalink\n" );
693 $this->setOldSubtitle( $oldid );
695 wfDebug( __METHOD__
. ": showing parser cache contents\n" );
697 $outputPage->addParserOutput( $this->mParserOutput
, $poOptions );
698 # Ensure that UI elements requiring revision ID have
699 # the correct version information.
700 $outputPage->setRevisionId( $this->mPage
->getLatest() );
701 # Preload timestamp to avoid a DB hit
702 $cachedTimestamp = $this->mParserOutput
->getTimestamp();
703 if ( $cachedTimestamp !== null ) {
704 $outputPage->setRevisionTimestamp( $cachedTimestamp );
705 $this->mPage
->setTimestamp( $cachedTimestamp );
712 # Are we looking at an old revision
713 $rev = $this->fetchRevisionRecord();
714 if ( $oldid && $this->fetchResult
->isOK() ) {
715 $this->setOldSubtitle( $oldid );
717 if ( !$this->showDeletedRevisionHeader() ) {
718 wfDebug( __METHOD__
. ": cannot view deleted revision\n" );
723 # Ensure that UI elements requiring revision ID have
724 # the correct version information.
725 $outputPage->setRevisionId( $this->getRevIdFetched() );
726 # Preload timestamp to avoid a DB hit
727 $outputPage->setRevisionTimestamp( $this->mPage
->getTimestamp() );
729 # Pages containing custom CSS or JavaScript get special treatment
730 if ( $this->getTitle()->isSiteConfigPage() ||
$this->getTitle()->isUserConfigPage() ) {
731 $dir = $this->getContext()->getLanguage()->getDir();
732 $lang = $this->getContext()->getLanguage()->getHtmlCode();
734 $outputPage->wrapWikiMsg(
735 "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
738 } elseif ( !Hooks
::run( 'ArticleRevisionViewCustom', [
745 // NOTE: sync with hooks called in DifferenceEngine::renderNewRevision()
746 // Allow extensions do their own custom view for certain pages
748 } elseif ( !Hooks
::run( 'ArticleContentViewCustom',
749 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ], '1.32' )
751 // NOTE: sync with hooks called in DifferenceEngine::renderNewRevision()
752 // Allow extensions do their own custom view for certain pages
757 # Run the parse, protected by a pool counter
758 wfDebug( __METHOD__
. ": doing uncached parse\n" );
760 $rev = $this->fetchRevisionRecord();
764 $poolArticleView = new PoolWorkArticleView(
767 $this->getRevIdFetched(),
771 $ok = $poolArticleView->execute();
772 $error = $poolArticleView->getError();
773 $this->mParserOutput
= $poolArticleView->getParserOutput() ?
: null;
775 # Don't cache a dirty ParserOutput object
776 if ( $poolArticleView->getIsDirty() ) {
777 $outputPage->setCdnMaxage( 0 );
778 $outputPage->addHTML( "<!-- parser cache is expired, " .
779 "sending anyway due to pool overload-->\n" );
787 $outputPage->clearHTML(); // for release() errors
788 $outputPage->enableClientCache( false );
789 $outputPage->setRobotPolicy( 'noindex,nofollow' );
791 $errortext = $error->getWikiText( false, 'view-pool-error' );
792 $outputPage->addWikiText( Html
::errorBox( $errortext ) );
794 # Connection or timeout error
798 if ( $this->mParserOutput
) {
799 $outputPage->addParserOutput( $this->mParserOutput
, $poOptions );
802 if ( $rev && $this->getRevisionRedirectTarget( $rev ) ) {
803 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
804 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
809 # Should be unreachable, but just in case...
815 // Get the ParserOutput actually *displayed* here.
816 // Note that $this->mParserOutput is the *current*/oldid version output.
817 // Note that the ArticleViewHeader hook is allowed to set $outputDone to a
818 // ParserOutput instance.
819 $pOutput = ( $outputDone instanceof ParserOutput
)
820 // phpcs:ignore MediaWiki.Usage.NestedInlineTernary.UnparenthesizedTernary -- FIXME T203805
821 ?
$outputDone // object fetched by hook
822 : $this->mParserOutput ?
: null; // ParserOutput or null, avoid false
824 # Adjust title for main page & pages with displaytitle
826 $this->adjustDisplayTitle( $pOutput );
829 # For the main page, overwrite the <title> element with the con-
830 # tents of 'pagetitle-view-mainpage' instead of the default (if
832 # This message always exists because it is in the i18n files
833 if ( $this->getTitle()->isMainPage() ) {
834 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
835 if ( !$msg->isDisabled() ) {
836 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
840 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
841 # This could use getTouched(), but that could be scary for major template edits.
842 $outputPage->adaptCdnTTL( $this->mPage
->getTimestamp(), IExpiringStore
::TTL_DAY
);
844 # Check for any __NOINDEX__ tags on the page using $pOutput
845 $policy = $this->getRobotPolicy( 'view', $pOutput ?
: null );
846 $outputPage->setIndexPolicy( $policy['index'] );
847 $outputPage->setFollowPolicy( $policy['follow'] ); // FIXME: test this
849 $this->showViewFooter();
850 $this->mPage
->doViewUpdates( $user, $oldid ); // FIXME: test this
852 # Load the postEdit module if the user just saved this revision
853 # See also EditPage::setPostEditCookie
854 $request = $this->getContext()->getRequest();
855 $cookieKey = EditPage
::POST_EDIT_COOKIE_KEY_PREFIX
. $this->getRevIdFetched();
856 $postEdit = $request->getCookie( $cookieKey );
858 # Clear the cookie. This also prevents caching of the response.
859 $request->response()->clearCookie( $cookieKey );
860 $outputPage->addJsConfigVars( 'wgPostEdit', $postEdit );
861 $outputPage->addModules( 'mediawiki.action.view.postEdit' ); // FIXME: test this
866 * @param RevisionRecord $revision
869 private function getRevisionRedirectTarget( RevisionRecord
$revision ) {
870 // TODO: find a *good* place for the code that determines the redirect target for
872 // NOTE: Use main slot content. Compare code in DerivedPageDataUpdater::revisionIsRedirect.
873 $content = $revision->getContent( 'main' );
874 return $content ?
$content->getRedirectTarget() : null;
878 * Adjust title for pages with displaytitle, -{T|}- or language conversion
879 * @param ParserOutput $pOutput
881 public function adjustDisplayTitle( ParserOutput
$pOutput ) {
882 $out = $this->getContext()->getOutput();
884 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
885 $titleText = $pOutput->getTitleText();
886 if ( strval( $titleText ) !== '' ) {
887 $out->setPageTitle( $titleText );
888 $out->setDisplayTitle( $titleText );
893 * Show a diff page according to current request variables. For use within
894 * Article::view() only, other callers should use the DifferenceEngine class.
896 protected function showDiffPage() {
897 $request = $this->getContext()->getRequest();
898 $user = $this->getContext()->getUser();
899 $diff = $request->getVal( 'diff' );
900 $rcid = $request->getVal( 'rcid' );
901 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
902 $purge = $request->getVal( 'action' ) == 'purge';
903 $unhide = $request->getInt( 'unhide' ) == 1;
904 $oldid = $this->getOldID();
906 $rev = $this->getRevisionFetched();
909 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
910 $msg = $this->getContext()->msg( 'difference-missing-revision' )
914 $this->getContext()->getOutput()->addHTML( $msg );
918 $contentHandler = $rev->getContentHandler();
919 $de = $contentHandler->createDifferenceEngine(
928 // DifferenceEngine directly fetched the revision:
929 $this->mRevIdFetched
= $de->getNewid();
930 $de->showDiffPage( $diffOnly );
932 // Run view updates for the newer revision being diffed (and shown
933 // below the diff if not $diffOnly).
934 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
935 // New can be false, convert it to 0 - this conveniently means the latest revision
936 $this->mPage
->doViewUpdates( $user, (int)$new );
940 * Get the robot policy to be used for the current view
941 * @param string $action The action= GET parameter
942 * @param ParserOutput|null $pOutput
943 * @return array The policy that should be set
944 * @todo actions other than 'view'
946 public function getRobotPolicy( $action, ParserOutput
$pOutput = null ) {
947 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
949 $ns = $this->getTitle()->getNamespace();
951 # Don't index user and user talk pages for blocked users (T13443)
952 if ( ( $ns == NS_USER ||
$ns == NS_USER_TALK
) && !$this->getTitle()->isSubpage() ) {
953 $specificTarget = null;
955 $titleText = $this->getTitle()->getText();
956 if ( IP
::isValid( $titleText ) ) {
957 $vagueTarget = $titleText;
959 $specificTarget = $titleText;
961 if ( Block
::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block
) {
963 'index' => 'noindex',
964 'follow' => 'nofollow'
969 if ( $this->mPage
->getId() === 0 ||
$this->getOldID() ) {
970 # Non-articles (special pages etc), and old revisions
972 'index' => 'noindex',
973 'follow' => 'nofollow'
975 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
976 # Discourage indexing of printable versions, but encourage following
978 'index' => 'noindex',
981 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
982 # For ?curid=x urls, disallow indexing
984 'index' => 'noindex',
989 # Otherwise, construct the policy based on the various config variables.
990 $policy = self
::formatRobotPolicy( $wgDefaultRobotPolicy );
992 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
993 # Honour customised robot policies for this namespace
994 $policy = array_merge(
996 self
::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
999 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
1000 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
1001 # a final sanity check that we have really got the parser output.
1002 $policy = array_merge(
1004 [ 'index' => $pOutput->getIndexPolicy() ]
1008 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
1009 # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
1010 $policy = array_merge(
1012 self
::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
1020 * Converts a String robot policy into an associative array, to allow
1021 * merging of several policies using array_merge().
1022 * @param array|string $policy Returns empty array on null/false/'', transparent
1023 * to already-converted arrays, converts string.
1024 * @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
1026 public static function formatRobotPolicy( $policy ) {
1027 if ( is_array( $policy ) ) {
1029 } elseif ( !$policy ) {
1033 $policy = explode( ',', $policy );
1034 $policy = array_map( 'trim', $policy );
1037 foreach ( $policy as $var ) {
1038 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
1039 $arr['index'] = $var;
1040 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
1041 $arr['follow'] = $var;
1049 * If this request is a redirect view, send "redirected from" subtitle to
1050 * the output. Returns true if the header was needed, false if this is not
1051 * a redirect view. Handles both local and remote redirects.
1055 public function showRedirectedFromHeader() {
1056 global $wgRedirectSources;
1058 $context = $this->getContext();
1059 $outputPage = $context->getOutput();
1060 $request = $context->getRequest();
1061 $rdfrom = $request->getVal( 'rdfrom' );
1063 // Construct a URL for the current page view, but with the target title
1064 $query = $request->getValues();
1065 unset( $query['rdfrom'] );
1066 unset( $query['title'] );
1067 if ( $this->getTitle()->isRedirect() ) {
1068 // Prevent double redirects
1069 $query['redirect'] = 'no';
1071 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
1073 if ( isset( $this->mRedirectedFrom
) ) {
1074 // Avoid PHP 7.1 warning of passing $this by reference
1075 $articlePage = $this;
1077 // This is an internally redirected page view.
1078 // We'll need a backlink to the source page for navigation.
1079 if ( Hooks
::run( 'ArticleViewRedirect', [ &$articlePage ] ) ) {
1080 $redir = Linker
::linkKnown(
1081 $this->mRedirectedFrom
,
1084 [ 'redirect' => 'no' ]
1087 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
1088 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
1091 // Add the script to update the displayed URL and
1092 // set the fragment if one was specified in the redirect
1093 $outputPage->addJsConfigVars( [
1094 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
1096 $outputPage->addModules( 'mediawiki.action.view.redirect' );
1098 // Add a <link rel="canonical"> tag
1099 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
1101 // Tell the output object that the user arrived at this article through a redirect
1102 $outputPage->setRedirectedFrom( $this->mRedirectedFrom
);
1106 } elseif ( $rdfrom ) {
1107 // This is an externally redirected view, from some other wiki.
1108 // If it was reported from a trusted site, supply a backlink.
1109 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
1110 $redir = Linker
::makeExternalLink( $rdfrom, $rdfrom );
1111 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
1112 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
1115 // Add the script to update the displayed URL
1116 $outputPage->addJsConfigVars( [
1117 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
1119 $outputPage->addModules( 'mediawiki.action.view.redirect' );
1129 * Show a header specific to the namespace currently being viewed, like
1130 * [[MediaWiki:Talkpagetext]]. For Article::view().
1132 public function showNamespaceHeader() {
1133 if ( $this->getTitle()->isTalkPage() ) {
1134 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
1135 $this->getContext()->getOutput()->wrapWikiMsg(
1136 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
1137 [ 'talkpageheader' ]
1144 * Show the footer section of an ordinary page view
1146 public function showViewFooter() {
1147 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
1148 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
1149 && IP
::isValid( $this->getTitle()->getText() )
1151 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
1154 // Show a footer allowing the user to patrol the shown revision or page if possible
1155 $patrolFooterShown = $this->showPatrolFooter();
1157 Hooks
::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
1161 * If patrol is possible, output a patrol UI box. This is called from the
1162 * footer section of ordinary page views. If patrol is not possible or not
1163 * desired, does nothing.
1164 * Side effect: When the patrol link is build, this method will call
1165 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
1169 public function showPatrolFooter() {
1170 global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol;
1172 // Allow hooks to decide whether to not output this at all
1173 if ( !Hooks
::run( 'ArticleShowPatrolFooter', [ $this ] ) ) {
1177 $outputPage = $this->getContext()->getOutput();
1178 $user = $this->getContext()->getUser();
1179 $title = $this->getTitle();
1182 if ( !$title->quickUserCan( 'patrol', $user )
1183 ||
!( $wgUseRCPatrol ||
$wgUseNPPatrol
1184 ||
( $wgUseFilePatrol && $title->inNamespace( NS_FILE
) ) )
1186 // Patrolling is disabled or the user isn't allowed to
1190 if ( $this->mRevision
1191 && !RecentChange
::isInRCLifespan( $this->mRevision
->getTimestamp(), 21600 )
1193 // The current revision is already older than what could be in the RC table
1194 // 6h tolerance because the RC might not be cleaned out regularly
1198 // Check for cached results
1199 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
1200 $key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() );
1201 if ( $cache->get( $key ) ) {
1205 $dbr = wfGetDB( DB_REPLICA
);
1206 $oldestRevisionTimestamp = $dbr->selectField(
1208 'MIN( rev_timestamp )',
1209 [ 'rev_page' => $title->getArticleID() ],
1213 // New page patrol: Get the timestamp of the oldest revison which
1214 // the revision table holds for the given page. Then we look
1215 // whether it's within the RC lifespan and if it is, we try
1216 // to get the recentchanges row belonging to that entry
1217 // (with rc_new = 1).
1218 $recentPageCreation = false;
1219 if ( $oldestRevisionTimestamp
1220 && RecentChange
::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
1222 // 6h tolerance because the RC might not be cleaned out regularly
1223 $recentPageCreation = true;
1224 $rc = RecentChange
::newFromConds(
1227 'rc_timestamp' => $oldestRevisionTimestamp,
1228 'rc_namespace' => $title->getNamespace(),
1229 'rc_cur_id' => $title->getArticleID()
1234 // Use generic patrol message for new pages
1235 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1239 // File patrol: Get the timestamp of the latest upload for this page,
1240 // check whether it is within the RC lifespan and if it is, we try
1241 // to get the recentchanges row belonging to that entry
1242 // (with rc_type = RC_LOG, rc_log_type = upload).
1243 $recentFileUpload = false;
1244 if ( ( !$rc ||
$rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1245 && $title->getNamespace() === NS_FILE
) {
1246 // Retrieve timestamp of most recent upload
1247 $newestUploadTimestamp = $dbr->selectField(
1249 'MAX( img_timestamp )',
1250 [ 'img_name' => $title->getDBkey() ],
1253 if ( $newestUploadTimestamp
1254 && RecentChange
::isInRCLifespan( $newestUploadTimestamp, 21600 )
1256 // 6h tolerance because the RC might not be cleaned out regularly
1257 $recentFileUpload = true;
1258 $rc = RecentChange
::newFromConds(
1260 'rc_type' => RC_LOG
,
1261 'rc_log_type' => 'upload',
1262 'rc_timestamp' => $newestUploadTimestamp,
1263 'rc_namespace' => NS_FILE
,
1264 'rc_cur_id' => $title->getArticleID()
1269 // Use patrol message specific to files
1270 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1275 if ( !$recentPageCreation && !$recentFileUpload ) {
1276 // Page creation and latest upload (for files) is too old to be in RC
1278 // We definitely can't patrol so cache the information
1279 // When a new file version is uploaded, the cache is cleared
1280 $cache->set( $key, '1' );
1286 // Don't cache: This can be hit if the page gets accessed very fast after
1287 // its creation / latest upload or in case we have high replica DB lag. In case
1288 // the revision is too old, we will already return above.
1292 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1293 // Patrolled RC entry around
1295 // Cache the information we gathered above in case we can't patrol
1296 // Don't cache in case we can patrol as this could change
1297 $cache->set( $key, '1' );
1302 if ( $rc->getPerformer()->equals( $user ) ) {
1303 // Don't show a patrol link for own creations/uploads. If the user could
1304 // patrol them, they already would be patrolled
1308 $outputPage->preventClickjacking();
1309 if ( $user->isAllowed( 'writeapi' ) ) {
1310 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1313 $link = Linker
::linkKnown(
1315 $markPatrolledMsg->escaped(),
1318 'action' => 'markpatrolled',
1319 'rcid' => $rc->getAttribute( 'rc_id' ),
1323 $outputPage->addHTML(
1324 "<div class='patrollink' data-mw='interface'>" .
1325 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1333 * Purge the cache used to check if it is worth showing the patrol footer
1334 * For example, it is done during re-uploads when file patrol is used.
1335 * @param int $articleID ID of the article to purge
1338 public static function purgePatrolFooterCache( $articleID ) {
1339 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
1340 $cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) );
1344 * Show the error text for a missing article. For articles in the MediaWiki
1345 * namespace, show the default message text. To be called from Article::view().
1347 public function showMissingArticle() {
1348 global $wgSend404Code;
1350 $outputPage = $this->getContext()->getOutput();
1351 // Whether the page is a root user page of an existing user (but not a subpage)
1352 $validUserPage = false;
1354 $title = $this->getTitle();
1356 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1357 if ( $title->getNamespace() == NS_USER
1358 ||
$title->getNamespace() == NS_USER_TALK
1360 $rootPart = explode( '/', $title->getText() )[0];
1361 $user = User
::newFromName( $rootPart, false /* allow IP users */ );
1362 $ip = User
::isIP( $rootPart );
1363 $block = Block
::newFromTarget( $user, $user );
1365 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1366 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1367 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1368 } elseif ( !is_null( $block ) && $block->getType() != Block
::TYPE_AUTO
) {
1369 # Show log extract if the user is currently blocked
1370 LogEventsList
::showLogExtract(
1373 MWNamespace
::getCanonicalName( NS_USER
) . ':' . $block->getTarget(),
1377 'showIfEmpty' => false,
1379 'blocked-notice-logextract',
1380 $user->getName() # Support GENDER in notice
1384 $validUserPage = !$title->isSubpage();
1386 $validUserPage = !$title->isSubpage();
1390 Hooks
::run( 'ShowMissingArticle', [ $this ] );
1392 # Show delete and move logs if there were any such events.
1393 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1394 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1395 $cache = MediaWikiServices
::getInstance()->getMainObjectStash();
1396 $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1397 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1398 $sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
1399 if ( $loggedIn ||
$cache->get( $key ) ||
$sessionExists ) {
1400 $logTypes = [ 'delete', 'move', 'protect' ];
1402 $dbr = wfGetDB( DB_REPLICA
);
1404 $conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
1405 // Give extensions a chance to hide their (unrelated) log entries
1406 Hooks
::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1407 LogEventsList
::showLogExtract(
1415 'showIfEmpty' => false,
1416 'msgKey' => [ $loggedIn ||
$sessionExists
1417 ?
'moveddeleted-notice'
1418 : 'moveddeleted-notice-recent'
1424 if ( !$this->mPage
->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1425 // If there's no backing content, send a 404 Not Found
1426 // for better machine handling of broken links.
1427 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1430 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1431 $policy = $this->getRobotPolicy( 'view' );
1432 $outputPage->setIndexPolicy( $policy['index'] );
1433 $outputPage->setFollowPolicy( $policy['follow'] );
1435 $hookResult = Hooks
::run( 'BeforeDisplayNoArticleText', [ $this ] );
1437 if ( !$hookResult ) {
1441 # Show error message
1442 $oldid = $this->getOldID();
1443 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI
&& $title->hasSourceText() ) {
1444 // use fake Content object for system message
1445 $parserOptions = ParserOptions
::newCanonical( 'canonical' );
1446 $outputPage->addParserOutput( $this->getEmptyPageParserOutput( $parserOptions ) );
1449 $text = wfMessage( 'missing-revision', $oldid )->plain();
1450 } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1451 && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1453 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
1454 $text = wfMessage( $message )->plain();
1456 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1459 $dir = $this->getContext()->getLanguage()->getDir();
1460 $lang = $this->getContext()->getLanguage()->getHtmlCode();
1461 $outputPage->addWikiText( Xml
::openElement( 'div', [
1462 'class' => "noarticletext mw-content-$dir",
1465 ] ) . "\n$text\n</div>" );
1470 * If the revision requested for view is deleted, check permissions.
1471 * Send either an error message or a warning header to the output.
1473 * @return bool True if the view is allowed, false if not.
1475 public function showDeletedRevisionHeader() {
1476 if ( !$this->mRevision
->isDeleted( Revision
::DELETED_TEXT
) ) {
1481 $outputPage = $this->getContext()->getOutput();
1482 $user = $this->getContext()->getUser();
1483 // If the user is not allowed to see it...
1484 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
, $user ) ) {
1485 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1486 'rev-deleted-text-permission' );
1489 // If the user needs to confirm that they want to see it...
1490 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1491 # Give explanation and add a link to view the revision...
1492 $oldid = intval( $this->getOldID() );
1493 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1494 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1495 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1496 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1500 // We are allowed to see...
1502 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1503 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1504 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1511 * Generate the navigation links when browsing through an article revisions
1512 * It shows the information as:
1513 * Revision as of \<date\>; view current revision
1514 * \<- Previous version | Next Version -\>
1516 * @param int $oldid Revision ID of this article revision
1518 public function setOldSubtitle( $oldid = 0 ) {
1519 // Avoid PHP 7.1 warning of passing $this by reference
1520 $articlePage = $this;
1522 if ( !Hooks
::run( 'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1526 $context = $this->getContext();
1527 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1529 # Cascade unhide param in links for easy deletion browsing
1532 $extraParams['unhide'] = 1;
1535 if ( $this->mRevision
&& $this->mRevision
->getId() === $oldid ) {
1536 $revision = $this->mRevision
;
1538 $revision = Revision
::newFromId( $oldid );
1541 $timestamp = $revision->getTimestamp();
1543 $current = ( $oldid == $this->mPage
->getLatest() );
1544 $language = $context->getLanguage();
1545 $user = $context->getUser();
1547 $td = $language->userTimeAndDate( $timestamp, $user );
1548 $tddate = $language->userDate( $timestamp, $user );
1549 $tdtime = $language->userTime( $timestamp, $user );
1551 # Show user links if allowed to see them. If hidden, then show them only if requested...
1552 $userlinks = Linker
::revUserTools( $revision, !$unhide );
1554 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1555 ?
'revision-info-current'
1558 $outputPage = $context->getOutput();
1559 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1560 $context->msg( $infomsg, $td )
1561 ->rawParams( $userlinks )
1562 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1563 ->rawParams( Linker
::revComment( $revision, true, true ) )
1568 ?
$context->msg( 'currentrevisionlink' )->escaped()
1569 : Linker
::linkKnown(
1571 $context->msg( 'currentrevisionlink' )->escaped(),
1576 ?
$context->msg( 'diff' )->escaped()
1577 : Linker
::linkKnown(
1579 $context->msg( 'diff' )->escaped(),
1586 $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1588 ? Linker
::linkKnown(
1590 $context->msg( 'previousrevision' )->escaped(),
1593 'direction' => 'prev',
1597 : $context->msg( 'previousrevision' )->escaped();
1599 ? Linker
::linkKnown(
1601 $context->msg( 'diff' )->escaped(),
1608 : $context->msg( 'diff' )->escaped();
1609 $nextlink = $current
1610 ?
$context->msg( 'nextrevision' )->escaped()
1611 : Linker
::linkKnown(
1613 $context->msg( 'nextrevision' )->escaped(),
1616 'direction' => 'next',
1620 $nextdiff = $current
1621 ?
$context->msg( 'diff' )->escaped()
1622 : Linker
::linkKnown(
1624 $context->msg( 'diff' )->escaped(),
1632 $cdel = Linker
::getRevDeleteLink( $user, $revision, $this->getTitle() );
1633 if ( $cdel !== '' ) {
1637 // the outer div is need for styling the revision info and nav in MobileFrontend
1638 $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1639 "<div id=\"mw-revision-nav\">" . $cdel .
1640 $context->msg( 'revision-nav' )->rawParams(
1641 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1642 )->escaped() . "</div></div>" );
1646 * Return the HTML for the top of a redirect page
1648 * Chances are you should just be using the ParserOutput from
1649 * WikitextContent::getParserOutput instead of calling this for redirects.
1651 * @param Title|array $target Destination(s) to redirect
1652 * @param bool $appendSubtitle [optional]
1653 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1654 * @return string Containing HTML with redirect link
1656 * @deprecated since 1.30
1658 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1659 $lang = $this->getTitle()->getPageLanguage();
1660 $out = $this->getContext()->getOutput();
1661 if ( $appendSubtitle ) {
1662 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1664 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1665 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1669 * Return the HTML for the top of a redirect page
1671 * Chances are you should just be using the ParserOutput from
1672 * WikitextContent::getParserOutput instead of calling this for redirects.
1675 * @param Language $lang
1676 * @param Title|array $target Destination(s) to redirect
1677 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1678 * @return string Containing HTML with redirect link
1680 public static function getRedirectHeaderHtml( Language
$lang, $target, $forceKnown = false ) {
1681 if ( !is_array( $target ) ) {
1682 $target = [ $target ];
1685 $html = '<ul class="redirectText">';
1686 /** @var Title $title */
1687 foreach ( $target as $title ) {
1688 $html .= '<li>' . Linker
::link(
1690 htmlspecialchars( $title->getFullText() ),
1692 // Make sure wiki page redirects are not followed
1693 $title->isRedirect() ?
[ 'redirect' => 'no' ] : [],
1694 ( $forceKnown ?
[ 'known', 'noclasses' ] : [] )
1699 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1701 return '<div class="redirectMsg">' .
1702 '<p>' . $redirectToText . '</p>' .
1708 * Adds help link with an icon via page indicators.
1709 * Link target can be overridden by a local message containing a wikilink:
1710 * the message key is: 'namespace-' + namespace number + '-helppage'.
1711 * @param string $to Target MediaWiki.org page title or encoded URL.
1712 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
1715 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1717 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1720 $out = $this->getContext()->getOutput();
1721 if ( !$msg->isDisabled() ) {
1722 $helpUrl = Skin
::makeUrl( $msg->plain() );
1723 $out->addHelpLink( $helpUrl, true );
1725 $out->addHelpLink( $to, $overrideBaseUrl );
1730 * Handle action=render
1732 public function render() {
1733 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1734 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1735 $this->disableSectionEditForRender
= true;
1740 * action=protect handler
1742 public function protect() {
1743 $form = new ProtectionForm( $this );
1748 * action=unprotect handler (alias)
1750 public function unprotect() {
1755 * UI entry point for page deletion
1757 public function delete() {
1758 # This code desperately needs to be totally rewritten
1760 $title = $this->getTitle();
1761 $context = $this->getContext();
1762 $user = $context->getUser();
1763 $request = $context->getRequest();
1766 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1767 if ( count( $permissionErrors ) ) {
1768 throw new PermissionsError( 'delete', $permissionErrors );
1771 # Read-only check...
1772 if ( wfReadOnly() ) {
1773 throw new ReadOnlyError
;
1776 # Better double-check that it hasn't been deleted yet!
1777 $this->mPage
->loadPageData(
1778 $request->wasPosted() ? WikiPage
::READ_LATEST
: WikiPage
::READ_NORMAL
1780 if ( !$this->mPage
->exists() ) {
1781 $deleteLogPage = new LogPage( 'delete' );
1782 $outputPage = $context->getOutput();
1783 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1784 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1785 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1787 $outputPage->addHTML(
1788 Xml
::element( 'h2', null, $deleteLogPage->getName()->text() )
1790 LogEventsList
::showLogExtract(
1799 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1800 $deleteReason = $request->getText( 'wpReason' );
1802 if ( $deleteReasonList == 'other' ) {
1803 $reason = $deleteReason;
1804 } elseif ( $deleteReason != '' ) {
1805 // Entry from drop down menu + additional comment
1806 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1807 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1809 $reason = $deleteReasonList;
1812 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1813 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1815 # Flag to hide all contents of the archived revisions
1816 $suppress = $request->getCheck( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1818 $this->doDelete( $reason, $suppress );
1820 WatchAction
::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1825 // Generate deletion reason
1826 $hasHistory = false;
1829 $reason = $this->generateReason( $hasHistory );
1830 } catch ( Exception
$e ) {
1831 # if a page is horribly broken, we still want to be able to
1832 # delete it. So be lenient about errors here.
1833 wfDebug( "Error while building auto delete summary: $e" );
1838 // If the page has a history, insert a warning
1839 if ( $hasHistory ) {
1840 $title = $this->getTitle();
1842 // The following can use the real revision count as this is only being shown for users
1843 // that can delete this page.
1844 // This, as a side-effect, also makes sure that the following query isn't being run for
1845 // pages with a larger history, unless the user has the 'bigdelete' right
1846 // (and is about to delete this page).
1847 $dbr = wfGetDB( DB_REPLICA
);
1848 $revisions = $edits = (int)$dbr->selectField(
1851 [ 'rev_page' => $title->getArticleID() ],
1855 // @todo i18n issue/patchwork message
1856 $context->getOutput()->addHTML(
1857 '<strong class="mw-delete-warning-revisions">' .
1858 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1859 $context->msg( 'word-separator' )->escaped() . Linker
::linkKnown( $title,
1860 $context->msg( 'history' )->escaped(),
1862 [ 'action' => 'history' ] ) .
1866 if ( $title->isBigDeletion() ) {
1867 global $wgDeleteRevisionsLimit;
1868 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1870 'delete-warning-toobig',
1871 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1877 $this->confirmDelete( $reason );
1881 * Output deletion confirmation dialog
1882 * @todo Move to another file?
1883 * @param string $reason Prefilled reason
1885 public function confirmDelete( $reason ) {
1886 wfDebug( "Article::confirmDelete\n" );
1888 $title = $this->getTitle();
1889 $ctx = $this->getContext();
1890 $outputPage = $ctx->getOutput();
1891 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1892 $outputPage->addBacklinkSubtitle( $title );
1893 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1894 $outputPage->addModules( 'mediawiki.action.delete' );
1896 $backlinkCache = $title->getBacklinkCache();
1897 if ( $backlinkCache->hasLinks( 'pagelinks' ) ||
$backlinkCache->hasLinks( 'templatelinks' ) ) {
1898 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1899 'deleting-backlinks-warning' );
1902 $subpageQueryLimit = 51;
1903 $subpages = $title->getSubpages( $subpageQueryLimit );
1904 $subpageCount = count( $subpages );
1905 if ( $subpageCount > 0 ) {
1906 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1907 [ 'deleting-subpages-warning', Message
::numParam( $subpageCount ) ] );
1909 $outputPage->addWikiMsg( 'confirmdeletetext' );
1911 Hooks
::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1913 $user = $this->getContext()->getUser();
1914 $checkWatch = $user->getBoolOption( 'watchdeletion' ) ||
$user->isWatched( $title );
1916 $outputPage->enableOOUI();
1918 $options = Xml
::listDropDownOptions(
1919 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->text(),
1920 [ 'other' => $ctx->msg( 'deletereasonotherlist' )->inContentLanguage()->text() ]
1922 $options = Xml
::listDropDownOptionsOoui( $options );
1924 $fields[] = new OOUI\
FieldLayout(
1925 new OOUI\
DropdownInputWidget( [
1926 'name' => 'wpDeleteReasonList',
1927 'inputId' => 'wpDeleteReasonList',
1929 'infusable' => true,
1931 'options' => $options
1934 'label' => $ctx->msg( 'deletecomment' )->text(),
1939 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
1940 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
1941 // Unicode codepoints (or 255 UTF-8 bytes for old schema).
1942 $conf = $this->getContext()->getConfig();
1943 $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD
;
1944 $fields[] = new OOUI\
FieldLayout(
1945 new OOUI\
TextInputWidget( [
1946 'name' => 'wpReason',
1947 'inputId' => 'wpReason',
1949 'maxLength' => $oldCommentSchema ?
255 : CommentStore
::COMMENT_CHARACTER_LIMIT
,
1950 'infusable' => true,
1952 'autofocus' => true,
1955 'label' => $ctx->msg( 'deleteotherreason' )->text(),
1960 if ( $user->isLoggedIn() ) {
1961 $fields[] = new OOUI\
FieldLayout(
1962 new OOUI\
CheckboxInputWidget( [
1963 'name' => 'wpWatch',
1964 'inputId' => 'wpWatch',
1966 'selected' => $checkWatch,
1969 'label' => $ctx->msg( 'watchthis' )->text(),
1970 'align' => 'inline',
1971 'infusable' => true,
1976 if ( $user->isAllowed( 'suppressrevision' ) ) {
1977 $fields[] = new OOUI\
FieldLayout(
1978 new OOUI\
CheckboxInputWidget( [
1979 'name' => 'wpSuppress',
1980 'inputId' => 'wpSuppress',
1984 'label' => $ctx->msg( 'revdelete-suppress' )->text(),
1985 'align' => 'inline',
1986 'infusable' => true,
1991 $fields[] = new OOUI\
FieldLayout(
1992 new OOUI\
ButtonInputWidget( [
1993 'name' => 'wpConfirmB',
1994 'inputId' => 'wpConfirmB',
1996 'value' => $ctx->msg( 'deletepage' )->text(),
1997 'label' => $ctx->msg( 'deletepage' )->text(),
1998 'flags' => [ 'primary', 'destructive' ],
2006 $fieldset = new OOUI\
FieldsetLayout( [
2007 'label' => $ctx->msg( 'delete-legend' )->text(),
2008 'id' => 'mw-delete-table',
2012 $form = new OOUI\
FormLayout( [
2014 'action' => $title->getLocalURL( 'action=delete' ),
2015 'id' => 'deleteconfirm',
2017 $form->appendContent(
2019 new OOUI\
HtmlSnippet(
2020 Html
::hidden( 'wpEditToken', $user->getEditToken( [ 'delete', $title->getPrefixedText() ] ) )
2024 $outputPage->addHTML(
2025 new OOUI\
PanelLayout( [
2026 'classes' => [ 'deletepage-wrapper' ],
2027 'expanded' => false,
2034 if ( $user->isAllowed( 'editinterface' ) ) {
2035 $link = Linker
::linkKnown(
2036 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
2037 wfMessage( 'delete-edit-reasonlist' )->escaped(),
2039 [ 'action' => 'edit' ]
2041 $outputPage->addHTML( '<p class="mw-delete-editreasons">' . $link . '</p>' );
2044 $deleteLogPage = new LogPage( 'delete' );
2045 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
2046 LogEventsList
::showLogExtract( $outputPage, 'delete', $title );
2050 * Perform a deletion and output success or failure messages
2051 * @param string $reason
2052 * @param bool $suppress
2054 public function doDelete( $reason, $suppress = false ) {
2056 $context = $this->getContext();
2057 $outputPage = $context->getOutput();
2058 $user = $context->getUser();
2059 $status = $this->mPage
->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
2061 if ( $status->isGood() ) {
2062 $deleted = $this->getTitle()->getPrefixedText();
2064 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
2065 $outputPage->setRobotPolicy( 'noindex,nofollow' );
2067 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
2069 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
2071 Hooks
::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
2073 $outputPage->returnToMain( false );
2075 $outputPage->setPageTitle(
2076 wfMessage( 'cannotdelete-title',
2077 $this->getTitle()->getPrefixedText() )
2080 if ( $error == '' ) {
2081 $outputPage->addWikiText(
2082 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
2084 $deleteLogPage = new LogPage( 'delete' );
2085 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
2087 LogEventsList
::showLogExtract(
2093 $outputPage->addHTML( $error );
2098 /* Caching functions */
2101 * checkLastModified returns true if it has taken care of all
2102 * output to the client that is necessary for this request.
2103 * (that is, it has sent a cached version of the page)
2105 * @return bool True if cached version send, false otherwise
2107 protected function tryFileCache() {
2108 static $called = false;
2111 wfDebug( "Article::tryFileCache(): called twice!?\n" );
2116 if ( $this->isFileCacheable() ) {
2117 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
2118 if ( $cache->isCacheGood( $this->mPage
->getTouched() ) ) {
2119 wfDebug( "Article::tryFileCache(): about to load file\n" );
2120 $cache->loadFromFileCache( $this->getContext() );
2123 wfDebug( "Article::tryFileCache(): starting buffer\n" );
2124 ob_start( [ &$cache, 'saveToFileCache' ] );
2127 wfDebug( "Article::tryFileCache(): not cacheable\n" );
2134 * Check if the page can be cached
2135 * @param int $mode One of the HTMLFileCache::MODE_* constants (since 1.28)
2138 public function isFileCacheable( $mode = HTMLFileCache
::MODE_NORMAL
) {
2141 if ( HTMLFileCache
::useFileCache( $this->getContext(), $mode ) ) {
2142 $cacheable = $this->mPage
->getId()
2143 && !$this->mRedirectedFrom
&& !$this->getTitle()->isRedirect();
2144 // Extension may have reason to disable file caching on some pages.
2146 // Avoid PHP 7.1 warning of passing $this by reference
2147 $articlePage = $this;
2148 $cacheable = Hooks
::run( 'IsFileCacheable', [ &$articlePage ] );
2158 * Lightweight method to get the parser output for a page, checking the parser cache
2159 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
2160 * consider, so it's not appropriate to use there.
2162 * @since 1.16 (r52326) for LiquidThreads
2164 * @param int|null $oldid Revision ID or null
2165 * @param User|null $user The relevant user
2166 * @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
2168 public function getParserOutput( $oldid = null, User
$user = null ) {
2169 // XXX: bypasses mParserOptions and thus setParserOptions()
2171 if ( $user === null ) {
2172 $parserOptions = $this->getParserOptions();
2174 $parserOptions = $this->mPage
->makeParserOptions( $user );
2177 return $this->mPage
->getParserOutput( $parserOptions, $oldid );
2181 * Override the ParserOptions used to render the primary article wikitext.
2183 * @param ParserOptions $options
2184 * @throws MWException If the parser options where already initialized.
2186 public function setParserOptions( ParserOptions
$options ) {
2187 if ( $this->mParserOptions
) {
2188 throw new MWException( "can't change parser options after they have already been set" );
2191 // clone, so if $options is modified later, it doesn't confuse the parser cache.
2192 $this->mParserOptions
= clone $options;
2196 * Get parser options suitable for rendering the primary article wikitext
2197 * @return ParserOptions
2199 public function getParserOptions() {
2200 if ( !$this->mParserOptions
) {
2201 $this->mParserOptions
= $this->mPage
->makeParserOptions( $this->getContext() );
2203 // Clone to allow modifications of the return value without affecting cache
2204 return clone $this->mParserOptions
;
2208 * Sets the context this Article is executed in
2210 * @param IContextSource $context
2213 public function setContext( $context ) {
2214 $this->mContext
= $context;
2218 * Gets the context this Article is executed in
2220 * @return IContextSource
2223 public function getContext() {
2224 if ( $this->mContext
instanceof IContextSource
) {
2225 return $this->mContext
;
2227 wfDebug( __METHOD__
. " called and \$mContext is null. " .
2228 "Return RequestContext::getMain(); for sanity\n" );
2229 return RequestContext
::getMain();
2234 * Use PHP's magic __get handler to handle accessing of
2235 * raw WikiPage fields for backwards compatibility.
2237 * @param string $fname Field name
2240 public function __get( $fname ) {
2241 if ( property_exists( $this->mPage
, $fname ) ) {
2242 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2243 return $this->mPage
->$fname;
2245 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE
);
2249 * Use PHP's magic __set handler to handle setting of
2250 * raw WikiPage fields for backwards compatibility.
2252 * @param string $fname Field name
2253 * @param mixed $fvalue New value
2255 public function __set( $fname, $fvalue ) {
2256 if ( property_exists( $this->mPage
, $fname ) ) {
2257 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2258 $this->mPage
->$fname = $fvalue;
2259 // Note: extensions may want to toss on new fields
2260 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
2261 $this->mPage
->$fname = $fvalue;
2263 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE
);
2268 * Call to WikiPage function for backwards compatibility.
2269 * @see WikiPage::checkFlags
2271 public function checkFlags( $flags ) {
2272 return $this->mPage
->checkFlags( $flags );
2276 * Call to WikiPage function for backwards compatibility.
2277 * @see WikiPage::checkTouched
2279 public function checkTouched() {
2280 return $this->mPage
->checkTouched();
2284 * Call to WikiPage function for backwards compatibility.
2285 * @see WikiPage::clearPreparedEdit
2287 public function clearPreparedEdit() {
2288 $this->mPage
->clearPreparedEdit();
2292 * Call to WikiPage function for backwards compatibility.
2293 * @see WikiPage::doDeleteArticleReal
2295 public function doDeleteArticleReal(
2296 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User
$user = null,
2299 return $this->mPage
->doDeleteArticleReal(
2300 $reason, $suppress, $u1, $u2, $error, $user, $tags
2305 * Call to WikiPage function for backwards compatibility.
2306 * @see WikiPage::doDeleteUpdates
2308 public function doDeleteUpdates(
2310 Content
$content = null,
2314 $this->mPage
->doDeleteUpdates( $id, $content, $revision, $user );
2318 * Call to WikiPage function for backwards compatibility.
2319 * @deprecated since 1.29. Use WikiPage::doEditContent() directly instead
2320 * @see WikiPage::doEditContent
2322 public function doEditContent( Content
$content, $summary, $flags = 0, $originalRevId = false,
2323 User
$user = null, $serialFormat = null
2325 wfDeprecated( __METHOD__
, '1.29' );
2326 return $this->mPage
->doEditContent( $content, $summary, $flags, $originalRevId,
2327 $user, $serialFormat
2332 * Call to WikiPage function for backwards compatibility.
2333 * @see WikiPage::doEditUpdates
2335 public function doEditUpdates( Revision
$revision, User
$user, array $options = [] ) {
2336 return $this->mPage
->doEditUpdates( $revision, $user, $options );
2340 * Call to WikiPage function for backwards compatibility.
2341 * @see WikiPage::doPurge
2342 * @note In 1.28 (and only 1.28), this took a $flags parameter that
2343 * controlled how much purging was done.
2345 public function doPurge() {
2346 return $this->mPage
->doPurge();
2350 * Call to WikiPage function for backwards compatibility.
2351 * @see WikiPage::doViewUpdates
2353 public function doViewUpdates( User
$user, $oldid = 0 ) {
2354 $this->mPage
->doViewUpdates( $user, $oldid );
2358 * Call to WikiPage function for backwards compatibility.
2359 * @see WikiPage::exists
2361 public function exists() {
2362 return $this->mPage
->exists();
2366 * Call to WikiPage function for backwards compatibility.
2367 * @see WikiPage::followRedirect
2369 public function followRedirect() {
2370 return $this->mPage
->followRedirect();
2374 * Call to WikiPage function for backwards compatibility.
2375 * @see ContentHandler::getActionOverrides
2377 public function getActionOverrides() {
2378 return $this->mPage
->getActionOverrides();
2382 * Call to WikiPage function for backwards compatibility.
2383 * @see WikiPage::getAutoDeleteReason
2385 public function getAutoDeleteReason( &$hasHistory ) {
2386 return $this->mPage
->getAutoDeleteReason( $hasHistory );
2390 * Call to WikiPage function for backwards compatibility.
2391 * @see WikiPage::getCategories
2393 public function getCategories() {
2394 return $this->mPage
->getCategories();
2398 * Call to WikiPage function for backwards compatibility.
2399 * @see WikiPage::getComment
2401 public function getComment( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2402 return $this->mPage
->getComment( $audience, $user );
2406 * Call to WikiPage function for backwards compatibility.
2407 * @see WikiPage::getContentHandler
2409 public function getContentHandler() {
2410 return $this->mPage
->getContentHandler();
2414 * Call to WikiPage function for backwards compatibility.
2415 * @see WikiPage::getContentModel
2417 public function getContentModel() {
2418 return $this->mPage
->getContentModel();
2422 * Call to WikiPage function for backwards compatibility.
2423 * @see WikiPage::getContributors
2425 public function getContributors() {
2426 return $this->mPage
->getContributors();
2430 * Call to WikiPage function for backwards compatibility.
2431 * @see WikiPage::getCreator
2433 public function getCreator( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2434 return $this->mPage
->getCreator( $audience, $user );
2438 * Call to WikiPage function for backwards compatibility.
2439 * @see WikiPage::getDeletionUpdates
2441 public function getDeletionUpdates( Content
$content = null ) {
2442 return $this->mPage
->getDeletionUpdates( $content );
2446 * Call to WikiPage function for backwards compatibility.
2447 * @see WikiPage::getHiddenCategories
2449 public function getHiddenCategories() {
2450 return $this->mPage
->getHiddenCategories();
2454 * Call to WikiPage function for backwards compatibility.
2455 * @see WikiPage::getId
2457 public function getId() {
2458 return $this->mPage
->getId();
2462 * Call to WikiPage function for backwards compatibility.
2463 * @see WikiPage::getLatest
2465 public function getLatest() {
2466 return $this->mPage
->getLatest();
2470 * Call to WikiPage function for backwards compatibility.
2471 * @see WikiPage::getLinksTimestamp
2473 public function getLinksTimestamp() {
2474 return $this->mPage
->getLinksTimestamp();
2478 * Call to WikiPage function for backwards compatibility.
2479 * @see WikiPage::getMinorEdit
2481 public function getMinorEdit() {
2482 return $this->mPage
->getMinorEdit();
2486 * Call to WikiPage function for backwards compatibility.
2487 * @see WikiPage::getOldestRevision
2489 public function getOldestRevision() {
2490 return $this->mPage
->getOldestRevision();
2494 * Call to WikiPage function for backwards compatibility.
2495 * @see WikiPage::getRedirectTarget
2497 public function getRedirectTarget() {
2498 return $this->mPage
->getRedirectTarget();
2502 * Call to WikiPage function for backwards compatibility.
2503 * @see WikiPage::getRedirectURL
2505 public function getRedirectURL( $rt ) {
2506 return $this->mPage
->getRedirectURL( $rt );
2510 * Call to WikiPage function for backwards compatibility.
2511 * @see WikiPage::getRevision
2513 public function getRevision() {
2514 return $this->mPage
->getRevision();
2518 * Call to WikiPage function for backwards compatibility.
2519 * @see WikiPage::getTimestamp
2521 public function getTimestamp() {
2522 return $this->mPage
->getTimestamp();
2526 * Call to WikiPage function for backwards compatibility.
2527 * @see WikiPage::getTouched
2529 public function getTouched() {
2530 return $this->mPage
->getTouched();
2534 * Call to WikiPage function for backwards compatibility.
2535 * @see WikiPage::getUndoContent
2537 public function getUndoContent( Revision
$undo, Revision
$undoafter = null ) {
2538 return $this->mPage
->getUndoContent( $undo, $undoafter );
2542 * Call to WikiPage function for backwards compatibility.
2543 * @see WikiPage::getUser
2545 public function getUser( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2546 return $this->mPage
->getUser( $audience, $user );
2550 * Call to WikiPage function for backwards compatibility.
2551 * @see WikiPage::getUserText
2553 public function getUserText( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2554 return $this->mPage
->getUserText( $audience, $user );
2558 * Call to WikiPage function for backwards compatibility.
2559 * @see WikiPage::hasViewableContent
2561 public function hasViewableContent() {
2562 return $this->mPage
->hasViewableContent();
2566 * Call to WikiPage function for backwards compatibility.
2567 * @see WikiPage::insertOn
2569 public function insertOn( $dbw, $pageId = null ) {
2570 return $this->mPage
->insertOn( $dbw, $pageId );
2574 * Call to WikiPage function for backwards compatibility.
2575 * @see WikiPage::insertProtectNullRevision
2577 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2578 array $expiry, $cascade, $reason, $user = null
2580 return $this->mPage
->insertProtectNullRevision( $revCommentMsg, $limit,
2581 $expiry, $cascade, $reason, $user
2586 * Call to WikiPage function for backwards compatibility.
2587 * @see WikiPage::insertRedirect
2589 public function insertRedirect() {
2590 return $this->mPage
->insertRedirect();
2594 * Call to WikiPage function for backwards compatibility.
2595 * @see WikiPage::insertRedirectEntry
2597 public function insertRedirectEntry( Title
$rt, $oldLatest = null ) {
2598 return $this->mPage
->insertRedirectEntry( $rt, $oldLatest );
2602 * Call to WikiPage function for backwards compatibility.
2603 * @see WikiPage::isCountable
2605 public function isCountable( $editInfo = false ) {
2606 return $this->mPage
->isCountable( $editInfo );
2610 * Call to WikiPage function for backwards compatibility.
2611 * @see WikiPage::isRedirect
2613 public function isRedirect() {
2614 return $this->mPage
->isRedirect();
2618 * Call to WikiPage function for backwards compatibility.
2619 * @see WikiPage::loadFromRow
2621 public function loadFromRow( $data, $from ) {
2622 return $this->mPage
->loadFromRow( $data, $from );
2626 * Call to WikiPage function for backwards compatibility.
2627 * @see WikiPage::loadPageData
2629 public function loadPageData( $from = 'fromdb' ) {
2630 $this->mPage
->loadPageData( $from );
2634 * Call to WikiPage function for backwards compatibility.
2635 * @see WikiPage::lockAndGetLatest
2637 public function lockAndGetLatest() {
2638 return $this->mPage
->lockAndGetLatest();
2642 * Call to WikiPage function for backwards compatibility.
2643 * @see WikiPage::makeParserOptions
2645 public function makeParserOptions( $context ) {
2646 return $this->mPage
->makeParserOptions( $context );
2650 * Call to WikiPage function for backwards compatibility.
2651 * @see WikiPage::pageDataFromId
2653 public function pageDataFromId( $dbr, $id, $options = [] ) {
2654 return $this->mPage
->pageDataFromId( $dbr, $id, $options );
2658 * Call to WikiPage function for backwards compatibility.
2659 * @see WikiPage::pageDataFromTitle
2661 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2662 return $this->mPage
->pageDataFromTitle( $dbr, $title, $options );
2666 * Call to WikiPage function for backwards compatibility.
2667 * @see WikiPage::prepareContentForEdit
2669 public function prepareContentForEdit(
2670 Content
$content, $revision = null, User
$user = null,
2671 $serialFormat = null, $useCache = true
2673 return $this->mPage
->prepareContentForEdit(
2674 $content, $revision, $user,
2675 $serialFormat, $useCache
2680 * Call to WikiPage function for backwards compatibility.
2681 * @see WikiPage::protectDescription
2683 public function protectDescription( array $limit, array $expiry ) {
2684 return $this->mPage
->protectDescription( $limit, $expiry );
2688 * Call to WikiPage function for backwards compatibility.
2689 * @see WikiPage::protectDescriptionLog
2691 public function protectDescriptionLog( array $limit, array $expiry ) {
2692 return $this->mPage
->protectDescriptionLog( $limit, $expiry );
2696 * Call to WikiPage function for backwards compatibility.
2697 * @see WikiPage::replaceSectionAtRev
2699 public function replaceSectionAtRev( $sectionId, Content
$sectionContent,
2700 $sectionTitle = '', $baseRevId = null
2702 return $this->mPage
->replaceSectionAtRev( $sectionId, $sectionContent,
2703 $sectionTitle, $baseRevId
2708 * Call to WikiPage function for backwards compatibility.
2709 * @see WikiPage::replaceSectionContent
2711 public function replaceSectionContent(
2712 $sectionId, Content
$sectionContent, $sectionTitle = '', $edittime = null
2714 return $this->mPage
->replaceSectionContent(
2715 $sectionId, $sectionContent, $sectionTitle, $edittime
2720 * Call to WikiPage function for backwards compatibility.
2721 * @see WikiPage::setTimestamp
2723 public function setTimestamp( $ts ) {
2724 return $this->mPage
->setTimestamp( $ts );
2728 * Call to WikiPage function for backwards compatibility.
2729 * @see WikiPage::shouldCheckParserCache
2731 public function shouldCheckParserCache( ParserOptions
$parserOptions, $oldId ) {
2732 return $this->mPage
->shouldCheckParserCache( $parserOptions, $oldId );
2736 * Call to WikiPage function for backwards compatibility.
2737 * @see WikiPage::supportsSections
2739 public function supportsSections() {
2740 return $this->mPage
->supportsSections();
2744 * Call to WikiPage function for backwards compatibility.
2745 * @see WikiPage::triggerOpportunisticLinksUpdate
2747 public function triggerOpportunisticLinksUpdate( ParserOutput
$parserOutput ) {
2748 return $this->mPage
->triggerOpportunisticLinksUpdate( $parserOutput );
2752 * Call to WikiPage function for backwards compatibility.
2753 * @see WikiPage::updateCategoryCounts
2755 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2756 return $this->mPage
->updateCategoryCounts( $added, $deleted, $id );
2760 * Call to WikiPage function for backwards compatibility.
2761 * @see WikiPage::updateIfNewerOn
2763 public function updateIfNewerOn( $dbw, $revision ) {
2764 return $this->mPage
->updateIfNewerOn( $dbw, $revision );
2768 * Call to WikiPage function for backwards compatibility.
2769 * @see WikiPage::updateRedirectOn
2771 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2772 return $this->mPage
->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect );
2776 * Call to WikiPage function for backwards compatibility.
2777 * @see WikiPage::updateRevisionOn
2779 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2780 $lastRevIsRedirect = null
2782 return $this->mPage
->updateRevisionOn( $dbw, $revision, $lastRevision,
2788 * @param array $limit
2789 * @param array $expiry
2790 * @param bool &$cascade
2791 * @param string $reason
2795 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2798 return $this->mPage
->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2802 * @param array $limit
2803 * @param string $reason
2804 * @param int &$cascade
2805 * @param array $expiry
2808 public function updateRestrictions( $limit = [], $reason = '',
2809 &$cascade = 0, $expiry = []
2811 return $this->mPage
->doUpdateRestrictions(
2816 $this->getContext()->getUser()
2821 * @param string $reason
2822 * @param bool $suppress
2823 * @param int|null $u1 Unused
2824 * @param bool|null $u2 Unused
2825 * @param string &$error
2828 public function doDeleteArticle(
2829 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2831 return $this->mPage
->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2835 * @param string $fromP
2836 * @param string $summary
2837 * @param string $token
2839 * @param array &$resultDetails
2840 * @param User|null $user
2843 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User
$user = null ) {
2844 $user = is_null( $user ) ?
$this->getContext()->getUser() : $user;
2845 return $this->mPage
->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2849 * @param string $fromP
2850 * @param string $summary
2852 * @param array &$resultDetails
2853 * @param User|null $guser
2856 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User
$guser = null ) {
2857 $guser = is_null( $guser ) ?
$this->getContext()->getUser() : $guser;
2858 return $this->mPage
->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2862 * @param bool &$hasHistory
2865 public function generateReason( &$hasHistory ) {
2866 $title = $this->mPage
->getTitle();
2867 $handler = ContentHandler
::getForTitle( $title );
2868 return $handler->getAutoDeleteReason( $title, $hasHistory );