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 * @var bool Whether render() was called. With the way subclasses work
80 * here, there doesn't seem to be any other way to stop calling
81 * OutputPage::enableSectionEditLinks() and still have it work as it did before.
83 private $disableSectionEditForRender = false;
86 * Constructor and clear the article
87 * @param Title $title Reference to a Title object.
88 * @param int $oldId Revision ID, null to fetch from request, zero for current
90 public function __construct( Title
$title, $oldId = null ) {
91 $this->mOldId
= $oldId;
92 $this->mPage
= $this->newPage( $title );
99 protected function newPage( Title
$title ) {
100 return new WikiPage( $title );
104 * Constructor from a page id
105 * @param int $id Article ID to load
106 * @return Article|null
108 public static function newFromID( $id ) {
109 $t = Title
::newFromID( $id );
110 return $t == null ?
null : new static( $t );
114 * Create an Article object of the appropriate class for the given page.
116 * @param Title $title
117 * @param IContextSource $context
120 public static function newFromTitle( $title, IContextSource
$context ) {
121 if ( NS_MEDIA
== $title->getNamespace() ) {
122 // FIXME: where should this go?
123 $title = Title
::makeTitle( NS_FILE
, $title->getDBkey() );
127 Hooks
::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
129 switch ( $title->getNamespace() ) {
131 $page = new ImagePage( $title );
134 $page = new CategoryPage( $title );
137 $page = new Article( $title );
140 $page->setContext( $context );
146 * Create an Article object of the appropriate class for the given page.
148 * @param WikiPage $page
149 * @param IContextSource $context
152 public static function newFromWikiPage( WikiPage
$page, IContextSource
$context ) {
153 $article = self
::newFromTitle( $page->getTitle(), $context );
154 $article->mPage
= $page; // override to keep process cached vars
159 * Get the page this view was redirected from
163 public function getRedirectedFrom() {
164 return $this->mRedirectedFrom
;
168 * Tell the page view functions that this view was redirected
169 * from another page on the wiki.
172 public function setRedirectedFrom( Title
$from ) {
173 $this->mRedirectedFrom
= $from;
177 * Get the title object of the article
179 * @return Title Title object of this page
181 public function getTitle() {
182 return $this->mPage
->getTitle();
186 * Get the WikiPage object of this instance
191 public function getPage() {
198 public function clear() {
199 $this->mContentLoaded
= false;
201 $this->mRedirectedFrom
= null; # Title object if set
202 $this->mRevIdFetched
= 0;
203 $this->mRedirectUrl
= false;
205 $this->mPage
->clear();
209 * Returns a Content object representing the pages effective display content,
210 * not necessarily the revision's content!
212 * Note that getContent does not follow redirects anymore.
213 * If you need to fetch redirectable content easily, try
214 * the shortcut in WikiPage::getRedirectTarget()
216 * This function has side effects! Do not use this function if you
217 * only want the real revision text if any.
219 * @return Content Return the content of this revision
223 protected function getContentObject() {
224 if ( $this->mPage
->getId() === 0 ) {
225 # If this is a MediaWiki:x message, then load the messages
226 # and return the message value for x.
227 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI
) {
228 $text = $this->getTitle()->getDefaultMessageText();
229 if ( $text === false ) {
233 $content = ContentHandler
::makeContent( $text, $this->getTitle() );
235 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
236 $content = new MessageContent( $message, null, 'parsemag' );
239 $this->fetchContentObject();
240 $content = $this->mContentObject
;
247 * @return int The oldid of the article that is to be shown, 0 for the current revision
249 public function getOldID() {
250 if ( is_null( $this->mOldId
) ) {
251 $this->mOldId
= $this->getOldIDFromRequest();
254 return $this->mOldId
;
258 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
260 * @return int The old id for the request
262 public function getOldIDFromRequest() {
263 $this->mRedirectUrl
= false;
265 $request = $this->getContext()->getRequest();
266 $oldid = $request->getIntOrNull( 'oldid' );
268 if ( $oldid === null ) {
272 if ( $oldid !== 0 ) {
273 # Load the given revision and check whether the page is another one.
274 # In that case, update this instance to reflect the change.
275 if ( $oldid === $this->mPage
->getLatest() ) {
276 $this->mRevision
= $this->mPage
->getRevision();
278 $this->mRevision
= Revision
::newFromId( $oldid );
279 if ( $this->mRevision
!== null ) {
280 // Revision title doesn't match the page title given?
281 if ( $this->mPage
->getId() != $this->mRevision
->getPage() ) {
282 $function = [ get_class( $this->mPage
), 'newFromID' ];
283 $this->mPage
= call_user_func( $function, $this->mRevision
->getPage() );
289 if ( $request->getVal( 'direction' ) == 'next' ) {
290 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
293 $this->mRevision
= null;
295 $this->mRedirectUrl
= $this->getTitle()->getFullURL( 'redirect=no' );
297 } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
298 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
301 $this->mRevision
= null;
309 * Get text content object
310 * Does *NOT* follow redirects.
311 * @todo When is this null?
313 * @note Code that wants to retrieve page content from the database should
314 * use WikiPage::getContent().
316 * @return Content|null|bool
320 protected function fetchContentObject() {
321 if ( $this->mContentLoaded
) {
322 return $this->mContentObject
;
325 $this->mContentLoaded
= true;
326 $this->mContent
= null;
328 $oldid = $this->getOldID();
330 # Pre-fill content with error message so that if something
331 # fails we'll have something telling us what we intended.
332 // XXX: this isn't page content but a UI message. horrible.
333 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
336 # $this->mRevision might already be fetched by getOldIDFromRequest()
337 if ( !$this->mRevision
) {
338 $this->mRevision
= Revision
::newFromId( $oldid );
339 if ( !$this->mRevision
) {
340 wfDebug( __METHOD__
. " failed to retrieve specified revision, id $oldid\n" );
345 $oldid = $this->mPage
->getLatest();
347 wfDebug( __METHOD__
. " failed to find page data for title " .
348 $this->getTitle()->getPrefixedText() . "\n" );
352 # Update error message with correct oldid
353 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
355 $this->mRevision
= $this->mPage
->getRevision();
357 if ( !$this->mRevision
) {
358 wfDebug( __METHOD__
. " failed to retrieve current page, rev_id $oldid\n" );
363 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
364 // We should instead work with the Revision object when we need it...
365 // Loads if user is allowed
366 $content = $this->mRevision
->getContent(
367 Revision
::FOR_THIS_USER
,
368 $this->getContext()->getUser()
372 wfDebug( __METHOD__
. " failed to retrieve content of revision " .
373 $this->mRevision
->getId() . "\n" );
377 $this->mContentObject
= $content;
378 $this->mRevIdFetched
= $this->mRevision
->getId();
380 // Avoid PHP 7.1 warning of passing $this by reference
381 $articlePage = $this;
384 'ArticleAfterFetchContentObject',
385 [ &$articlePage, &$this->mContentObject
]
388 return $this->mContentObject
;
392 * Returns true if the currently-referenced revision is the current edit
393 * to this page (and it exists).
396 public function isCurrent() {
397 # If no oldid, this is the current version.
398 if ( $this->getOldID() == 0 ) {
402 return $this->mPage
->exists() && $this->mRevision
&& $this->mRevision
->isCurrent();
406 * Get the fetched Revision object depending on request parameters or null
410 * @return Revision|null
412 public function getRevisionFetched() {
413 $this->fetchContentObject();
415 return $this->mRevision
;
419 * Use this to fetch the rev ID used on page views
421 * @return int Revision ID of last article revision
423 public function getRevIdFetched() {
424 if ( $this->mRevIdFetched
) {
425 return $this->mRevIdFetched
;
427 return $this->mPage
->getLatest();
432 * This is the default action of the index.php entry point: just view the
433 * page of the given title.
435 public function view() {
436 global $wgUseFileCache, $wgDebugToolbar;
438 # Get variables from query string
439 # As side effect this will load the revision and update the title
440 # in a revision ID is passed in the request, so this should remain
441 # the first call of this method even if $oldid is used way below.
442 $oldid = $this->getOldID();
444 $user = $this->getContext()->getUser();
445 # Another whitelist check in case getOldID() is altering the title
446 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
447 if ( count( $permErrors ) ) {
448 wfDebug( __METHOD__
. ": denied on secondary read check\n" );
449 throw new PermissionsError( 'read', $permErrors );
452 $outputPage = $this->getContext()->getOutput();
453 # getOldID() may as well want us to redirect somewhere else
454 if ( $this->mRedirectUrl
) {
455 $outputPage->redirect( $this->mRedirectUrl
);
456 wfDebug( __METHOD__
. ": redirecting due to oldid\n" );
461 # If we got diff in the query, we want to see a diff page instead of the article.
462 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
463 wfDebug( __METHOD__
. ": showing diff page\n" );
464 $this->showDiffPage();
469 # Set page title (may be overridden by DISPLAYTITLE)
470 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
472 $outputPage->setArticleFlag( true );
473 # Allow frames by default
474 $outputPage->allowClickjacking();
476 $parserCache = MediaWikiServices
::getInstance()->getParserCache();
478 $parserOptions = $this->getParserOptions();
480 # Render printable version, use printable version cache
481 if ( $outputPage->isPrintable() ) {
482 $parserOptions->setIsPrintable( true );
483 $poOptions['enableSectionEditLinks'] = false;
484 } elseif ( $this->disableSectionEditForRender
485 ||
!$this->isCurrent() ||
!$this->getTitle()->quickUserCan( 'edit', $user )
487 $poOptions['enableSectionEditLinks'] = false;
490 # Try client and file cache
491 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage
->checkTouched() ) {
492 # Try to stream the output from file cache
493 if ( $wgUseFileCache && $this->tryFileCache() ) {
494 wfDebug( __METHOD__
. ": done file cache\n" );
495 # tell wgOut that output is taken care of
496 $outputPage->disable();
497 $this->mPage
->doViewUpdates( $user, $oldid );
503 # Should the parser cache be used?
504 $useParserCache = $this->mPage
->shouldCheckParserCache( $parserOptions, $oldid );
505 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ?
'yes' : 'no' ) . "\n" );
506 if ( $user->getStubThreshold() ) {
507 MediaWikiServices
::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
510 $this->showRedirectedFromHeader();
511 $this->showNamespaceHeader();
513 # Iterate through the possible ways of constructing the output text.
514 # Keep going until $outputDone is set, or we run out of things to do.
517 $this->mParserOutput
= false;
519 while ( !$outputDone && ++
$pass ) {
522 // Avoid PHP 7.1 warning of passing $this by reference
523 $articlePage = $this;
524 Hooks
::run( 'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
527 # Early abort if the page doesn't exist
528 if ( !$this->mPage
->exists() ) {
529 wfDebug( __METHOD__
. ": showing missing article\n" );
530 $this->showMissingArticle();
531 $this->mPage
->doViewUpdates( $user );
535 # Try the parser cache
536 if ( $useParserCache ) {
537 $this->mParserOutput
= $parserCache->get( $this->mPage
, $parserOptions );
539 if ( $this->mParserOutput
!== false ) {
541 wfDebug( __METHOD__
. ": showing parser cache contents for current rev permalink\n" );
542 $this->setOldSubtitle( $oldid );
544 wfDebug( __METHOD__
. ": showing parser cache contents\n" );
546 $outputPage->addParserOutput( $this->mParserOutput
, $poOptions );
547 # Ensure that UI elements requiring revision ID have
548 # the correct version information.
549 $outputPage->setRevisionId( $this->mPage
->getLatest() );
550 # Preload timestamp to avoid a DB hit
551 $cachedTimestamp = $this->mParserOutput
->getTimestamp();
552 if ( $cachedTimestamp !== null ) {
553 $outputPage->setRevisionTimestamp( $cachedTimestamp );
554 $this->mPage
->setTimestamp( $cachedTimestamp );
561 # This will set $this->mRevision if needed
562 $this->fetchContentObject();
564 # Are we looking at an old revision
565 if ( $oldid && $this->mRevision
) {
566 $this->setOldSubtitle( $oldid );
568 if ( !$this->showDeletedRevisionHeader() ) {
569 wfDebug( __METHOD__
. ": cannot view deleted revision\n" );
574 # Ensure that UI elements requiring revision ID have
575 # the correct version information.
576 $outputPage->setRevisionId( $this->getRevIdFetched() );
577 # Preload timestamp to avoid a DB hit
578 $outputPage->setRevisionTimestamp( $this->mPage
->getTimestamp() );
580 # Pages containing custom CSS or JavaScript get special treatment
581 if ( $this->getTitle()->isSiteConfigPage() ||
$this->getTitle()->isUserConfigPage() ) {
582 $dir = $this->getContext()->getLanguage()->getDir();
583 $lang = $this->getContext()->getLanguage()->getHtmlCode();
585 $outputPage->wrapWikiMsg(
586 "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
589 } elseif ( !Hooks
::run( 'ArticleContentViewCustom',
590 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] )
592 # Allow extensions do their own custom view for certain pages
597 # Run the parse, protected by a pool counter
598 wfDebug( __METHOD__
. ": doing uncached parse\n" );
600 $content = $this->getContentObject();
601 $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
602 $this->getRevIdFetched(), $useParserCache, $content );
604 if ( !$poolArticleView->execute() ) {
605 $error = $poolArticleView->getError();
607 $outputPage->clearHTML(); // for release() errors
608 $outputPage->enableClientCache( false );
609 $outputPage->setRobotPolicy( 'noindex,nofollow' );
611 $errortext = $error->getWikiText( false, 'view-pool-error' );
612 $outputPage->addWikiText( Html
::errorBox( $errortext ) );
614 # Connection or timeout error
618 $this->mParserOutput
= $poolArticleView->getParserOutput();
619 $outputPage->addParserOutput( $this->mParserOutput
, $poOptions );
620 if ( $content->getRedirectTarget() ) {
621 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
622 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
625 # Don't cache a dirty ParserOutput object
626 if ( $poolArticleView->getIsDirty() ) {
627 $outputPage->setCdnMaxage( 0 );
628 $outputPage->addHTML( "<!-- parser cache is expired, " .
629 "sending anyway due to pool overload-->\n" );
634 # Should be unreachable, but just in case...
640 # Get the ParserOutput actually *displayed* here.
641 # Note that $this->mParserOutput is the *current*/oldid version output.
642 $pOutput = ( $outputDone instanceof ParserOutput
)
643 ?
$outputDone // object fetched by hook
644 : $this->mParserOutput
;
646 # Adjust title for main page & pages with displaytitle
648 $this->adjustDisplayTitle( $pOutput );
651 # For the main page, overwrite the <title> element with the con-
652 # tents of 'pagetitle-view-mainpage' instead of the default (if
654 # This message always exists because it is in the i18n files
655 if ( $this->getTitle()->isMainPage() ) {
656 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
657 if ( !$msg->isDisabled() ) {
658 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
662 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
663 # This could use getTouched(), but that could be scary for major template edits.
664 $outputPage->adaptCdnTTL( $this->mPage
->getTimestamp(), IExpiringStore
::TTL_DAY
);
666 # Check for any __NOINDEX__ tags on the page using $pOutput
667 $policy = $this->getRobotPolicy( 'view', $pOutput );
668 $outputPage->setIndexPolicy( $policy['index'] );
669 $outputPage->setFollowPolicy( $policy['follow'] );
671 $this->showViewFooter();
672 $this->mPage
->doViewUpdates( $user, $oldid );
674 # Load the postEdit module if the user just saved this revision
675 # See also EditPage::setPostEditCookie
676 $request = $this->getContext()->getRequest();
677 $cookieKey = EditPage
::POST_EDIT_COOKIE_KEY_PREFIX
. $this->getRevIdFetched();
678 $postEdit = $request->getCookie( $cookieKey );
680 # Clear the cookie. This also prevents caching of the response.
681 $request->response()->clearCookie( $cookieKey );
682 $outputPage->addJsConfigVars( 'wgPostEdit', $postEdit );
683 $outputPage->addModules( 'mediawiki.action.view.postEdit' );
688 * Adjust title for pages with displaytitle, -{T|}- or language conversion
689 * @param ParserOutput $pOutput
691 public function adjustDisplayTitle( ParserOutput
$pOutput ) {
692 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
693 $titleText = $pOutput->getTitleText();
694 if ( strval( $titleText ) !== '' ) {
695 $this->getContext()->getOutput()->setPageTitle( $titleText );
700 * Show a diff page according to current request variables. For use within
701 * Article::view() only, other callers should use the DifferenceEngine class.
703 protected function showDiffPage() {
704 $request = $this->getContext()->getRequest();
705 $user = $this->getContext()->getUser();
706 $diff = $request->getVal( 'diff' );
707 $rcid = $request->getVal( 'rcid' );
708 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
709 $purge = $request->getVal( 'action' ) == 'purge';
710 $unhide = $request->getInt( 'unhide' ) == 1;
711 $oldid = $this->getOldID();
713 $rev = $this->getRevisionFetched();
716 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
717 $msg = $this->getContext()->msg( 'difference-missing-revision' )
721 $this->getContext()->getOutput()->addHTML( $msg );
725 $contentHandler = $rev->getContentHandler();
726 $de = $contentHandler->createDifferenceEngine(
735 // DifferenceEngine directly fetched the revision:
736 $this->mRevIdFetched
= $de->mNewid
;
737 $de->showDiffPage( $diffOnly );
739 // Run view updates for the newer revision being diffed (and shown
740 // below the diff if not $diffOnly).
741 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
742 // New can be false, convert it to 0 - this conveniently means the latest revision
743 $this->mPage
->doViewUpdates( $user, (int)$new );
747 * Get the robot policy to be used for the current view
748 * @param string $action The action= GET parameter
749 * @param ParserOutput|null $pOutput
750 * @return array The policy that should be set
751 * @todo actions other than 'view'
753 public function getRobotPolicy( $action, $pOutput = null ) {
754 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
756 $ns = $this->getTitle()->getNamespace();
758 # Don't index user and user talk pages for blocked users (T13443)
759 if ( ( $ns == NS_USER ||
$ns == NS_USER_TALK
) && !$this->getTitle()->isSubpage() ) {
760 $specificTarget = null;
762 $titleText = $this->getTitle()->getText();
763 if ( IP
::isValid( $titleText ) ) {
764 $vagueTarget = $titleText;
766 $specificTarget = $titleText;
768 if ( Block
::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block
) {
770 'index' => 'noindex',
771 'follow' => 'nofollow'
776 if ( $this->mPage
->getId() === 0 ||
$this->getOldID() ) {
777 # Non-articles (special pages etc), and old revisions
779 'index' => 'noindex',
780 'follow' => 'nofollow'
782 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
783 # Discourage indexing of printable versions, but encourage following
785 'index' => 'noindex',
788 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
789 # For ?curid=x urls, disallow indexing
791 'index' => 'noindex',
796 # Otherwise, construct the policy based on the various config variables.
797 $policy = self
::formatRobotPolicy( $wgDefaultRobotPolicy );
799 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
800 # Honour customised robot policies for this namespace
801 $policy = array_merge(
803 self
::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
806 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
807 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
808 # a final sanity check that we have really got the parser output.
809 $policy = array_merge(
811 [ 'index' => $pOutput->getIndexPolicy() ]
815 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
816 # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
817 $policy = array_merge(
819 self
::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
827 * Converts a String robot policy into an associative array, to allow
828 * merging of several policies using array_merge().
829 * @param array|string $policy Returns empty array on null/false/'', transparent
830 * to already-converted arrays, converts string.
831 * @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
833 public static function formatRobotPolicy( $policy ) {
834 if ( is_array( $policy ) ) {
836 } elseif ( !$policy ) {
840 $policy = explode( ',', $policy );
841 $policy = array_map( 'trim', $policy );
844 foreach ( $policy as $var ) {
845 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
846 $arr['index'] = $var;
847 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
848 $arr['follow'] = $var;
856 * If this request is a redirect view, send "redirected from" subtitle to
857 * the output. Returns true if the header was needed, false if this is not
858 * a redirect view. Handles both local and remote redirects.
862 public function showRedirectedFromHeader() {
863 global $wgRedirectSources;
865 $context = $this->getContext();
866 $outputPage = $context->getOutput();
867 $request = $context->getRequest();
868 $rdfrom = $request->getVal( 'rdfrom' );
870 // Construct a URL for the current page view, but with the target title
871 $query = $request->getValues();
872 unset( $query['rdfrom'] );
873 unset( $query['title'] );
874 if ( $this->getTitle()->isRedirect() ) {
875 // Prevent double redirects
876 $query['redirect'] = 'no';
878 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
880 if ( isset( $this->mRedirectedFrom
) ) {
881 // Avoid PHP 7.1 warning of passing $this by reference
882 $articlePage = $this;
884 // This is an internally redirected page view.
885 // We'll need a backlink to the source page for navigation.
886 if ( Hooks
::run( 'ArticleViewRedirect', [ &$articlePage ] ) ) {
887 $redir = Linker
::linkKnown(
888 $this->mRedirectedFrom
,
891 [ 'redirect' => 'no' ]
894 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
895 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
898 // Add the script to update the displayed URL and
899 // set the fragment if one was specified in the redirect
900 $outputPage->addJsConfigVars( [
901 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
903 $outputPage->addModules( 'mediawiki.action.view.redirect' );
905 // Add a <link rel="canonical"> tag
906 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
908 // Tell the output object that the user arrived at this article through a redirect
909 $outputPage->setRedirectedFrom( $this->mRedirectedFrom
);
913 } elseif ( $rdfrom ) {
914 // This is an externally redirected view, from some other wiki.
915 // If it was reported from a trusted site, supply a backlink.
916 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
917 $redir = Linker
::makeExternalLink( $rdfrom, $rdfrom );
918 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
919 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
922 // Add the script to update the displayed URL
923 $outputPage->addJsConfigVars( [
924 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
926 $outputPage->addModules( 'mediawiki.action.view.redirect' );
936 * Show a header specific to the namespace currently being viewed, like
937 * [[MediaWiki:Talkpagetext]]. For Article::view().
939 public function showNamespaceHeader() {
940 if ( $this->getTitle()->isTalkPage() ) {
941 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
942 $this->getContext()->getOutput()->wrapWikiMsg(
943 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
951 * Show the footer section of an ordinary page view
953 public function showViewFooter() {
954 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
955 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
956 && IP
::isValid( $this->getTitle()->getText() )
958 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
961 // Show a footer allowing the user to patrol the shown revision or page if possible
962 $patrolFooterShown = $this->showPatrolFooter();
964 Hooks
::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
968 * If patrol is possible, output a patrol UI box. This is called from the
969 * footer section of ordinary page views. If patrol is not possible or not
970 * desired, does nothing.
971 * Side effect: When the patrol link is build, this method will call
972 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
976 public function showPatrolFooter() {
977 global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
979 $outputPage = $this->getContext()->getOutput();
980 $user = $this->getContext()->getUser();
981 $title = $this->getTitle();
984 if ( !$title->quickUserCan( 'patrol', $user )
985 ||
!( $wgUseRCPatrol ||
$wgUseNPPatrol
986 ||
( $wgUseFilePatrol && $title->inNamespace( NS_FILE
) ) )
988 // Patrolling is disabled or the user isn't allowed to
992 if ( $this->mRevision
993 && !RecentChange
::isInRCLifespan( $this->mRevision
->getTimestamp(), 21600 )
995 // The current revision is already older than what could be in the RC table
996 // 6h tolerance because the RC might not be cleaned out regularly
1000 // Check for cached results
1001 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
1002 $key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() );
1003 if ( $cache->get( $key ) ) {
1007 $dbr = wfGetDB( DB_REPLICA
);
1008 $oldestRevisionTimestamp = $dbr->selectField(
1010 'MIN( rev_timestamp )',
1011 [ 'rev_page' => $title->getArticleID() ],
1015 // New page patrol: Get the timestamp of the oldest revison which
1016 // the revision table holds for the given page. Then we look
1017 // whether it's within the RC lifespan and if it is, we try
1018 // to get the recentchanges row belonging to that entry
1019 // (with rc_new = 1).
1020 $recentPageCreation = false;
1021 if ( $oldestRevisionTimestamp
1022 && RecentChange
::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
1024 // 6h tolerance because the RC might not be cleaned out regularly
1025 $recentPageCreation = true;
1026 $rc = RecentChange
::newFromConds(
1029 'rc_timestamp' => $oldestRevisionTimestamp,
1030 'rc_namespace' => $title->getNamespace(),
1031 'rc_cur_id' => $title->getArticleID()
1036 // Use generic patrol message for new pages
1037 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1041 // File patrol: Get the timestamp of the latest upload for this page,
1042 // check whether it is within the RC lifespan and if it is, we try
1043 // to get the recentchanges row belonging to that entry
1044 // (with rc_type = RC_LOG, rc_log_type = upload).
1045 $recentFileUpload = false;
1046 if ( ( !$rc ||
$rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1047 && $title->getNamespace() === NS_FILE
) {
1048 // Retrieve timestamp of most recent upload
1049 $newestUploadTimestamp = $dbr->selectField(
1051 'MAX( img_timestamp )',
1052 [ 'img_name' => $title->getDBkey() ],
1055 if ( $newestUploadTimestamp
1056 && RecentChange
::isInRCLifespan( $newestUploadTimestamp, 21600 )
1058 // 6h tolerance because the RC might not be cleaned out regularly
1059 $recentFileUpload = true;
1060 $rc = RecentChange
::newFromConds(
1062 'rc_type' => RC_LOG
,
1063 'rc_log_type' => 'upload',
1064 'rc_timestamp' => $newestUploadTimestamp,
1065 'rc_namespace' => NS_FILE
,
1066 'rc_cur_id' => $title->getArticleID()
1069 [ 'USE INDEX' => 'rc_timestamp' ]
1072 // Use patrol message specific to files
1073 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1078 if ( !$recentPageCreation && !$recentFileUpload ) {
1079 // Page creation and latest upload (for files) is too old to be in RC
1081 // We definitely can't patrol so cache the information
1082 // When a new file version is uploaded, the cache is cleared
1083 $cache->set( $key, '1' );
1089 // Don't cache: This can be hit if the page gets accessed very fast after
1090 // its creation / latest upload or in case we have high replica DB lag. In case
1091 // the revision is too old, we will already return above.
1095 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1096 // Patrolled RC entry around
1098 // Cache the information we gathered above in case we can't patrol
1099 // Don't cache in case we can patrol as this could change
1100 $cache->set( $key, '1' );
1105 if ( $rc->getPerformer()->equals( $user ) ) {
1106 // Don't show a patrol link for own creations/uploads. If the user could
1107 // patrol them, they already would be patrolled
1111 $outputPage->preventClickjacking();
1112 if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
1113 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1116 $link = Linker
::linkKnown(
1118 $markPatrolledMsg->escaped(),
1121 'action' => 'markpatrolled',
1122 'rcid' => $rc->getAttribute( 'rc_id' ),
1126 $outputPage->addHTML(
1127 "<div class='patrollink' data-mw='interface'>" .
1128 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1136 * Purge the cache used to check if it is worth showing the patrol footer
1137 * For example, it is done during re-uploads when file patrol is used.
1138 * @param int $articleID ID of the article to purge
1141 public static function purgePatrolFooterCache( $articleID ) {
1142 $cache = MediaWikiServices
::getInstance()->getMainWANObjectCache();
1143 $cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) );
1147 * Show the error text for a missing article. For articles in the MediaWiki
1148 * namespace, show the default message text. To be called from Article::view().
1150 public function showMissingArticle() {
1151 global $wgSend404Code;
1153 $outputPage = $this->getContext()->getOutput();
1154 // Whether the page is a root user page of an existing user (but not a subpage)
1155 $validUserPage = false;
1157 $title = $this->getTitle();
1159 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1160 if ( $title->getNamespace() == NS_USER
1161 ||
$title->getNamespace() == NS_USER_TALK
1163 $rootPart = explode( '/', $title->getText() )[0];
1164 $user = User
::newFromName( $rootPart, false /* allow IP users */ );
1165 $ip = User
::isIP( $rootPart );
1166 $block = Block
::newFromTarget( $user, $user );
1168 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1169 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1170 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1171 } elseif ( !is_null( $block ) && $block->getType() != Block
::TYPE_AUTO
) {
1172 # Show log extract if the user is currently blocked
1173 LogEventsList
::showLogExtract(
1176 MWNamespace
::getCanonicalName( NS_USER
) . ':' . $block->getTarget(),
1180 'showIfEmpty' => false,
1182 'blocked-notice-logextract',
1183 $user->getName() # Support GENDER in notice
1187 $validUserPage = !$title->isSubpage();
1189 $validUserPage = !$title->isSubpage();
1193 Hooks
::run( 'ShowMissingArticle', [ $this ] );
1195 # Show delete and move logs if there were any such events.
1196 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1197 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1198 $cache = MediaWikiServices
::getInstance()->getMainObjectStash();
1199 $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1200 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1201 $sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
1202 if ( $loggedIn ||
$cache->get( $key ) ||
$sessionExists ) {
1203 $logTypes = [ 'delete', 'move', 'protect' ];
1205 $dbr = wfGetDB( DB_REPLICA
);
1207 $conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
1208 // Give extensions a chance to hide their (unrelated) log entries
1209 Hooks
::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1210 LogEventsList
::showLogExtract(
1218 'showIfEmpty' => false,
1219 'msgKey' => [ $loggedIn ||
$sessionExists
1220 ?
'moveddeleted-notice'
1221 : 'moveddeleted-notice-recent'
1227 if ( !$this->mPage
->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1228 // If there's no backing content, send a 404 Not Found
1229 // for better machine handling of broken links.
1230 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1233 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1234 $policy = $this->getRobotPolicy( 'view' );
1235 $outputPage->setIndexPolicy( $policy['index'] );
1236 $outputPage->setFollowPolicy( $policy['follow'] );
1238 $hookResult = Hooks
::run( 'BeforeDisplayNoArticleText', [ $this ] );
1240 if ( !$hookResult ) {
1244 # Show error message
1245 $oldid = $this->getOldID();
1246 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI
&& $title->hasSourceText() ) {
1247 $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
1250 $text = wfMessage( 'missing-revision', $oldid )->plain();
1251 } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1252 && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1254 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
1255 $text = wfMessage( $message )->plain();
1257 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1260 $dir = $this->getContext()->getLanguage()->getDir();
1261 $lang = $this->getContext()->getLanguage()->getHtmlCode();
1262 $outputPage->addWikiText( Xml
::openElement( 'div', [
1263 'class' => "noarticletext mw-content-$dir",
1266 ] ) . "\n$text\n</div>" );
1271 * If the revision requested for view is deleted, check permissions.
1272 * Send either an error message or a warning header to the output.
1274 * @return bool True if the view is allowed, false if not.
1276 public function showDeletedRevisionHeader() {
1277 if ( !$this->mRevision
->isDeleted( Revision
::DELETED_TEXT
) ) {
1282 $outputPage = $this->getContext()->getOutput();
1283 $user = $this->getContext()->getUser();
1284 // If the user is not allowed to see it...
1285 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
, $user ) ) {
1286 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1287 'rev-deleted-text-permission' );
1290 // If the user needs to confirm that they want to see it...
1291 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1292 # Give explanation and add a link to view the revision...
1293 $oldid = intval( $this->getOldID() );
1294 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1295 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1296 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1297 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1301 // We are allowed to see...
1303 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1304 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1305 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1312 * Generate the navigation links when browsing through an article revisions
1313 * It shows the information as:
1314 * Revision as of \<date\>; view current revision
1315 * \<- Previous version | Next Version -\>
1317 * @param int $oldid Revision ID of this article revision
1319 public function setOldSubtitle( $oldid = 0 ) {
1320 // Avoid PHP 7.1 warning of passing $this by reference
1321 $articlePage = $this;
1323 if ( !Hooks
::run( 'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1327 $context = $this->getContext();
1328 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1330 # Cascade unhide param in links for easy deletion browsing
1333 $extraParams['unhide'] = 1;
1336 if ( $this->mRevision
&& $this->mRevision
->getId() === $oldid ) {
1337 $revision = $this->mRevision
;
1339 $revision = Revision
::newFromId( $oldid );
1342 $timestamp = $revision->getTimestamp();
1344 $current = ( $oldid == $this->mPage
->getLatest() );
1345 $language = $context->getLanguage();
1346 $user = $context->getUser();
1348 $td = $language->userTimeAndDate( $timestamp, $user );
1349 $tddate = $language->userDate( $timestamp, $user );
1350 $tdtime = $language->userTime( $timestamp, $user );
1352 # Show user links if allowed to see them. If hidden, then show them only if requested...
1353 $userlinks = Linker
::revUserTools( $revision, !$unhide );
1355 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1356 ?
'revision-info-current'
1359 $outputPage = $context->getOutput();
1360 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1361 $context->msg( $infomsg, $td )
1362 ->rawParams( $userlinks )
1363 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1364 ->rawParams( Linker
::revComment( $revision, true, true ) )
1369 ?
$context->msg( 'currentrevisionlink' )->escaped()
1370 : Linker
::linkKnown(
1372 $context->msg( 'currentrevisionlink' )->escaped(),
1377 ?
$context->msg( 'diff' )->escaped()
1378 : Linker
::linkKnown(
1380 $context->msg( 'diff' )->escaped(),
1387 $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1389 ? Linker
::linkKnown(
1391 $context->msg( 'previousrevision' )->escaped(),
1394 'direction' => 'prev',
1398 : $context->msg( 'previousrevision' )->escaped();
1400 ? Linker
::linkKnown(
1402 $context->msg( 'diff' )->escaped(),
1409 : $context->msg( 'diff' )->escaped();
1410 $nextlink = $current
1411 ?
$context->msg( 'nextrevision' )->escaped()
1412 : Linker
::linkKnown(
1414 $context->msg( 'nextrevision' )->escaped(),
1417 'direction' => 'next',
1421 $nextdiff = $current
1422 ?
$context->msg( 'diff' )->escaped()
1423 : Linker
::linkKnown(
1425 $context->msg( 'diff' )->escaped(),
1433 $cdel = Linker
::getRevDeleteLink( $user, $revision, $this->getTitle() );
1434 if ( $cdel !== '' ) {
1438 // the outer div is need for styling the revision info and nav in MobileFrontend
1439 $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1440 "<div id=\"mw-revision-nav\">" . $cdel .
1441 $context->msg( 'revision-nav' )->rawParams(
1442 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1443 )->escaped() . "</div></div>" );
1447 * Return the HTML for the top of a redirect page
1449 * Chances are you should just be using the ParserOutput from
1450 * WikitextContent::getParserOutput instead of calling this for redirects.
1452 * @param Title|array $target Destination(s) to redirect
1453 * @param bool $appendSubtitle [optional]
1454 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1455 * @return string Containing HTML with redirect link
1457 * @deprecated since 1.30
1459 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1460 $lang = $this->getTitle()->getPageLanguage();
1461 $out = $this->getContext()->getOutput();
1462 if ( $appendSubtitle ) {
1463 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1465 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1466 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1470 * Return the HTML for the top of a redirect page
1472 * Chances are you should just be using the ParserOutput from
1473 * WikitextContent::getParserOutput instead of calling this for redirects.
1476 * @param Language $lang
1477 * @param Title|array $target Destination(s) to redirect
1478 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1479 * @return string Containing HTML with redirect link
1481 public static function getRedirectHeaderHtml( Language
$lang, $target, $forceKnown = false ) {
1482 if ( !is_array( $target ) ) {
1483 $target = [ $target ];
1486 $html = '<ul class="redirectText">';
1487 /** @var Title $title */
1488 foreach ( $target as $title ) {
1489 $html .= '<li>' . Linker
::link(
1491 htmlspecialchars( $title->getFullText() ),
1493 // Make sure wiki page redirects are not followed
1494 $title->isRedirect() ?
[ 'redirect' => 'no' ] : [],
1495 ( $forceKnown ?
[ 'known', 'noclasses' ] : [] )
1500 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1502 return '<div class="redirectMsg">' .
1503 '<p>' . $redirectToText . '</p>' .
1509 * Adds help link with an icon via page indicators.
1510 * Link target can be overridden by a local message containing a wikilink:
1511 * the message key is: 'namespace-' + namespace number + '-helppage'.
1512 * @param string $to Target MediaWiki.org page title or encoded URL.
1513 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
1516 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1518 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1521 $out = $this->getContext()->getOutput();
1522 if ( !$msg->isDisabled() ) {
1523 $helpUrl = Skin
::makeUrl( $msg->plain() );
1524 $out->addHelpLink( $helpUrl, true );
1526 $out->addHelpLink( $to, $overrideBaseUrl );
1531 * Handle action=render
1533 public function render() {
1534 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1535 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1536 $this->disableSectionEditForRender
= true;
1541 * action=protect handler
1543 public function protect() {
1544 $form = new ProtectionForm( $this );
1549 * action=unprotect handler (alias)
1551 public function unprotect() {
1556 * UI entry point for page deletion
1558 public function delete() {
1559 # This code desperately needs to be totally rewritten
1561 $title = $this->getTitle();
1562 $context = $this->getContext();
1563 $user = $context->getUser();
1564 $request = $context->getRequest();
1567 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1568 if ( count( $permissionErrors ) ) {
1569 throw new PermissionsError( 'delete', $permissionErrors );
1572 # Read-only check...
1573 if ( wfReadOnly() ) {
1574 throw new ReadOnlyError
;
1577 # Better double-check that it hasn't been deleted yet!
1578 $this->mPage
->loadPageData(
1579 $request->wasPosted() ? WikiPage
::READ_LATEST
: WikiPage
::READ_NORMAL
1581 if ( !$this->mPage
->exists() ) {
1582 $deleteLogPage = new LogPage( 'delete' );
1583 $outputPage = $context->getOutput();
1584 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1585 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1586 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1588 $outputPage->addHTML(
1589 Xml
::element( 'h2', null, $deleteLogPage->getName()->text() )
1591 LogEventsList
::showLogExtract(
1600 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1601 $deleteReason = $request->getText( 'wpReason' );
1603 if ( $deleteReasonList == 'other' ) {
1604 $reason = $deleteReason;
1605 } elseif ( $deleteReason != '' ) {
1606 // Entry from drop down menu + additional comment
1607 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1608 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1610 $reason = $deleteReasonList;
1613 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1614 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1616 # Flag to hide all contents of the archived revisions
1617 $suppress = $request->getCheck( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1619 $this->doDelete( $reason, $suppress );
1621 WatchAction
::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1626 // Generate deletion reason
1627 $hasHistory = false;
1630 $reason = $this->generateReason( $hasHistory );
1631 } catch ( Exception
$e ) {
1632 # if a page is horribly broken, we still want to be able to
1633 # delete it. So be lenient about errors here.
1634 wfDebug( "Error while building auto delete summary: $e" );
1639 // If the page has a history, insert a warning
1640 if ( $hasHistory ) {
1641 $title = $this->getTitle();
1643 // The following can use the real revision count as this is only being shown for users
1644 // that can delete this page.
1645 // This, as a side-effect, also makes sure that the following query isn't being run for
1646 // pages with a larger history, unless the user has the 'bigdelete' right
1647 // (and is about to delete this page).
1648 $dbr = wfGetDB( DB_REPLICA
);
1649 $revisions = $edits = (int)$dbr->selectField(
1652 [ 'rev_page' => $title->getArticleID() ],
1656 // @todo FIXME: i18n issue/patchwork message
1657 $context->getOutput()->addHTML(
1658 '<strong class="mw-delete-warning-revisions">' .
1659 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1660 $context->msg( 'word-separator' )->escaped() . Linker
::linkKnown( $title,
1661 $context->msg( 'history' )->escaped(),
1663 [ 'action' => 'history' ] ) .
1667 if ( $title->isBigDeletion() ) {
1668 global $wgDeleteRevisionsLimit;
1669 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1671 'delete-warning-toobig',
1672 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1678 $this->confirmDelete( $reason );
1682 * Output deletion confirmation dialog
1683 * @todo FIXME: Move to another file?
1684 * @param string $reason Prefilled reason
1686 public function confirmDelete( $reason ) {
1687 wfDebug( "Article::confirmDelete\n" );
1689 $title = $this->getTitle();
1690 $ctx = $this->getContext();
1691 $outputPage = $ctx->getOutput();
1692 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1693 $outputPage->addBacklinkSubtitle( $title );
1694 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1695 $outputPage->addModules( 'mediawiki.action.delete' );
1697 $backlinkCache = $title->getBacklinkCache();
1698 if ( $backlinkCache->hasLinks( 'pagelinks' ) ||
$backlinkCache->hasLinks( 'templatelinks' ) ) {
1699 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1700 'deleting-backlinks-warning' );
1703 $subpageQueryLimit = 51;
1704 $subpages = $title->getSubpages( $subpageQueryLimit );
1705 $subpageCount = count( $subpages );
1706 if ( $subpageCount > 0 ) {
1707 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1708 [ 'deleting-subpages-warning', Message
::numParam( $subpageCount ) ] );
1710 $outputPage->addWikiMsg( 'confirmdeletetext' );
1712 Hooks
::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1714 $user = $this->getContext()->getUser();
1715 $checkWatch = $user->getBoolOption( 'watchdeletion' ) ||
$user->isWatched( $title );
1717 $outputPage->enableOOUI();
1719 $options = Xml
::listDropDownOptions(
1720 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->text(),
1721 [ 'other' => $ctx->msg( 'deletereasonotherlist' )->inContentLanguage()->text() ]
1723 $options = Xml
::listDropDownOptionsOoui( $options );
1725 $fields[] = new OOUI\
FieldLayout(
1726 new OOUI\
DropdownInputWidget( [
1727 'name' => 'wpDeleteReasonList',
1728 'inputId' => 'wpDeleteReasonList',
1730 'infusable' => true,
1732 'options' => $options
1735 'label' => $ctx->msg( 'deletecomment' )->text(),
1740 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
1741 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
1742 // Unicode codepoints (or 255 UTF-8 bytes for old schema).
1743 $conf = $this->getContext()->getConfig();
1744 $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD
;
1745 $fields[] = new OOUI\
FieldLayout(
1746 new OOUI\
TextInputWidget( [
1747 'name' => 'wpReason',
1748 'inputId' => 'wpReason',
1750 'maxLength' => $oldCommentSchema ?
255 : CommentStore
::COMMENT_CHARACTER_LIMIT
,
1751 'infusable' => true,
1753 'autofocus' => true,
1756 'label' => $ctx->msg( 'deleteotherreason' )->text(),
1761 if ( $user->isLoggedIn() ) {
1762 $fields[] = new OOUI\
FieldLayout(
1763 new OOUI\
CheckboxInputWidget( [
1764 'name' => 'wpWatch',
1765 'inputId' => 'wpWatch',
1767 'selected' => $checkWatch,
1770 'label' => $ctx->msg( 'watchthis' )->text(),
1771 'align' => 'inline',
1772 'infusable' => true,
1777 if ( $user->isAllowed( 'suppressrevision' ) ) {
1778 $fields[] = new OOUI\
FieldLayout(
1779 new OOUI\
CheckboxInputWidget( [
1780 'name' => 'wpSuppress',
1781 'inputId' => 'wpSuppress',
1785 'label' => $ctx->msg( 'revdelete-suppress' )->text(),
1786 'align' => 'inline',
1787 'infusable' => true,
1792 $fields[] = new OOUI\
FieldLayout(
1793 new OOUI\
ButtonInputWidget( [
1794 'name' => 'wpConfirmB',
1795 'inputId' => 'wpConfirmB',
1797 'value' => $ctx->msg( 'deletepage' )->text(),
1798 'label' => $ctx->msg( 'deletepage' )->text(),
1799 'flags' => [ 'primary', 'destructive' ],
1807 $fieldset = new OOUI\
FieldsetLayout( [
1808 'label' => $ctx->msg( 'delete-legend' )->text(),
1809 'id' => 'mw-delete-table',
1813 $form = new OOUI\
FormLayout( [
1815 'action' => $title->getLocalURL( 'action=delete' ),
1816 'id' => 'deleteconfirm',
1818 $form->appendContent(
1820 new OOUI\
HtmlSnippet(
1821 Html
::hidden( 'wpEditToken', $user->getEditToken( [ 'delete', $title->getPrefixedText() ] ) )
1825 $outputPage->addHTML(
1826 new OOUI\
PanelLayout( [
1827 'classes' => [ 'deletepage-wrapper' ],
1828 'expanded' => false,
1835 if ( $user->isAllowed( 'editinterface' ) ) {
1836 $link = Linker
::linkKnown(
1837 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1838 wfMessage( 'delete-edit-reasonlist' )->escaped(),
1840 [ 'action' => 'edit' ]
1842 $outputPage->addHTML( '<p class="mw-delete-editreasons">' . $link . '</p>' );
1845 $deleteLogPage = new LogPage( 'delete' );
1846 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1847 LogEventsList
::showLogExtract( $outputPage, 'delete', $title );
1851 * Perform a deletion and output success or failure messages
1852 * @param string $reason
1853 * @param bool $suppress
1855 public function doDelete( $reason, $suppress = false ) {
1857 $context = $this->getContext();
1858 $outputPage = $context->getOutput();
1859 $user = $context->getUser();
1860 $status = $this->mPage
->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
1862 if ( $status->isGood() ) {
1863 $deleted = $this->getTitle()->getPrefixedText();
1865 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1866 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1868 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1870 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1872 Hooks
::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
1874 $outputPage->returnToMain( false );
1876 $outputPage->setPageTitle(
1877 wfMessage( 'cannotdelete-title',
1878 $this->getTitle()->getPrefixedText() )
1881 if ( $error == '' ) {
1882 $outputPage->addWikiText(
1883 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1885 $deleteLogPage = new LogPage( 'delete' );
1886 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1888 LogEventsList
::showLogExtract(
1894 $outputPage->addHTML( $error );
1899 /* Caching functions */
1902 * checkLastModified returns true if it has taken care of all
1903 * output to the client that is necessary for this request.
1904 * (that is, it has sent a cached version of the page)
1906 * @return bool True if cached version send, false otherwise
1908 protected function tryFileCache() {
1909 static $called = false;
1912 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1917 if ( $this->isFileCacheable() ) {
1918 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
1919 if ( $cache->isCacheGood( $this->mPage
->getTouched() ) ) {
1920 wfDebug( "Article::tryFileCache(): about to load file\n" );
1921 $cache->loadFromFileCache( $this->getContext() );
1924 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1925 ob_start( [ &$cache, 'saveToFileCache' ] );
1928 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1935 * Check if the page can be cached
1936 * @param int $mode One of the HTMLFileCache::MODE_* constants (since 1.28)
1939 public function isFileCacheable( $mode = HTMLFileCache
::MODE_NORMAL
) {
1942 if ( HTMLFileCache
::useFileCache( $this->getContext(), $mode ) ) {
1943 $cacheable = $this->mPage
->getId()
1944 && !$this->mRedirectedFrom
&& !$this->getTitle()->isRedirect();
1945 // Extension may have reason to disable file caching on some pages.
1947 // Avoid PHP 7.1 warning of passing $this by reference
1948 $articlePage = $this;
1949 $cacheable = Hooks
::run( 'IsFileCacheable', [ &$articlePage ] );
1959 * Lightweight method to get the parser output for a page, checking the parser cache
1960 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1961 * consider, so it's not appropriate to use there.
1963 * @since 1.16 (r52326) for LiquidThreads
1965 * @param int|null $oldid Revision ID or null
1966 * @param User $user The relevant user
1967 * @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
1969 public function getParserOutput( $oldid = null, User
$user = null ) {
1970 // XXX: bypasses mParserOptions and thus setParserOptions()
1972 if ( $user === null ) {
1973 $parserOptions = $this->getParserOptions();
1975 $parserOptions = $this->mPage
->makeParserOptions( $user );
1978 return $this->mPage
->getParserOutput( $parserOptions, $oldid );
1982 * Override the ParserOptions used to render the primary article wikitext.
1984 * @param ParserOptions $options
1985 * @throws MWException If the parser options where already initialized.
1987 public function setParserOptions( ParserOptions
$options ) {
1988 if ( $this->mParserOptions
) {
1989 throw new MWException( "can't change parser options after they have already been set" );
1992 // clone, so if $options is modified later, it doesn't confuse the parser cache.
1993 $this->mParserOptions
= clone $options;
1997 * Get parser options suitable for rendering the primary article wikitext
1998 * @return ParserOptions
2000 public function getParserOptions() {
2001 if ( !$this->mParserOptions
) {
2002 $this->mParserOptions
= $this->mPage
->makeParserOptions( $this->getContext() );
2004 // Clone to allow modifications of the return value without affecting cache
2005 return clone $this->mParserOptions
;
2009 * Sets the context this Article is executed in
2011 * @param IContextSource $context
2014 public function setContext( $context ) {
2015 $this->mContext
= $context;
2019 * Gets the context this Article is executed in
2021 * @return IContextSource
2024 public function getContext() {
2025 if ( $this->mContext
instanceof IContextSource
) {
2026 return $this->mContext
;
2028 wfDebug( __METHOD__
. " called and \$mContext is null. " .
2029 "Return RequestContext::getMain(); for sanity\n" );
2030 return RequestContext
::getMain();
2035 * Use PHP's magic __get handler to handle accessing of
2036 * raw WikiPage fields for backwards compatibility.
2038 * @param string $fname Field name
2041 public function __get( $fname ) {
2042 if ( property_exists( $this->mPage
, $fname ) ) {
2043 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2044 return $this->mPage
->$fname;
2046 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE
);
2050 * Use PHP's magic __set handler to handle setting of
2051 * raw WikiPage fields for backwards compatibility.
2053 * @param string $fname Field name
2054 * @param mixed $fvalue New value
2056 public function __set( $fname, $fvalue ) {
2057 if ( property_exists( $this->mPage
, $fname ) ) {
2058 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2059 $this->mPage
->$fname = $fvalue;
2060 // Note: extensions may want to toss on new fields
2061 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
2062 $this->mPage
->$fname = $fvalue;
2064 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE
);
2069 * Call to WikiPage function for backwards compatibility.
2070 * @see WikiPage::checkFlags
2072 public function checkFlags( $flags ) {
2073 return $this->mPage
->checkFlags( $flags );
2077 * Call to WikiPage function for backwards compatibility.
2078 * @see WikiPage::checkTouched
2080 public function checkTouched() {
2081 return $this->mPage
->checkTouched();
2085 * Call to WikiPage function for backwards compatibility.
2086 * @see WikiPage::clearPreparedEdit
2088 public function clearPreparedEdit() {
2089 $this->mPage
->clearPreparedEdit();
2093 * Call to WikiPage function for backwards compatibility.
2094 * @see WikiPage::doDeleteArticleReal
2096 public function doDeleteArticleReal(
2097 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User
$user = null,
2100 return $this->mPage
->doDeleteArticleReal(
2101 $reason, $suppress, $u1, $u2, $error, $user, $tags
2106 * Call to WikiPage function for backwards compatibility.
2107 * @see WikiPage::doDeleteUpdates
2109 public function doDeleteUpdates( $id, Content
$content = null ) {
2110 return $this->mPage
->doDeleteUpdates( $id, $content );
2114 * Call to WikiPage function for backwards compatibility.
2115 * @deprecated since 1.29. Use WikiPage::doEditContent() directly instead
2116 * @see WikiPage::doEditContent
2118 public function doEditContent( Content
$content, $summary, $flags = 0, $baseRevId = false,
2119 User
$user = null, $serialFormat = null
2121 wfDeprecated( __METHOD__
, '1.29' );
2122 return $this->mPage
->doEditContent( $content, $summary, $flags, $baseRevId,
2123 $user, $serialFormat
2128 * Call to WikiPage function for backwards compatibility.
2129 * @see WikiPage::doEditUpdates
2131 public function doEditUpdates( Revision
$revision, User
$user, array $options = [] ) {
2132 return $this->mPage
->doEditUpdates( $revision, $user, $options );
2136 * Call to WikiPage function for backwards compatibility.
2137 * @see WikiPage::doPurge
2138 * @note In 1.28 (and only 1.28), this took a $flags parameter that
2139 * controlled how much purging was done.
2141 public function doPurge() {
2142 return $this->mPage
->doPurge();
2146 * Call to WikiPage function for backwards compatibility.
2147 * @see WikiPage::doViewUpdates
2149 public function doViewUpdates( User
$user, $oldid = 0 ) {
2150 $this->mPage
->doViewUpdates( $user, $oldid );
2154 * Call to WikiPage function for backwards compatibility.
2155 * @see WikiPage::exists
2157 public function exists() {
2158 return $this->mPage
->exists();
2162 * Call to WikiPage function for backwards compatibility.
2163 * @see WikiPage::followRedirect
2165 public function followRedirect() {
2166 return $this->mPage
->followRedirect();
2170 * Call to WikiPage function for backwards compatibility.
2171 * @see ContentHandler::getActionOverrides
2173 public function getActionOverrides() {
2174 return $this->mPage
->getActionOverrides();
2178 * Call to WikiPage function for backwards compatibility.
2179 * @see WikiPage::getAutoDeleteReason
2181 public function getAutoDeleteReason( &$hasHistory ) {
2182 return $this->mPage
->getAutoDeleteReason( $hasHistory );
2186 * Call to WikiPage function for backwards compatibility.
2187 * @see WikiPage::getCategories
2189 public function getCategories() {
2190 return $this->mPage
->getCategories();
2194 * Call to WikiPage function for backwards compatibility.
2195 * @see WikiPage::getComment
2197 public function getComment( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2198 return $this->mPage
->getComment( $audience, $user );
2202 * Call to WikiPage function for backwards compatibility.
2203 * @see WikiPage::getContentHandler
2205 public function getContentHandler() {
2206 return $this->mPage
->getContentHandler();
2210 * Call to WikiPage function for backwards compatibility.
2211 * @see WikiPage::getContentModel
2213 public function getContentModel() {
2214 return $this->mPage
->getContentModel();
2218 * Call to WikiPage function for backwards compatibility.
2219 * @see WikiPage::getContributors
2221 public function getContributors() {
2222 return $this->mPage
->getContributors();
2226 * Call to WikiPage function for backwards compatibility.
2227 * @see WikiPage::getCreator
2229 public function getCreator( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2230 return $this->mPage
->getCreator( $audience, $user );
2234 * Call to WikiPage function for backwards compatibility.
2235 * @see WikiPage::getDeletionUpdates
2237 public function getDeletionUpdates( Content
$content = null ) {
2238 return $this->mPage
->getDeletionUpdates( $content );
2242 * Call to WikiPage function for backwards compatibility.
2243 * @see WikiPage::getHiddenCategories
2245 public function getHiddenCategories() {
2246 return $this->mPage
->getHiddenCategories();
2250 * Call to WikiPage function for backwards compatibility.
2251 * @see WikiPage::getId
2253 public function getId() {
2254 return $this->mPage
->getId();
2258 * Call to WikiPage function for backwards compatibility.
2259 * @see WikiPage::getLatest
2261 public function getLatest() {
2262 return $this->mPage
->getLatest();
2266 * Call to WikiPage function for backwards compatibility.
2267 * @see WikiPage::getLinksTimestamp
2269 public function getLinksTimestamp() {
2270 return $this->mPage
->getLinksTimestamp();
2274 * Call to WikiPage function for backwards compatibility.
2275 * @see WikiPage::getMinorEdit
2277 public function getMinorEdit() {
2278 return $this->mPage
->getMinorEdit();
2282 * Call to WikiPage function for backwards compatibility.
2283 * @see WikiPage::getOldestRevision
2285 public function getOldestRevision() {
2286 return $this->mPage
->getOldestRevision();
2290 * Call to WikiPage function for backwards compatibility.
2291 * @see WikiPage::getRedirectTarget
2293 public function getRedirectTarget() {
2294 return $this->mPage
->getRedirectTarget();
2298 * Call to WikiPage function for backwards compatibility.
2299 * @see WikiPage::getRedirectURL
2301 public function getRedirectURL( $rt ) {
2302 return $this->mPage
->getRedirectURL( $rt );
2306 * Call to WikiPage function for backwards compatibility.
2307 * @see WikiPage::getRevision
2309 public function getRevision() {
2310 return $this->mPage
->getRevision();
2314 * Call to WikiPage function for backwards compatibility.
2315 * @see WikiPage::getTimestamp
2317 public function getTimestamp() {
2318 return $this->mPage
->getTimestamp();
2322 * Call to WikiPage function for backwards compatibility.
2323 * @see WikiPage::getTouched
2325 public function getTouched() {
2326 return $this->mPage
->getTouched();
2330 * Call to WikiPage function for backwards compatibility.
2331 * @see WikiPage::getUndoContent
2333 public function getUndoContent( Revision
$undo, Revision
$undoafter = null ) {
2334 return $this->mPage
->getUndoContent( $undo, $undoafter );
2338 * Call to WikiPage function for backwards compatibility.
2339 * @see WikiPage::getUser
2341 public function getUser( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2342 return $this->mPage
->getUser( $audience, $user );
2346 * Call to WikiPage function for backwards compatibility.
2347 * @see WikiPage::getUserText
2349 public function getUserText( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2350 return $this->mPage
->getUserText( $audience, $user );
2354 * Call to WikiPage function for backwards compatibility.
2355 * @see WikiPage::hasViewableContent
2357 public function hasViewableContent() {
2358 return $this->mPage
->hasViewableContent();
2362 * Call to WikiPage function for backwards compatibility.
2363 * @see WikiPage::insertOn
2365 public function insertOn( $dbw, $pageId = null ) {
2366 return $this->mPage
->insertOn( $dbw, $pageId );
2370 * Call to WikiPage function for backwards compatibility.
2371 * @see WikiPage::insertProtectNullRevision
2373 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2374 array $expiry, $cascade, $reason, $user = null
2376 return $this->mPage
->insertProtectNullRevision( $revCommentMsg, $limit,
2377 $expiry, $cascade, $reason, $user
2382 * Call to WikiPage function for backwards compatibility.
2383 * @see WikiPage::insertRedirect
2385 public function insertRedirect() {
2386 return $this->mPage
->insertRedirect();
2390 * Call to WikiPage function for backwards compatibility.
2391 * @see WikiPage::insertRedirectEntry
2393 public function insertRedirectEntry( Title
$rt, $oldLatest = null ) {
2394 return $this->mPage
->insertRedirectEntry( $rt, $oldLatest );
2398 * Call to WikiPage function for backwards compatibility.
2399 * @see WikiPage::isCountable
2401 public function isCountable( $editInfo = false ) {
2402 return $this->mPage
->isCountable( $editInfo );
2406 * Call to WikiPage function for backwards compatibility.
2407 * @see WikiPage::isRedirect
2409 public function isRedirect() {
2410 return $this->mPage
->isRedirect();
2414 * Call to WikiPage function for backwards compatibility.
2415 * @see WikiPage::loadFromRow
2417 public function loadFromRow( $data, $from ) {
2418 return $this->mPage
->loadFromRow( $data, $from );
2422 * Call to WikiPage function for backwards compatibility.
2423 * @see WikiPage::loadPageData
2425 public function loadPageData( $from = 'fromdb' ) {
2426 $this->mPage
->loadPageData( $from );
2430 * Call to WikiPage function for backwards compatibility.
2431 * @see WikiPage::lockAndGetLatest
2433 public function lockAndGetLatest() {
2434 return $this->mPage
->lockAndGetLatest();
2438 * Call to WikiPage function for backwards compatibility.
2439 * @see WikiPage::makeParserOptions
2441 public function makeParserOptions( $context ) {
2442 return $this->mPage
->makeParserOptions( $context );
2446 * Call to WikiPage function for backwards compatibility.
2447 * @see WikiPage::pageDataFromId
2449 public function pageDataFromId( $dbr, $id, $options = [] ) {
2450 return $this->mPage
->pageDataFromId( $dbr, $id, $options );
2454 * Call to WikiPage function for backwards compatibility.
2455 * @see WikiPage::pageDataFromTitle
2457 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2458 return $this->mPage
->pageDataFromTitle( $dbr, $title, $options );
2462 * Call to WikiPage function for backwards compatibility.
2463 * @see WikiPage::prepareContentForEdit
2465 public function prepareContentForEdit(
2466 Content
$content, $revision = null, User
$user = null,
2467 $serialFormat = null, $useCache = true
2469 return $this->mPage
->prepareContentForEdit(
2470 $content, $revision, $user,
2471 $serialFormat, $useCache
2476 * Call to WikiPage function for backwards compatibility.
2477 * @see WikiPage::protectDescription
2479 public function protectDescription( array $limit, array $expiry ) {
2480 return $this->mPage
->protectDescription( $limit, $expiry );
2484 * Call to WikiPage function for backwards compatibility.
2485 * @see WikiPage::protectDescriptionLog
2487 public function protectDescriptionLog( array $limit, array $expiry ) {
2488 return $this->mPage
->protectDescriptionLog( $limit, $expiry );
2492 * Call to WikiPage function for backwards compatibility.
2493 * @see WikiPage::replaceSectionAtRev
2495 public function replaceSectionAtRev( $sectionId, Content
$sectionContent,
2496 $sectionTitle = '', $baseRevId = null
2498 return $this->mPage
->replaceSectionAtRev( $sectionId, $sectionContent,
2499 $sectionTitle, $baseRevId
2504 * Call to WikiPage function for backwards compatibility.
2505 * @see WikiPage::replaceSectionContent
2507 public function replaceSectionContent(
2508 $sectionId, Content
$sectionContent, $sectionTitle = '', $edittime = null
2510 return $this->mPage
->replaceSectionContent(
2511 $sectionId, $sectionContent, $sectionTitle, $edittime
2516 * Call to WikiPage function for backwards compatibility.
2517 * @see WikiPage::setTimestamp
2519 public function setTimestamp( $ts ) {
2520 return $this->mPage
->setTimestamp( $ts );
2524 * Call to WikiPage function for backwards compatibility.
2525 * @see WikiPage::shouldCheckParserCache
2527 public function shouldCheckParserCache( ParserOptions
$parserOptions, $oldId ) {
2528 return $this->mPage
->shouldCheckParserCache( $parserOptions, $oldId );
2532 * Call to WikiPage function for backwards compatibility.
2533 * @see WikiPage::supportsSections
2535 public function supportsSections() {
2536 return $this->mPage
->supportsSections();
2540 * Call to WikiPage function for backwards compatibility.
2541 * @see WikiPage::triggerOpportunisticLinksUpdate
2543 public function triggerOpportunisticLinksUpdate( ParserOutput
$parserOutput ) {
2544 return $this->mPage
->triggerOpportunisticLinksUpdate( $parserOutput );
2548 * Call to WikiPage function for backwards compatibility.
2549 * @see WikiPage::updateCategoryCounts
2551 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2552 return $this->mPage
->updateCategoryCounts( $added, $deleted, $id );
2556 * Call to WikiPage function for backwards compatibility.
2557 * @see WikiPage::updateIfNewerOn
2559 public function updateIfNewerOn( $dbw, $revision ) {
2560 return $this->mPage
->updateIfNewerOn( $dbw, $revision );
2564 * Call to WikiPage function for backwards compatibility.
2565 * @see WikiPage::updateRedirectOn
2567 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2568 return $this->mPage
->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect );
2572 * Call to WikiPage function for backwards compatibility.
2573 * @see WikiPage::updateRevisionOn
2575 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2576 $lastRevIsRedirect = null
2578 return $this->mPage
->updateRevisionOn( $dbw, $revision, $lastRevision,
2584 * @param array $limit
2585 * @param array $expiry
2586 * @param bool &$cascade
2587 * @param string $reason
2591 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2594 return $this->mPage
->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2598 * @param array $limit
2599 * @param string $reason
2600 * @param int &$cascade
2601 * @param array $expiry
2604 public function updateRestrictions( $limit = [], $reason = '',
2605 &$cascade = 0, $expiry = []
2607 return $this->mPage
->doUpdateRestrictions(
2612 $this->getContext()->getUser()
2617 * @param string $reason
2618 * @param bool $suppress
2619 * @param int $u1 Unused
2620 * @param bool $u2 Unused
2621 * @param string &$error
2624 public function doDeleteArticle(
2625 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2627 return $this->mPage
->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2631 * @param string $fromP
2632 * @param string $summary
2633 * @param string $token
2635 * @param array &$resultDetails
2636 * @param User|null $user
2639 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User
$user = null ) {
2640 $user = is_null( $user ) ?
$this->getContext()->getUser() : $user;
2641 return $this->mPage
->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2645 * @param string $fromP
2646 * @param string $summary
2648 * @param array &$resultDetails
2649 * @param User|null $guser
2652 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User
$guser = null ) {
2653 $guser = is_null( $guser ) ?
$this->getContext()->getUser() : $guser;
2654 return $this->mPage
->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2658 * @param bool &$hasHistory
2661 public function generateReason( &$hasHistory ) {
2662 $title = $this->mPage
->getTitle();
2663 $handler = ContentHandler
::getForTitle( $title );
2664 return $handler->getAutoDeleteReason( $title, $hasHistory );