3 * User interface for page actions.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 use MediaWiki\MediaWikiServices
;
25 * Class for viewing MediaWiki article and history.
27 * This maintains WikiPage functions for backwards compatibility.
29 * @todo Move and rewrite code to an Action class
31 * See design.txt for an overview.
32 * Note: edit user interface and cache support functions have been
33 * moved to separate EditPage and HTMLFileCache classes.
35 class Article
implements Page
{
36 /** @var IContextSource The context this Article is executed in */
39 /** @var WikiPage The WikiPage object of this instance */
42 /** @var ParserOptions ParserOptions object for $wgUser articles */
43 public $mParserOptions;
46 * @var string Text of the revision we are working on
52 * @var Content Content of the revision we are working on
55 public $mContentObject;
57 /** @var bool Is the content ($mContent) already loaded? */
58 public $mContentLoaded = false;
60 /** @var int|null The oldid of the article that is to be shown, 0 for the current revision */
63 /** @var Title Title from which we were redirected here */
64 public $mRedirectedFrom = null;
66 /** @var string|bool URL to redirect to or false if none */
67 public $mRedirectUrl = false;
69 /** @var int Revision ID of revision we are working on */
70 public $mRevIdFetched = 0;
72 /** @var Revision Revision we are working on */
73 public $mRevision = null;
75 /** @var ParserOutput */
76 public $mParserOutput;
79 * Constructor and clear the article
80 * @param Title $title Reference to a Title object.
81 * @param int $oldId Revision ID, null to fetch from request, zero for current
83 public function __construct( Title
$title, $oldId = null ) {
84 $this->mOldId
= $oldId;
85 $this->mPage
= $this->newPage( $title );
92 protected function newPage( Title
$title ) {
93 return new WikiPage( $title );
97 * Constructor from a page id
98 * @param int $id Article ID to load
99 * @return Article|null
101 public static function newFromID( $id ) {
102 $t = Title
::newFromID( $id );
103 return $t == null ?
null : new static( $t );
107 * Create an Article object of the appropriate class for the given page.
109 * @param Title $title
110 * @param IContextSource $context
113 public static function newFromTitle( $title, IContextSource
$context ) {
114 if ( NS_MEDIA
== $title->getNamespace() ) {
115 // FIXME: where should this go?
116 $title = Title
::makeTitle( NS_FILE
, $title->getDBkey() );
120 Hooks
::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
122 switch ( $title->getNamespace() ) {
124 $page = new ImagePage( $title );
127 $page = new CategoryPage( $title );
130 $page = new Article( $title );
133 $page->setContext( $context );
139 * Create an Article object of the appropriate class for the given page.
141 * @param WikiPage $page
142 * @param IContextSource $context
145 public static function newFromWikiPage( WikiPage
$page, IContextSource
$context ) {
146 $article = self
::newFromTitle( $page->getTitle(), $context );
147 $article->mPage
= $page; // override to keep process cached vars
152 * Get the page this view was redirected from
156 public function getRedirectedFrom() {
157 return $this->mRedirectedFrom
;
161 * Tell the page view functions that this view was redirected
162 * from another page on the wiki.
165 public function setRedirectedFrom( Title
$from ) {
166 $this->mRedirectedFrom
= $from;
170 * Get the title object of the article
172 * @return Title Title object of this page
174 public function getTitle() {
175 return $this->mPage
->getTitle();
179 * Get the WikiPage object of this instance
184 public function getPage() {
191 public function clear() {
192 $this->mContentLoaded
= false;
194 $this->mRedirectedFrom
= null; # Title object if set
195 $this->mRevIdFetched
= 0;
196 $this->mRedirectUrl
= false;
198 $this->mPage
->clear();
202 * Returns a Content object representing the pages effective display content,
203 * not necessarily the revision's content!
205 * Note that getContent does not follow redirects anymore.
206 * If you need to fetch redirectable content easily, try
207 * the shortcut in WikiPage::getRedirectTarget()
209 * This function has side effects! Do not use this function if you
210 * only want the real revision text if any.
212 * @return Content Return the content of this revision
216 protected function getContentObject() {
217 if ( $this->mPage
->getId() === 0 ) {
218 # If this is a MediaWiki:x message, then load the messages
219 # and return the message value for x.
220 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI
) {
221 $text = $this->getTitle()->getDefaultMessageText();
222 if ( $text === false ) {
226 $content = ContentHandler
::makeContent( $text, $this->getTitle() );
228 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
229 $content = new MessageContent( $message, null, 'parsemag' );
232 $this->fetchContentObject();
233 $content = $this->mContentObject
;
240 * @return int The oldid of the article that is to be shown, 0 for the current revision
242 public function getOldID() {
243 if ( is_null( $this->mOldId
) ) {
244 $this->mOldId
= $this->getOldIDFromRequest();
247 return $this->mOldId
;
251 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
253 * @return int The old id for the request
255 public function getOldIDFromRequest() {
256 $this->mRedirectUrl
= false;
258 $request = $this->getContext()->getRequest();
259 $oldid = $request->getIntOrNull( 'oldid' );
261 if ( $oldid === null ) {
265 if ( $oldid !== 0 ) {
266 # Load the given revision and check whether the page is another one.
267 # In that case, update this instance to reflect the change.
268 if ( $oldid === $this->mPage
->getLatest() ) {
269 $this->mRevision
= $this->mPage
->getRevision();
271 $this->mRevision
= Revision
::newFromId( $oldid );
272 if ( $this->mRevision
!== null ) {
273 // Revision title doesn't match the page title given?
274 if ( $this->mPage
->getId() != $this->mRevision
->getPage() ) {
275 $function = [ get_class( $this->mPage
), 'newFromID' ];
276 $this->mPage
= call_user_func( $function, $this->mRevision
->getPage() );
282 if ( $request->getVal( 'direction' ) == 'next' ) {
283 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
286 $this->mRevision
= null;
288 $this->mRedirectUrl
= $this->getTitle()->getFullURL( 'redirect=no' );
290 } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
291 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
294 $this->mRevision
= null;
302 * Get text content object
303 * Does *NOT* follow redirects.
304 * @todo When is this null?
306 * @note Code that wants to retrieve page content from the database should
307 * use WikiPage::getContent().
309 * @return Content|null|bool
313 protected function fetchContentObject() {
314 if ( $this->mContentLoaded
) {
315 return $this->mContentObject
;
318 $this->mContentLoaded
= true;
319 $this->mContent
= null;
321 $oldid = $this->getOldID();
323 # Pre-fill content with error message so that if something
324 # fails we'll have something telling us what we intended.
325 // XXX: this isn't page content but a UI message. horrible.
326 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
329 # $this->mRevision might already be fetched by getOldIDFromRequest()
330 if ( !$this->mRevision
) {
331 $this->mRevision
= Revision
::newFromId( $oldid );
332 if ( !$this->mRevision
) {
333 wfDebug( __METHOD__
. " failed to retrieve specified revision, id $oldid\n" );
338 $oldid = $this->mPage
->getLatest();
340 wfDebug( __METHOD__
. " failed to find page data for title " .
341 $this->getTitle()->getPrefixedText() . "\n" );
345 # Update error message with correct oldid
346 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
348 $this->mRevision
= $this->mPage
->getRevision();
350 if ( !$this->mRevision
) {
351 wfDebug( __METHOD__
. " failed to retrieve current page, rev_id $oldid\n" );
356 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
357 // We should instead work with the Revision object when we need it...
358 // Loads if user is allowed
359 $content = $this->mRevision
->getContent(
360 Revision
::FOR_THIS_USER
,
361 $this->getContext()->getUser()
365 wfDebug( __METHOD__
. " failed to retrieve content of revision " .
366 $this->mRevision
->getId() . "\n" );
370 $this->mContentObject
= $content;
371 $this->mRevIdFetched
= $this->mRevision
->getId();
373 // Avoid PHP 7.1 warning of passing $this by reference
374 $articlePage = $this;
377 'ArticleAfterFetchContentObject',
378 [ &$articlePage, &$this->mContentObject
]
381 return $this->mContentObject
;
385 * Returns true if the currently-referenced revision is the current edit
386 * to this page (and it exists).
389 public function isCurrent() {
390 # If no oldid, this is the current version.
391 if ( $this->getOldID() == 0 ) {
395 return $this->mPage
->exists() && $this->mRevision
&& $this->mRevision
->isCurrent();
399 * Get the fetched Revision object depending on request parameters or null
403 * @return Revision|null
405 public function getRevisionFetched() {
406 $this->fetchContentObject();
408 return $this->mRevision
;
412 * Use this to fetch the rev ID used on page views
414 * @return int Revision ID of last article revision
416 public function getRevIdFetched() {
417 if ( $this->mRevIdFetched
) {
418 return $this->mRevIdFetched
;
420 return $this->mPage
->getLatest();
425 * This is the default action of the index.php entry point: just view the
426 * page of the given title.
428 public function view() {
429 global $wgUseFileCache, $wgDebugToolbar;
431 # Get variables from query string
432 # As side effect this will load the revision and update the title
433 # in a revision ID is passed in the request, so this should remain
434 # the first call of this method even if $oldid is used way below.
435 $oldid = $this->getOldID();
437 $user = $this->getContext()->getUser();
438 # Another whitelist check in case getOldID() is altering the title
439 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
440 if ( count( $permErrors ) ) {
441 wfDebug( __METHOD__
. ": denied on secondary read check\n" );
442 throw new PermissionsError( 'read', $permErrors );
445 $outputPage = $this->getContext()->getOutput();
446 # getOldID() may as well want us to redirect somewhere else
447 if ( $this->mRedirectUrl
) {
448 $outputPage->redirect( $this->mRedirectUrl
);
449 wfDebug( __METHOD__
. ": redirecting due to oldid\n" );
454 # If we got diff in the query, we want to see a diff page instead of the article.
455 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
456 wfDebug( __METHOD__
. ": showing diff page\n" );
457 $this->showDiffPage();
462 # Set page title (may be overridden by DISPLAYTITLE)
463 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
465 $outputPage->setArticleFlag( true );
466 # Allow frames by default
467 $outputPage->allowClickjacking();
469 $parserCache = MediaWikiServices
::getInstance()->getParserCache();
471 $parserOptions = $this->getParserOptions();
472 # Render printable version, use printable version cache
473 if ( $outputPage->isPrintable() ) {
474 $parserOptions->setIsPrintable( true );
475 $parserOptions->setEditSection( false );
476 } elseif ( !$this->isCurrent() ||
!$this->getTitle()->quickUserCan( 'edit', $user ) ) {
477 $parserOptions->setEditSection( false );
480 # Try client and file cache
481 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage
->checkTouched() ) {
482 # Try to stream the output from file cache
483 if ( $wgUseFileCache && $this->tryFileCache() ) {
484 wfDebug( __METHOD__
. ": done file cache\n" );
485 # tell wgOut that output is taken care of
486 $outputPage->disable();
487 $this->mPage
->doViewUpdates( $user, $oldid );
493 # Should the parser cache be used?
494 $useParserCache = $this->mPage
->shouldCheckParserCache( $parserOptions, $oldid );
495 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ?
'yes' : 'no' ) . "\n" );
496 if ( $user->getStubThreshold() ) {
497 MediaWikiServices
::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
500 $this->showRedirectedFromHeader();
501 $this->showNamespaceHeader();
503 # Iterate through the possible ways of constructing the output text.
504 # Keep going until $outputDone is set, or we run out of things to do.
507 $this->mParserOutput
= false;
509 while ( !$outputDone && ++
$pass ) {
512 // Avoid PHP 7.1 warning of passing $this by reference
513 $articlePage = $this;
514 Hooks
::run( 'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
517 # Early abort if the page doesn't exist
518 if ( !$this->mPage
->exists() ) {
519 wfDebug( __METHOD__
. ": showing missing article\n" );
520 $this->showMissingArticle();
521 $this->mPage
->doViewUpdates( $user );
525 # Try the parser cache
526 if ( $useParserCache ) {
527 $this->mParserOutput
= $parserCache->get( $this->mPage
, $parserOptions );
529 if ( $this->mParserOutput
!== false ) {
531 wfDebug( __METHOD__
. ": showing parser cache contents for current rev permalink\n" );
532 $this->setOldSubtitle( $oldid );
534 wfDebug( __METHOD__
. ": showing parser cache contents\n" );
536 $outputPage->addParserOutput( $this->mParserOutput
);
537 # Ensure that UI elements requiring revision ID have
538 # the correct version information.
539 $outputPage->setRevisionId( $this->mPage
->getLatest() );
540 # Preload timestamp to avoid a DB hit
541 $cachedTimestamp = $this->mParserOutput
->getTimestamp();
542 if ( $cachedTimestamp !== null ) {
543 $outputPage->setRevisionTimestamp( $cachedTimestamp );
544 $this->mPage
->setTimestamp( $cachedTimestamp );
551 # This will set $this->mRevision if needed
552 $this->fetchContentObject();
554 # Are we looking at an old revision
555 if ( $oldid && $this->mRevision
) {
556 $this->setOldSubtitle( $oldid );
558 if ( !$this->showDeletedRevisionHeader() ) {
559 wfDebug( __METHOD__
. ": cannot view deleted revision\n" );
564 # Ensure that UI elements requiring revision ID have
565 # the correct version information.
566 $outputPage->setRevisionId( $this->getRevIdFetched() );
567 # Preload timestamp to avoid a DB hit
568 $outputPage->setRevisionTimestamp( $this->mPage
->getTimestamp() );
570 if ( !Hooks
::run( 'ArticleContentViewCustom',
571 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] )
573 # Allow extensions do their own custom view for certain pages
578 # Run the parse, protected by a pool counter
579 wfDebug( __METHOD__
. ": doing uncached parse\n" );
581 $content = $this->getContentObject();
582 $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
583 $this->getRevIdFetched(), $useParserCache, $content );
585 if ( !$poolArticleView->execute() ) {
586 $error = $poolArticleView->getError();
588 $outputPage->clearHTML(); // for release() errors
589 $outputPage->enableClientCache( false );
590 $outputPage->setRobotPolicy( 'noindex,nofollow' );
592 $errortext = $error->getWikiText( false, 'view-pool-error' );
593 $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
595 # Connection or timeout error
599 $this->mParserOutput
= $poolArticleView->getParserOutput();
600 $outputPage->addParserOutput( $this->mParserOutput
);
601 if ( $content->getRedirectTarget() ) {
602 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
603 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
606 # Don't cache a dirty ParserOutput object
607 if ( $poolArticleView->getIsDirty() ) {
608 $outputPage->setCdnMaxage( 0 );
609 $outputPage->addHTML( "<!-- parser cache is expired, " .
610 "sending anyway due to pool overload-->\n" );
615 # Should be unreachable, but just in case...
621 # Get the ParserOutput actually *displayed* here.
622 # Note that $this->mParserOutput is the *current*/oldid version output.
623 $pOutput = ( $outputDone instanceof ParserOutput
)
624 ?
$outputDone // object fetched by hook
625 : $this->mParserOutput
;
627 # Adjust title for main page & pages with displaytitle
629 $this->adjustDisplayTitle( $pOutput );
632 # For the main page, overwrite the <title> element with the con-
633 # tents of 'pagetitle-view-mainpage' instead of the default (if
635 # This message always exists because it is in the i18n files
636 if ( $this->getTitle()->isMainPage() ) {
637 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
638 if ( !$msg->isDisabled() ) {
639 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
643 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
644 # This could use getTouched(), but that could be scary for major template edits.
645 $outputPage->adaptCdnTTL( $this->mPage
->getTimestamp(), IExpiringStore
::TTL_DAY
);
647 # Check for any __NOINDEX__ tags on the page using $pOutput
648 $policy = $this->getRobotPolicy( 'view', $pOutput );
649 $outputPage->setIndexPolicy( $policy['index'] );
650 $outputPage->setFollowPolicy( $policy['follow'] );
652 $this->showViewFooter();
653 $this->mPage
->doViewUpdates( $user, $oldid );
655 # Load the postEdit module if the user just saved this revision
656 # See also EditPage::setPostEditCookie
657 $request = $this->getContext()->getRequest();
658 $cookieKey = EditPage
::POST_EDIT_COOKIE_KEY_PREFIX
. $this->getRevIdFetched();
659 $postEdit = $request->getCookie( $cookieKey );
661 # Clear the cookie. This also prevents caching of the response.
662 $request->response()->clearCookie( $cookieKey );
663 $outputPage->addJsConfigVars( 'wgPostEdit', $postEdit );
664 $outputPage->addModules( 'mediawiki.action.view.postEdit' );
669 * Adjust title for pages with displaytitle, -{T|}- or language conversion
670 * @param ParserOutput $pOutput
672 public function adjustDisplayTitle( ParserOutput
$pOutput ) {
673 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
674 $titleText = $pOutput->getTitleText();
675 if ( strval( $titleText ) !== '' ) {
676 $this->getContext()->getOutput()->setPageTitle( $titleText );
681 * Show a diff page according to current request variables. For use within
682 * Article::view() only, other callers should use the DifferenceEngine class.
684 protected function showDiffPage() {
685 $request = $this->getContext()->getRequest();
686 $user = $this->getContext()->getUser();
687 $diff = $request->getVal( 'diff' );
688 $rcid = $request->getVal( 'rcid' );
689 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
690 $purge = $request->getVal( 'action' ) == 'purge';
691 $unhide = $request->getInt( 'unhide' ) == 1;
692 $oldid = $this->getOldID();
694 $rev = $this->getRevisionFetched();
697 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
698 $msg = $this->getContext()->msg( 'difference-missing-revision' )
702 $this->getContext()->getOutput()->addHTML( $msg );
706 $contentHandler = $rev->getContentHandler();
707 $de = $contentHandler->createDifferenceEngine(
716 // DifferenceEngine directly fetched the revision:
717 $this->mRevIdFetched
= $de->mNewid
;
718 $de->showDiffPage( $diffOnly );
720 // Run view updates for the newer revision being diffed (and shown
721 // below the diff if not $diffOnly).
722 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
723 // New can be false, convert it to 0 - this conveniently means the latest revision
724 $this->mPage
->doViewUpdates( $user, (int)$new );
728 * Get the robot policy to be used for the current view
729 * @param string $action The action= GET parameter
730 * @param ParserOutput|null $pOutput
731 * @return array The policy that should be set
732 * @todo actions other than 'view'
734 public function getRobotPolicy( $action, $pOutput = null ) {
735 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
737 $ns = $this->getTitle()->getNamespace();
739 # Don't index user and user talk pages for blocked users (T13443)
740 if ( ( $ns == NS_USER ||
$ns == NS_USER_TALK
) && !$this->getTitle()->isSubpage() ) {
741 $specificTarget = null;
743 $titleText = $this->getTitle()->getText();
744 if ( IP
::isValid( $titleText ) ) {
745 $vagueTarget = $titleText;
747 $specificTarget = $titleText;
749 if ( Block
::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block
) {
751 'index' => 'noindex',
752 'follow' => 'nofollow'
757 if ( $this->mPage
->getId() === 0 ||
$this->getOldID() ) {
758 # Non-articles (special pages etc), and old revisions
760 'index' => 'noindex',
761 'follow' => 'nofollow'
763 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
764 # Discourage indexing of printable versions, but encourage following
766 'index' => 'noindex',
769 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
770 # For ?curid=x urls, disallow indexing
772 'index' => 'noindex',
777 # Otherwise, construct the policy based on the various config variables.
778 $policy = self
::formatRobotPolicy( $wgDefaultRobotPolicy );
780 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
781 # Honour customised robot policies for this namespace
782 $policy = array_merge(
784 self
::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
787 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
788 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
789 # a final sanity check that we have really got the parser output.
790 $policy = array_merge(
792 [ 'index' => $pOutput->getIndexPolicy() ]
796 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
797 # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
798 $policy = array_merge(
800 self
::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
808 * Converts a String robot policy into an associative array, to allow
809 * merging of several policies using array_merge().
810 * @param array|string $policy Returns empty array on null/false/'', transparent
811 * to already-converted arrays, converts string.
812 * @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
814 public static function formatRobotPolicy( $policy ) {
815 if ( is_array( $policy ) ) {
817 } elseif ( !$policy ) {
821 $policy = explode( ',', $policy );
822 $policy = array_map( 'trim', $policy );
825 foreach ( $policy as $var ) {
826 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
827 $arr['index'] = $var;
828 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
829 $arr['follow'] = $var;
837 * If this request is a redirect view, send "redirected from" subtitle to
838 * the output. Returns true if the header was needed, false if this is not
839 * a redirect view. Handles both local and remote redirects.
843 public function showRedirectedFromHeader() {
844 global $wgRedirectSources;
846 $context = $this->getContext();
847 $outputPage = $context->getOutput();
848 $request = $context->getRequest();
849 $rdfrom = $request->getVal( 'rdfrom' );
851 // Construct a URL for the current page view, but with the target title
852 $query = $request->getValues();
853 unset( $query['rdfrom'] );
854 unset( $query['title'] );
855 if ( $this->getTitle()->isRedirect() ) {
856 // Prevent double redirects
857 $query['redirect'] = 'no';
859 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
861 if ( isset( $this->mRedirectedFrom
) ) {
862 // Avoid PHP 7.1 warning of passing $this by reference
863 $articlePage = $this;
865 // This is an internally redirected page view.
866 // We'll need a backlink to the source page for navigation.
867 if ( Hooks
::run( 'ArticleViewRedirect', [ &$articlePage ] ) ) {
868 $redir = Linker
::linkKnown(
869 $this->mRedirectedFrom
,
872 [ 'redirect' => 'no' ]
875 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
876 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
879 // Add the script to update the displayed URL and
880 // set the fragment if one was specified in the redirect
881 $outputPage->addJsConfigVars( [
882 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
884 $outputPage->addModules( 'mediawiki.action.view.redirect' );
886 // Add a <link rel="canonical"> tag
887 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
889 // Tell the output object that the user arrived at this article through a redirect
890 $outputPage->setRedirectedFrom( $this->mRedirectedFrom
);
894 } elseif ( $rdfrom ) {
895 // This is an externally redirected view, from some other wiki.
896 // If it was reported from a trusted site, supply a backlink.
897 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
898 $redir = Linker
::makeExternalLink( $rdfrom, $rdfrom );
899 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
900 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
903 // Add the script to update the displayed URL
904 $outputPage->addJsConfigVars( [
905 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
907 $outputPage->addModules( 'mediawiki.action.view.redirect' );
917 * Show a header specific to the namespace currently being viewed, like
918 * [[MediaWiki:Talkpagetext]]. For Article::view().
920 public function showNamespaceHeader() {
921 if ( $this->getTitle()->isTalkPage() ) {
922 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
923 $this->getContext()->getOutput()->wrapWikiMsg(
924 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
932 * Show the footer section of an ordinary page view
934 public function showViewFooter() {
935 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
936 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
937 && IP
::isValid( $this->getTitle()->getText() )
939 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
942 // Show a footer allowing the user to patrol the shown revision or page if possible
943 $patrolFooterShown = $this->showPatrolFooter();
945 Hooks
::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
949 * If patrol is possible, output a patrol UI box. This is called from the
950 * footer section of ordinary page views. If patrol is not possible or not
951 * desired, does nothing.
952 * Side effect: When the patrol link is build, this method will call
953 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
957 public function showPatrolFooter() {
958 global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
960 $outputPage = $this->getContext()->getOutput();
961 $user = $this->getContext()->getUser();
962 $title = $this->getTitle();
965 if ( !$title->quickUserCan( 'patrol', $user )
966 ||
!( $wgUseRCPatrol ||
$wgUseNPPatrol
967 ||
( $wgUseFilePatrol && $title->inNamespace( NS_FILE
) ) )
969 // Patrolling is disabled or the user isn't allowed to
973 if ( $this->mRevision
974 && !RecentChange
::isInRCLifespan( $this->mRevision
->getTimestamp(), 21600 )
976 // The current revision is already older than what could be in the RC table
977 // 6h tolerance because the RC might not be cleaned out regularly
981 // Check for cached results
982 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
983 $key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() );
984 if ( $cache->get( $key ) ) {
988 $dbr = wfGetDB( DB_REPLICA
);
989 $oldestRevisionTimestamp = $dbr->selectField(
991 'MIN( rev_timestamp )',
992 [ 'rev_page' => $title->getArticleID() ],
996 // New page patrol: Get the timestamp of the oldest revison which
997 // the revision table holds for the given page. Then we look
998 // whether it's within the RC lifespan and if it is, we try
999 // to get the recentchanges row belonging to that entry
1000 // (with rc_new = 1).
1001 $recentPageCreation = false;
1002 if ( $oldestRevisionTimestamp
1003 && RecentChange
::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
1005 // 6h tolerance because the RC might not be cleaned out regularly
1006 $recentPageCreation = true;
1007 $rc = RecentChange
::newFromConds(
1010 'rc_timestamp' => $oldestRevisionTimestamp,
1011 'rc_namespace' => $title->getNamespace(),
1012 'rc_cur_id' => $title->getArticleID()
1017 // Use generic patrol message for new pages
1018 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1022 // File patrol: Get the timestamp of the latest upload for this page,
1023 // check whether it is within the RC lifespan and if it is, we try
1024 // to get the recentchanges row belonging to that entry
1025 // (with rc_type = RC_LOG, rc_log_type = upload).
1026 $recentFileUpload = false;
1027 if ( ( !$rc ||
$rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1028 && $title->getNamespace() === NS_FILE
) {
1029 // Retrieve timestamp of most recent upload
1030 $newestUploadTimestamp = $dbr->selectField(
1032 'MAX( img_timestamp )',
1033 [ 'img_name' => $title->getDBkey() ],
1036 if ( $newestUploadTimestamp
1037 && RecentChange
::isInRCLifespan( $newestUploadTimestamp, 21600 )
1039 // 6h tolerance because the RC might not be cleaned out regularly
1040 $recentFileUpload = true;
1041 $rc = RecentChange
::newFromConds(
1043 'rc_type' => RC_LOG
,
1044 'rc_log_type' => 'upload',
1045 'rc_timestamp' => $newestUploadTimestamp,
1046 'rc_namespace' => NS_FILE
,
1047 'rc_cur_id' => $title->getArticleID()
1050 [ 'USE INDEX' => 'rc_timestamp' ]
1053 // Use patrol message specific to files
1054 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1059 if ( !$recentPageCreation && !$recentFileUpload ) {
1060 // Page creation and latest upload (for files) is too old to be in RC
1062 // We definitely can't patrol so cache the information
1063 // When a new file version is uploaded, the cache is cleared
1064 $cache->set( $key, '1' );
1070 // Don't cache: This can be hit if the page gets accessed very fast after
1071 // its creation / latest upload or in case we have high replica DB lag. In case
1072 // the revision is too old, we will already return above.
1076 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1077 // Patrolled RC entry around
1079 // Cache the information we gathered above in case we can't patrol
1080 // Don't cache in case we can patrol as this could change
1081 $cache->set( $key, '1' );
1086 if ( $rc->getPerformer()->equals( $user ) ) {
1087 // Don't show a patrol link for own creations/uploads. If the user could
1088 // patrol them, they already would be patrolled
1092 $outputPage->preventClickjacking();
1093 if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
1094 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1097 $link = Linker
::linkKnown(
1099 $markPatrolledMsg->escaped(),
1102 'action' => 'markpatrolled',
1103 'rcid' => $rc->getAttribute( 'rc_id' ),
1107 $outputPage->addHTML(
1108 "<div class='patrollink' data-mw='interface'>" .
1109 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1117 * Purge the cache used to check if it is worth showing the patrol footer
1118 * For example, it is done during re-uploads when file patrol is used.
1119 * @param int $articleID ID of the article to purge
1122 public static function purgePatrolFooterCache( $articleID ) {
1123 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
1124 $cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) );
1128 * Show the error text for a missing article. For articles in the MediaWiki
1129 * namespace, show the default message text. To be called from Article::view().
1131 public function showMissingArticle() {
1132 global $wgSend404Code;
1134 $outputPage = $this->getContext()->getOutput();
1135 // Whether the page is a root user page of an existing user (but not a subpage)
1136 $validUserPage = false;
1138 $title = $this->getTitle();
1140 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1141 if ( $title->getNamespace() == NS_USER
1142 ||
$title->getNamespace() == NS_USER_TALK
1144 $rootPart = explode( '/', $title->getText() )[0];
1145 $user = User
::newFromName( $rootPart, false /* allow IP users */ );
1146 $ip = User
::isIP( $rootPart );
1147 $block = Block
::newFromTarget( $user, $user );
1149 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1150 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1151 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1152 } elseif ( !is_null( $block ) && $block->getType() != Block
::TYPE_AUTO
) {
1153 # Show log extract if the user is currently blocked
1154 LogEventsList
::showLogExtract(
1157 MWNamespace
::getCanonicalName( NS_USER
) . ':' . $block->getTarget(),
1161 'showIfEmpty' => false,
1163 'blocked-notice-logextract',
1164 $user->getName() # Support GENDER in notice
1168 $validUserPage = !$title->isSubpage();
1170 $validUserPage = !$title->isSubpage();
1174 Hooks
::run( 'ShowMissingArticle', [ $this ] );
1176 # Show delete and move logs if there were any such events.
1177 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1178 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1179 $cache = MediaWikiServices
::getInstance()->getMainObjectStash();
1180 $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1181 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1182 if ( $loggedIn ||
$cache->get( $key ) ) {
1183 $logTypes = [ 'delete', 'move', 'protect' ];
1185 $dbr = wfGetDB( DB_REPLICA
);
1187 $conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
1188 // Give extensions a chance to hide their (unrelated) log entries
1189 Hooks
::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1190 LogEventsList
::showLogExtract(
1198 'showIfEmpty' => false,
1199 'msgKey' => [ $loggedIn
1200 ?
'moveddeleted-notice'
1201 : 'moveddeleted-notice-recent'
1207 if ( !$this->mPage
->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1208 // If there's no backing content, send a 404 Not Found
1209 // for better machine handling of broken links.
1210 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1213 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1214 $policy = $this->getRobotPolicy( 'view' );
1215 $outputPage->setIndexPolicy( $policy['index'] );
1216 $outputPage->setFollowPolicy( $policy['follow'] );
1218 $hookResult = Hooks
::run( 'BeforeDisplayNoArticleText', [ $this ] );
1220 if ( !$hookResult ) {
1224 # Show error message
1225 $oldid = $this->getOldID();
1226 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI
&& $title->hasSourceText() ) {
1227 $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
1230 $text = wfMessage( 'missing-revision', $oldid )->plain();
1231 } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1232 && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1234 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
1235 $text = wfMessage( $message )->plain();
1237 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1240 $dir = $this->getContext()->getLanguage()->getDir();
1241 $lang = $this->getContext()->getLanguage()->getCode();
1242 $outputPage->addWikiText( Xml
::openElement( 'div', [
1243 'class' => "noarticletext mw-content-$dir",
1246 ] ) . "\n$text\n</div>" );
1251 * If the revision requested for view is deleted, check permissions.
1252 * Send either an error message or a warning header to the output.
1254 * @return bool True if the view is allowed, false if not.
1256 public function showDeletedRevisionHeader() {
1257 if ( !$this->mRevision
->isDeleted( Revision
::DELETED_TEXT
) ) {
1262 $outputPage = $this->getContext()->getOutput();
1263 $user = $this->getContext()->getUser();
1264 // If the user is not allowed to see it...
1265 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
, $user ) ) {
1266 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1267 'rev-deleted-text-permission' );
1270 // If the user needs to confirm that they want to see it...
1271 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1272 # Give explanation and add a link to view the revision...
1273 $oldid = intval( $this->getOldID() );
1274 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1275 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1276 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1277 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1281 // We are allowed to see...
1283 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1284 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1285 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1292 * Generate the navigation links when browsing through an article revisions
1293 * It shows the information as:
1294 * Revision as of \<date\>; view current revision
1295 * \<- Previous version | Next Version -\>
1297 * @param int $oldid Revision ID of this article revision
1299 public function setOldSubtitle( $oldid = 0 ) {
1300 // Avoid PHP 7.1 warning of passing $this by reference
1301 $articlePage = $this;
1303 if ( !Hooks
::run( 'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1307 $context = $this->getContext();
1308 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1310 # Cascade unhide param in links for easy deletion browsing
1313 $extraParams['unhide'] = 1;
1316 if ( $this->mRevision
&& $this->mRevision
->getId() === $oldid ) {
1317 $revision = $this->mRevision
;
1319 $revision = Revision
::newFromId( $oldid );
1322 $timestamp = $revision->getTimestamp();
1324 $current = ( $oldid == $this->mPage
->getLatest() );
1325 $language = $context->getLanguage();
1326 $user = $context->getUser();
1328 $td = $language->userTimeAndDate( $timestamp, $user );
1329 $tddate = $language->userDate( $timestamp, $user );
1330 $tdtime = $language->userTime( $timestamp, $user );
1332 # Show user links if allowed to see them. If hidden, then show them only if requested...
1333 $userlinks = Linker
::revUserTools( $revision, !$unhide );
1335 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1336 ?
'revision-info-current'
1339 $outputPage = $context->getOutput();
1340 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1341 $context->msg( $infomsg, $td )
1342 ->rawParams( $userlinks )
1343 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1344 ->rawParams( Linker
::revComment( $revision, true, true ) )
1349 ?
$context->msg( 'currentrevisionlink' )->escaped()
1350 : Linker
::linkKnown(
1352 $context->msg( 'currentrevisionlink' )->escaped(),
1357 ?
$context->msg( 'diff' )->escaped()
1358 : Linker
::linkKnown(
1360 $context->msg( 'diff' )->escaped(),
1367 $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1369 ? Linker
::linkKnown(
1371 $context->msg( 'previousrevision' )->escaped(),
1374 'direction' => 'prev',
1378 : $context->msg( 'previousrevision' )->escaped();
1380 ? Linker
::linkKnown(
1382 $context->msg( 'diff' )->escaped(),
1389 : $context->msg( 'diff' )->escaped();
1390 $nextlink = $current
1391 ?
$context->msg( 'nextrevision' )->escaped()
1392 : Linker
::linkKnown(
1394 $context->msg( 'nextrevision' )->escaped(),
1397 'direction' => 'next',
1401 $nextdiff = $current
1402 ?
$context->msg( 'diff' )->escaped()
1403 : Linker
::linkKnown(
1405 $context->msg( 'diff' )->escaped(),
1413 $cdel = Linker
::getRevDeleteLink( $user, $revision, $this->getTitle() );
1414 if ( $cdel !== '' ) {
1418 // the outer div is need for styling the revision info and nav in MobileFrontend
1419 $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1420 "<div id=\"mw-revision-nav\">" . $cdel .
1421 $context->msg( 'revision-nav' )->rawParams(
1422 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1423 )->escaped() . "</div></div>" );
1427 * Return the HTML for the top of a redirect page
1429 * Chances are you should just be using the ParserOutput from
1430 * WikitextContent::getParserOutput instead of calling this for redirects.
1432 * @param Title|array $target Destination(s) to redirect
1433 * @param bool $appendSubtitle [optional]
1434 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1435 * @return string Containing HTML with redirect link
1437 * @deprecated since 1.30
1439 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1440 $lang = $this->getTitle()->getPageLanguage();
1441 $out = $this->getContext()->getOutput();
1442 if ( $appendSubtitle ) {
1443 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1445 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1446 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1450 * Return the HTML for the top of a redirect page
1452 * Chances are you should just be using the ParserOutput from
1453 * WikitextContent::getParserOutput instead of calling this for redirects.
1456 * @param Language $lang
1457 * @param Title|array $target Destination(s) to redirect
1458 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1459 * @return string Containing HTML with redirect link
1461 public static function getRedirectHeaderHtml( Language
$lang, $target, $forceKnown = false ) {
1462 if ( !is_array( $target ) ) {
1463 $target = [ $target ];
1466 $html = '<ul class="redirectText">';
1467 /** @var Title $title */
1468 foreach ( $target as $title ) {
1469 $html .= '<li>' . Linker
::link(
1471 htmlspecialchars( $title->getFullText() ),
1473 // Make sure wiki page redirects are not followed
1474 $title->isRedirect() ?
[ 'redirect' => 'no' ] : [],
1475 ( $forceKnown ?
[ 'known', 'noclasses' ] : [] )
1480 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1482 return '<div class="redirectMsg">' .
1483 '<p>' . $redirectToText . '</p>' .
1489 * Adds help link with an icon via page indicators.
1490 * Link target can be overridden by a local message containing a wikilink:
1491 * the message key is: 'namespace-' + namespace number + '-helppage'.
1492 * @param string $to Target MediaWiki.org page title or encoded URL.
1493 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
1496 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1498 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1501 $out = $this->getContext()->getOutput();
1502 if ( !$msg->isDisabled() ) {
1503 $helpUrl = Skin
::makeUrl( $msg->plain() );
1504 $out->addHelpLink( $helpUrl, true );
1506 $out->addHelpLink( $to, $overrideBaseUrl );
1511 * Handle action=render
1513 public function render() {
1514 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1515 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1516 $this->getContext()->getOutput()->enableSectionEditLinks( false );
1521 * action=protect handler
1523 public function protect() {
1524 $form = new ProtectionForm( $this );
1529 * action=unprotect handler (alias)
1531 public function unprotect() {
1536 * UI entry point for page deletion
1538 public function delete() {
1539 # This code desperately needs to be totally rewritten
1541 $title = $this->getTitle();
1542 $context = $this->getContext();
1543 $user = $context->getUser();
1544 $request = $context->getRequest();
1547 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1548 if ( count( $permissionErrors ) ) {
1549 throw new PermissionsError( 'delete', $permissionErrors );
1552 # Read-only check...
1553 if ( wfReadOnly() ) {
1554 throw new ReadOnlyError
;
1557 # Better double-check that it hasn't been deleted yet!
1558 $this->mPage
->loadPageData(
1559 $request->wasPosted() ? WikiPage
::READ_LATEST
: WikiPage
::READ_NORMAL
1561 if ( !$this->mPage
->exists() ) {
1562 $deleteLogPage = new LogPage( 'delete' );
1563 $outputPage = $context->getOutput();
1564 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1565 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1566 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1568 $outputPage->addHTML(
1569 Xml
::element( 'h2', null, $deleteLogPage->getName()->text() )
1571 LogEventsList
::showLogExtract(
1580 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1581 $deleteReason = $request->getText( 'wpReason' );
1583 if ( $deleteReasonList == 'other' ) {
1584 $reason = $deleteReason;
1585 } elseif ( $deleteReason != '' ) {
1586 // Entry from drop down menu + additional comment
1587 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1588 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1590 $reason = $deleteReasonList;
1593 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1594 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1596 # Flag to hide all contents of the archived revisions
1597 $suppress = $request->getCheck( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1599 $this->doDelete( $reason, $suppress );
1601 WatchAction
::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1606 // Generate deletion reason
1607 $hasHistory = false;
1610 $reason = $this->generateReason( $hasHistory );
1611 } catch ( Exception
$e ) {
1612 # if a page is horribly broken, we still want to be able to
1613 # delete it. So be lenient about errors here.
1614 wfDebug( "Error while building auto delete summary: $e" );
1619 // If the page has a history, insert a warning
1620 if ( $hasHistory ) {
1621 $title = $this->getTitle();
1623 // The following can use the real revision count as this is only being shown for users
1624 // that can delete this page.
1625 // This, as a side-effect, also makes sure that the following query isn't being run for
1626 // pages with a larger history, unless the user has the 'bigdelete' right
1627 // (and is about to delete this page).
1628 $dbr = wfGetDB( DB_REPLICA
);
1629 $revisions = $edits = (int)$dbr->selectField(
1632 [ 'rev_page' => $title->getArticleID() ],
1636 // @todo FIXME: i18n issue/patchwork message
1637 $context->getOutput()->addHTML(
1638 '<strong class="mw-delete-warning-revisions">' .
1639 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1640 $context->msg( 'word-separator' )->escaped() . Linker
::linkKnown( $title,
1641 $context->msg( 'history' )->escaped(),
1643 [ 'action' => 'history' ] ) .
1647 if ( $title->isBigDeletion() ) {
1648 global $wgDeleteRevisionsLimit;
1649 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1651 'delete-warning-toobig',
1652 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1658 $this->confirmDelete( $reason );
1662 * Output deletion confirmation dialog
1663 * @todo FIXME: Move to another file?
1664 * @param string $reason Prefilled reason
1666 public function confirmDelete( $reason ) {
1667 wfDebug( "Article::confirmDelete\n" );
1669 $title = $this->getTitle();
1670 $ctx = $this->getContext();
1671 $outputPage = $ctx->getOutput();
1672 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1673 $outputPage->addBacklinkSubtitle( $title );
1674 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1676 $backlinkCache = $title->getBacklinkCache();
1677 if ( $backlinkCache->hasLinks( 'pagelinks' ) ||
$backlinkCache->hasLinks( 'templatelinks' ) ) {
1678 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1679 'deleting-backlinks-warning' );
1682 $subpageQueryLimit = 51;
1683 $subpages = $title->getSubpages( $subpageQueryLimit );
1684 $subpageCount = count( $subpages );
1685 if ( $subpageCount > 0 ) {
1686 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1687 [ 'deleting-subpages-warning', Message
::numParam( $subpageCount ) ] );
1689 $outputPage->addWikiMsg( 'confirmdeletetext' );
1691 Hooks
::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1693 $user = $this->getContext()->getUser();
1694 $checkWatch = $user->getBoolOption( 'watchdeletion' ) ||
$user->isWatched( $title );
1696 $outputPage->enableOOUI();
1698 $options = Xml
::listDropDownOptions(
1699 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->text(),
1700 [ 'other' => $ctx->msg( 'deletereasonotherlist' )->inContentLanguage()->text() ]
1702 $options = Xml
::listDropDownOptionsOoui( $options );
1704 $fields[] = new OOUI\
FieldLayout(
1705 new OOUI\
DropdownInputWidget( [
1706 'name' => 'wpDeleteReasonList',
1707 'inputId' => 'wpDeleteReasonList',
1709 'infusable' => true,
1711 'options' => $options
1714 'label' => $ctx->msg( 'deletecomment' )->text(),
1719 $fields[] = new OOUI\
FieldLayout(
1720 new OOUI\
TextInputWidget( [
1721 'name' => 'wpReason',
1722 'inputId' => 'wpReason',
1725 'infusable' => true,
1727 'autofocus' => true,
1730 'label' => $ctx->msg( 'deleteotherreason' )->text(),
1735 if ( $user->isLoggedIn() ) {
1736 $fields[] = new OOUI\
FieldLayout(
1737 new OOUI\
CheckboxInputWidget( [
1738 'name' => 'wpWatch',
1739 'inputId' => 'wpWatch',
1741 'selected' => $checkWatch,
1744 'label' => $ctx->msg( 'watchthis' )->text(),
1745 'align' => 'inline',
1746 'infusable' => true,
1751 if ( $user->isAllowed( 'suppressrevision' ) ) {
1752 $fields[] = new OOUI\
FieldLayout(
1753 new OOUI\
CheckboxInputWidget( [
1754 'name' => 'wpSuppress',
1755 'inputId' => 'wpSuppress',
1759 'label' => $ctx->msg( 'revdelete-suppress' )->text(),
1760 'align' => 'inline',
1761 'infusable' => true,
1766 $fields[] = new OOUI\
FieldLayout(
1767 new OOUI\
ButtonInputWidget( [
1768 'name' => 'wpConfirmB',
1769 'inputId' => 'wpConfirmB',
1771 'value' => $ctx->msg( 'deletepage' )->text(),
1772 'label' => $ctx->msg( 'deletepage' )->text(),
1773 'flags' => [ 'primary', 'destructive' ],
1781 $fieldset = new OOUI\
FieldsetLayout( [
1782 'label' => $ctx->msg( 'delete-legend' )->text(),
1783 'id' => 'mw-delete-table',
1787 $form = new OOUI\
FormLayout( [
1789 'action' => $title->getLocalURL( 'action=delete' ),
1790 'id' => 'deleteconfirm',
1792 $form->appendContent(
1794 new OOUI\
HtmlSnippet(
1795 Html
::hidden( 'wpEditToken', $user->getEditToken( [ 'delete', $title->getPrefixedText() ] ) )
1799 $outputPage->addHTML(
1800 new OOUI\
PanelLayout( [
1801 'classes' => [ 'deletepage-wrapper' ],
1802 'expanded' => false,
1809 if ( $user->isAllowed( 'editinterface' ) ) {
1810 $link = Linker
::linkKnown(
1811 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1812 wfMessage( 'delete-edit-reasonlist' )->escaped(),
1814 [ 'action' => 'edit' ]
1816 $outputPage->addHTML( '<p class="mw-delete-editreasons">' . $link . '</p>' );
1819 $deleteLogPage = new LogPage( 'delete' );
1820 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1821 LogEventsList
::showLogExtract( $outputPage, 'delete', $title );
1825 * Perform a deletion and output success or failure messages
1826 * @param string $reason
1827 * @param bool $suppress
1829 public function doDelete( $reason, $suppress = false ) {
1831 $context = $this->getContext();
1832 $outputPage = $context->getOutput();
1833 $user = $context->getUser();
1834 $status = $this->mPage
->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
1836 if ( $status->isGood() ) {
1837 $deleted = $this->getTitle()->getPrefixedText();
1839 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1840 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1842 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1844 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1846 Hooks
::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
1848 $outputPage->returnToMain( false );
1850 $outputPage->setPageTitle(
1851 wfMessage( 'cannotdelete-title',
1852 $this->getTitle()->getPrefixedText() )
1855 if ( $error == '' ) {
1856 $outputPage->addWikiText(
1857 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1859 $deleteLogPage = new LogPage( 'delete' );
1860 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1862 LogEventsList
::showLogExtract(
1868 $outputPage->addHTML( $error );
1873 /* Caching functions */
1876 * checkLastModified returns true if it has taken care of all
1877 * output to the client that is necessary for this request.
1878 * (that is, it has sent a cached version of the page)
1880 * @return bool True if cached version send, false otherwise
1882 protected function tryFileCache() {
1883 static $called = false;
1886 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1891 if ( $this->isFileCacheable() ) {
1892 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
1893 if ( $cache->isCacheGood( $this->mPage
->getTouched() ) ) {
1894 wfDebug( "Article::tryFileCache(): about to load file\n" );
1895 $cache->loadFromFileCache( $this->getContext() );
1898 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1899 ob_start( [ &$cache, 'saveToFileCache' ] );
1902 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1909 * Check if the page can be cached
1910 * @param int $mode One of the HTMLFileCache::MODE_* constants (since 1.28)
1913 public function isFileCacheable( $mode = HTMLFileCache
::MODE_NORMAL
) {
1916 if ( HTMLFileCache
::useFileCache( $this->getContext(), $mode ) ) {
1917 $cacheable = $this->mPage
->getId()
1918 && !$this->mRedirectedFrom
&& !$this->getTitle()->isRedirect();
1919 // Extension may have reason to disable file caching on some pages.
1921 // Avoid PHP 7.1 warning of passing $this by reference
1922 $articlePage = $this;
1923 $cacheable = Hooks
::run( 'IsFileCacheable', [ &$articlePage ] );
1933 * Lightweight method to get the parser output for a page, checking the parser cache
1934 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1935 * consider, so it's not appropriate to use there.
1937 * @since 1.16 (r52326) for LiquidThreads
1939 * @param int|null $oldid Revision ID or null
1940 * @param User $user The relevant user
1941 * @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
1943 public function getParserOutput( $oldid = null, User
$user = null ) {
1944 // XXX: bypasses mParserOptions and thus setParserOptions()
1946 if ( $user === null ) {
1947 $parserOptions = $this->getParserOptions();
1949 $parserOptions = $this->mPage
->makeParserOptions( $user );
1952 return $this->mPage
->getParserOutput( $parserOptions, $oldid );
1956 * Override the ParserOptions used to render the primary article wikitext.
1958 * @param ParserOptions $options
1959 * @throws MWException If the parser options where already initialized.
1961 public function setParserOptions( ParserOptions
$options ) {
1962 if ( $this->mParserOptions
) {
1963 throw new MWException( "can't change parser options after they have already been set" );
1966 // clone, so if $options is modified later, it doesn't confuse the parser cache.
1967 $this->mParserOptions
= clone $options;
1971 * Get parser options suitable for rendering the primary article wikitext
1972 * @return ParserOptions
1974 public function getParserOptions() {
1975 if ( !$this->mParserOptions
) {
1976 $this->mParserOptions
= $this->mPage
->makeParserOptions( $this->getContext() );
1978 // Clone to allow modifications of the return value without affecting cache
1979 return clone $this->mParserOptions
;
1983 * Sets the context this Article is executed in
1985 * @param IContextSource $context
1988 public function setContext( $context ) {
1989 $this->mContext
= $context;
1993 * Gets the context this Article is executed in
1995 * @return IContextSource
1998 public function getContext() {
1999 if ( $this->mContext
instanceof IContextSource
) {
2000 return $this->mContext
;
2002 wfDebug( __METHOD__
. " called and \$mContext is null. " .
2003 "Return RequestContext::getMain(); for sanity\n" );
2004 return RequestContext
::getMain();
2009 * Use PHP's magic __get handler to handle accessing of
2010 * raw WikiPage fields for backwards compatibility.
2012 * @param string $fname Field name
2015 public function __get( $fname ) {
2016 if ( property_exists( $this->mPage
, $fname ) ) {
2017 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2018 return $this->mPage
->$fname;
2020 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE
);
2024 * Use PHP's magic __set handler to handle setting of
2025 * raw WikiPage fields for backwards compatibility.
2027 * @param string $fname Field name
2028 * @param mixed $fvalue New value
2030 public function __set( $fname, $fvalue ) {
2031 if ( property_exists( $this->mPage
, $fname ) ) {
2032 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2033 $this->mPage
->$fname = $fvalue;
2034 // Note: extensions may want to toss on new fields
2035 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
2036 $this->mPage
->$fname = $fvalue;
2038 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE
);
2043 * Call to WikiPage function for backwards compatibility.
2044 * @see WikiPage::checkFlags
2046 public function checkFlags( $flags ) {
2047 return $this->mPage
->checkFlags( $flags );
2051 * Call to WikiPage function for backwards compatibility.
2052 * @see WikiPage::checkTouched
2054 public function checkTouched() {
2055 return $this->mPage
->checkTouched();
2059 * Call to WikiPage function for backwards compatibility.
2060 * @see WikiPage::clearPreparedEdit
2062 public function clearPreparedEdit() {
2063 $this->mPage
->clearPreparedEdit();
2067 * Call to WikiPage function for backwards compatibility.
2068 * @see WikiPage::doDeleteArticleReal
2070 public function doDeleteArticleReal(
2071 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User
$user = null,
2074 return $this->mPage
->doDeleteArticleReal(
2075 $reason, $suppress, $u1, $u2, $error, $user, $tags
2080 * Call to WikiPage function for backwards compatibility.
2081 * @see WikiPage::doDeleteUpdates
2083 public function doDeleteUpdates( $id, Content
$content = null ) {
2084 return $this->mPage
->doDeleteUpdates( $id, $content );
2088 * Call to WikiPage function for backwards compatibility.
2089 * @deprecated since 1.29. Use WikiPage::doEditContent() directly instead
2090 * @see WikiPage::doEditContent
2092 public function doEditContent( Content
$content, $summary, $flags = 0, $baseRevId = false,
2093 User
$user = null, $serialFormat = null
2095 wfDeprecated( __METHOD__
, '1.29' );
2096 return $this->mPage
->doEditContent( $content, $summary, $flags, $baseRevId,
2097 $user, $serialFormat
2102 * Call to WikiPage function for backwards compatibility.
2103 * @see WikiPage::doEditUpdates
2105 public function doEditUpdates( Revision
$revision, User
$user, array $options = [] ) {
2106 return $this->mPage
->doEditUpdates( $revision, $user, $options );
2110 * Call to WikiPage function for backwards compatibility.
2111 * @see WikiPage::doPurge
2112 * @note In 1.28 (and only 1.28), this took a $flags parameter that
2113 * controlled how much purging was done.
2115 public function doPurge() {
2116 return $this->mPage
->doPurge();
2120 * Call to WikiPage function for backwards compatibility.
2121 * @see WikiPage::getLastPurgeTimestamp
2122 * @deprecated since 1.29
2124 public function getLastPurgeTimestamp() {
2125 wfDeprecated( __METHOD__
, '1.29' );
2126 return $this->mPage
->getLastPurgeTimestamp();
2130 * Call to WikiPage function for backwards compatibility.
2131 * @see WikiPage::doViewUpdates
2133 public function doViewUpdates( User
$user, $oldid = 0 ) {
2134 $this->mPage
->doViewUpdates( $user, $oldid );
2138 * Call to WikiPage function for backwards compatibility.
2139 * @see WikiPage::exists
2141 public function exists() {
2142 return $this->mPage
->exists();
2146 * Call to WikiPage function for backwards compatibility.
2147 * @see WikiPage::followRedirect
2149 public function followRedirect() {
2150 return $this->mPage
->followRedirect();
2154 * Call to WikiPage function for backwards compatibility.
2155 * @see ContentHandler::getActionOverrides
2157 public function getActionOverrides() {
2158 return $this->mPage
->getActionOverrides();
2162 * Call to WikiPage function for backwards compatibility.
2163 * @see WikiPage::getAutoDeleteReason
2165 public function getAutoDeleteReason( &$hasHistory ) {
2166 return $this->mPage
->getAutoDeleteReason( $hasHistory );
2170 * Call to WikiPage function for backwards compatibility.
2171 * @see WikiPage::getCategories
2173 public function getCategories() {
2174 return $this->mPage
->getCategories();
2178 * Call to WikiPage function for backwards compatibility.
2179 * @see WikiPage::getComment
2181 public function getComment( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2182 return $this->mPage
->getComment( $audience, $user );
2186 * Call to WikiPage function for backwards compatibility.
2187 * @see WikiPage::getContentHandler
2189 public function getContentHandler() {
2190 return $this->mPage
->getContentHandler();
2194 * Call to WikiPage function for backwards compatibility.
2195 * @see WikiPage::getContentModel
2197 public function getContentModel() {
2198 return $this->mPage
->getContentModel();
2202 * Call to WikiPage function for backwards compatibility.
2203 * @see WikiPage::getContributors
2205 public function getContributors() {
2206 return $this->mPage
->getContributors();
2210 * Call to WikiPage function for backwards compatibility.
2211 * @see WikiPage::getCreator
2213 public function getCreator( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2214 return $this->mPage
->getCreator( $audience, $user );
2218 * Call to WikiPage function for backwards compatibility.
2219 * @see WikiPage::getDeletionUpdates
2221 public function getDeletionUpdates( Content
$content = null ) {
2222 return $this->mPage
->getDeletionUpdates( $content );
2226 * Call to WikiPage function for backwards compatibility.
2227 * @see WikiPage::getHiddenCategories
2229 public function getHiddenCategories() {
2230 return $this->mPage
->getHiddenCategories();
2234 * Call to WikiPage function for backwards compatibility.
2235 * @see WikiPage::getId
2237 public function getId() {
2238 return $this->mPage
->getId();
2242 * Call to WikiPage function for backwards compatibility.
2243 * @see WikiPage::getLatest
2245 public function getLatest() {
2246 return $this->mPage
->getLatest();
2250 * Call to WikiPage function for backwards compatibility.
2251 * @see WikiPage::getLinksTimestamp
2253 public function getLinksTimestamp() {
2254 return $this->mPage
->getLinksTimestamp();
2258 * Call to WikiPage function for backwards compatibility.
2259 * @see WikiPage::getMinorEdit
2261 public function getMinorEdit() {
2262 return $this->mPage
->getMinorEdit();
2266 * Call to WikiPage function for backwards compatibility.
2267 * @see WikiPage::getOldestRevision
2269 public function getOldestRevision() {
2270 return $this->mPage
->getOldestRevision();
2274 * Call to WikiPage function for backwards compatibility.
2275 * @see WikiPage::getRedirectTarget
2277 public function getRedirectTarget() {
2278 return $this->mPage
->getRedirectTarget();
2282 * Call to WikiPage function for backwards compatibility.
2283 * @see WikiPage::getRedirectURL
2285 public function getRedirectURL( $rt ) {
2286 return $this->mPage
->getRedirectURL( $rt );
2290 * Call to WikiPage function for backwards compatibility.
2291 * @see WikiPage::getRevision
2293 public function getRevision() {
2294 return $this->mPage
->getRevision();
2298 * Call to WikiPage function for backwards compatibility.
2299 * @see WikiPage::getTimestamp
2301 public function getTimestamp() {
2302 return $this->mPage
->getTimestamp();
2306 * Call to WikiPage function for backwards compatibility.
2307 * @see WikiPage::getTouched
2309 public function getTouched() {
2310 return $this->mPage
->getTouched();
2314 * Call to WikiPage function for backwards compatibility.
2315 * @see WikiPage::getUndoContent
2317 public function getUndoContent( Revision
$undo, Revision
$undoafter = null ) {
2318 return $this->mPage
->getUndoContent( $undo, $undoafter );
2322 * Call to WikiPage function for backwards compatibility.
2323 * @see WikiPage::getUser
2325 public function getUser( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2326 return $this->mPage
->getUser( $audience, $user );
2330 * Call to WikiPage function for backwards compatibility.
2331 * @see WikiPage::getUserText
2333 public function getUserText( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2334 return $this->mPage
->getUserText( $audience, $user );
2338 * Call to WikiPage function for backwards compatibility.
2339 * @see WikiPage::hasViewableContent
2341 public function hasViewableContent() {
2342 return $this->mPage
->hasViewableContent();
2346 * Call to WikiPage function for backwards compatibility.
2347 * @see WikiPage::insertOn
2349 public function insertOn( $dbw, $pageId = null ) {
2350 return $this->mPage
->insertOn( $dbw, $pageId );
2354 * Call to WikiPage function for backwards compatibility.
2355 * @see WikiPage::insertProtectNullRevision
2357 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2358 array $expiry, $cascade, $reason, $user = null
2360 return $this->mPage
->insertProtectNullRevision( $revCommentMsg, $limit,
2361 $expiry, $cascade, $reason, $user
2366 * Call to WikiPage function for backwards compatibility.
2367 * @see WikiPage::insertRedirect
2369 public function insertRedirect() {
2370 return $this->mPage
->insertRedirect();
2374 * Call to WikiPage function for backwards compatibility.
2375 * @see WikiPage::insertRedirectEntry
2377 public function insertRedirectEntry( Title
$rt, $oldLatest = null ) {
2378 return $this->mPage
->insertRedirectEntry( $rt, $oldLatest );
2382 * Call to WikiPage function for backwards compatibility.
2383 * @see WikiPage::isCountable
2385 public function isCountable( $editInfo = false ) {
2386 return $this->mPage
->isCountable( $editInfo );
2390 * Call to WikiPage function for backwards compatibility.
2391 * @see WikiPage::isRedirect
2393 public function isRedirect() {
2394 return $this->mPage
->isRedirect();
2398 * Call to WikiPage function for backwards compatibility.
2399 * @see WikiPage::loadFromRow
2401 public function loadFromRow( $data, $from ) {
2402 return $this->mPage
->loadFromRow( $data, $from );
2406 * Call to WikiPage function for backwards compatibility.
2407 * @see WikiPage::loadPageData
2409 public function loadPageData( $from = 'fromdb' ) {
2410 $this->mPage
->loadPageData( $from );
2414 * Call to WikiPage function for backwards compatibility.
2415 * @see WikiPage::lockAndGetLatest
2417 public function lockAndGetLatest() {
2418 return $this->mPage
->lockAndGetLatest();
2422 * Call to WikiPage function for backwards compatibility.
2423 * @see WikiPage::makeParserOptions
2425 public function makeParserOptions( $context ) {
2426 return $this->mPage
->makeParserOptions( $context );
2430 * Call to WikiPage function for backwards compatibility.
2431 * @see WikiPage::pageDataFromId
2433 public function pageDataFromId( $dbr, $id, $options = [] ) {
2434 return $this->mPage
->pageDataFromId( $dbr, $id, $options );
2438 * Call to WikiPage function for backwards compatibility.
2439 * @see WikiPage::pageDataFromTitle
2441 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2442 return $this->mPage
->pageDataFromTitle( $dbr, $title, $options );
2446 * Call to WikiPage function for backwards compatibility.
2447 * @see WikiPage::prepareContentForEdit
2449 public function prepareContentForEdit(
2450 Content
$content, $revision = null, User
$user = null,
2451 $serialFormat = null, $useCache = true
2453 return $this->mPage
->prepareContentForEdit(
2454 $content, $revision, $user,
2455 $serialFormat, $useCache
2460 * Call to WikiPage function for backwards compatibility.
2461 * @see WikiPage::protectDescription
2463 public function protectDescription( array $limit, array $expiry ) {
2464 return $this->mPage
->protectDescription( $limit, $expiry );
2468 * Call to WikiPage function for backwards compatibility.
2469 * @see WikiPage::protectDescriptionLog
2471 public function protectDescriptionLog( array $limit, array $expiry ) {
2472 return $this->mPage
->protectDescriptionLog( $limit, $expiry );
2476 * Call to WikiPage function for backwards compatibility.
2477 * @see WikiPage::replaceSectionAtRev
2479 public function replaceSectionAtRev( $sectionId, Content
$sectionContent,
2480 $sectionTitle = '', $baseRevId = null
2482 return $this->mPage
->replaceSectionAtRev( $sectionId, $sectionContent,
2483 $sectionTitle, $baseRevId
2488 * Call to WikiPage function for backwards compatibility.
2489 * @see WikiPage::replaceSectionContent
2491 public function replaceSectionContent(
2492 $sectionId, Content
$sectionContent, $sectionTitle = '', $edittime = null
2494 return $this->mPage
->replaceSectionContent(
2495 $sectionId, $sectionContent, $sectionTitle, $edittime
2500 * Call to WikiPage function for backwards compatibility.
2501 * @see WikiPage::setTimestamp
2503 public function setTimestamp( $ts ) {
2504 return $this->mPage
->setTimestamp( $ts );
2508 * Call to WikiPage function for backwards compatibility.
2509 * @see WikiPage::shouldCheckParserCache
2511 public function shouldCheckParserCache( ParserOptions
$parserOptions, $oldId ) {
2512 return $this->mPage
->shouldCheckParserCache( $parserOptions, $oldId );
2516 * Call to WikiPage function for backwards compatibility.
2517 * @see WikiPage::supportsSections
2519 public function supportsSections() {
2520 return $this->mPage
->supportsSections();
2524 * Call to WikiPage function for backwards compatibility.
2525 * @see WikiPage::triggerOpportunisticLinksUpdate
2527 public function triggerOpportunisticLinksUpdate( ParserOutput
$parserOutput ) {
2528 return $this->mPage
->triggerOpportunisticLinksUpdate( $parserOutput );
2532 * Call to WikiPage function for backwards compatibility.
2533 * @see WikiPage::updateCategoryCounts
2535 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2536 return $this->mPage
->updateCategoryCounts( $added, $deleted, $id );
2540 * Call to WikiPage function for backwards compatibility.
2541 * @see WikiPage::updateIfNewerOn
2543 public function updateIfNewerOn( $dbw, $revision ) {
2544 return $this->mPage
->updateIfNewerOn( $dbw, $revision );
2548 * Call to WikiPage function for backwards compatibility.
2549 * @see WikiPage::updateRedirectOn
2551 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2552 return $this->mPage
->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null );
2556 * Call to WikiPage function for backwards compatibility.
2557 * @see WikiPage::updateRevisionOn
2559 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2560 $lastRevIsRedirect = null
2562 return $this->mPage
->updateRevisionOn( $dbw, $revision, $lastRevision,
2568 * @param array $limit
2569 * @param array $expiry
2570 * @param bool &$cascade
2571 * @param string $reason
2575 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2578 return $this->mPage
->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2582 * @param array $limit
2583 * @param string $reason
2584 * @param int &$cascade
2585 * @param array $expiry
2588 public function updateRestrictions( $limit = [], $reason = '',
2589 &$cascade = 0, $expiry = []
2591 return $this->mPage
->doUpdateRestrictions(
2596 $this->getContext()->getUser()
2601 * @param string $reason
2602 * @param bool $suppress
2603 * @param int $u1 Unused
2604 * @param bool $u2 Unused
2605 * @param string &$error
2608 public function doDeleteArticle(
2609 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2611 return $this->mPage
->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2615 * @param string $fromP
2616 * @param string $summary
2617 * @param string $token
2619 * @param array &$resultDetails
2620 * @param User|null $user
2623 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User
$user = null ) {
2624 $user = is_null( $user ) ?
$this->getContext()->getUser() : $user;
2625 return $this->mPage
->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2629 * @param string $fromP
2630 * @param string $summary
2632 * @param array &$resultDetails
2633 * @param User|null $guser
2636 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User
$guser = null ) {
2637 $guser = is_null( $guser ) ?
$this->getContext()->getUser() : $guser;
2638 return $this->mPage
->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2642 * @param bool &$hasHistory
2645 public function generateReason( &$hasHistory ) {
2646 $title = $this->mPage
->getTitle();
2647 $handler = ContentHandler
::getForTitle( $title );
2648 return $handler->getAutoDeleteReason( $title, $hasHistory );
2654 * @deprecated since 1.24, use WikiPage::selectFields() instead
2656 public static function selectFields() {
2657 wfDeprecated( __METHOD__
, '1.24' );
2658 return WikiPage
::selectFields();
2662 * @param Title $title
2664 * @deprecated since 1.24, use WikiPage::onArticleCreate() instead
2666 public static function onArticleCreate( $title ) {
2667 wfDeprecated( __METHOD__
, '1.24' );
2668 WikiPage
::onArticleCreate( $title );
2672 * @param Title $title
2674 * @deprecated since 1.24, use WikiPage::onArticleDelete() instead
2676 public static function onArticleDelete( $title ) {
2677 wfDeprecated( __METHOD__
, '1.24' );
2678 WikiPage
::onArticleDelete( $title );
2682 * @param Title $title
2684 * @deprecated since 1.24, use WikiPage::onArticleEdit() instead
2686 public static function onArticleEdit( $title ) {
2687 wfDeprecated( __METHOD__
, '1.24' );
2688 WikiPage
::onArticleEdit( $title );