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() {
218 if ( $this->mPage
->getId() === 0 ) {
219 # If this is a MediaWiki:x message, then load the messages
220 # and return the message value for x.
221 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI
) {
222 $text = $this->getTitle()->getDefaultMessageText();
223 if ( $text === false ) {
227 $content = ContentHandler
::makeContent( $text, $this->getTitle() );
229 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
230 $content = new MessageContent( $message, null, 'parsemag' );
233 $this->fetchContentObject();
234 $content = $this->mContentObject
;
241 * @return int The oldid of the article that is to be shown, 0 for the current revision
243 public function getOldID() {
244 if ( is_null( $this->mOldId
) ) {
245 $this->mOldId
= $this->getOldIDFromRequest();
248 return $this->mOldId
;
252 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
254 * @return int The old id for the request
256 public function getOldIDFromRequest() {
257 $this->mRedirectUrl
= false;
259 $request = $this->getContext()->getRequest();
260 $oldid = $request->getIntOrNull( 'oldid' );
262 if ( $oldid === null ) {
266 if ( $oldid !== 0 ) {
267 # Load the given revision and check whether the page is another one.
268 # In that case, update this instance to reflect the change.
269 if ( $oldid === $this->mPage
->getLatest() ) {
270 $this->mRevision
= $this->mPage
->getRevision();
272 $this->mRevision
= Revision
::newFromId( $oldid );
273 if ( $this->mRevision
!== null ) {
274 // Revision title doesn't match the page title given?
275 if ( $this->mPage
->getId() != $this->mRevision
->getPage() ) {
276 $function = [ get_class( $this->mPage
), 'newFromID' ];
277 $this->mPage
= call_user_func( $function, $this->mRevision
->getPage() );
283 if ( $request->getVal( 'direction' ) == 'next' ) {
284 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
287 $this->mRevision
= null;
289 $this->mRedirectUrl
= $this->getTitle()->getFullURL( 'redirect=no' );
291 } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
292 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
295 $this->mRevision
= null;
303 * Get text content object
304 * Does *NOT* follow redirects.
305 * @todo When is this null?
307 * @note Code that wants to retrieve page content from the database should
308 * use WikiPage::getContent().
310 * @return Content|null|bool
314 protected function fetchContentObject() {
315 if ( $this->mContentLoaded
) {
316 return $this->mContentObject
;
319 $this->mContentLoaded
= true;
320 $this->mContent
= null;
322 $oldid = $this->getOldID();
324 # Pre-fill content with error message so that if something
325 # fails we'll have something telling us what we intended.
326 // XXX: this isn't page content but a UI message. horrible.
327 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
330 # $this->mRevision might already be fetched by getOldIDFromRequest()
331 if ( !$this->mRevision
) {
332 $this->mRevision
= Revision
::newFromId( $oldid );
333 if ( !$this->mRevision
) {
334 wfDebug( __METHOD__
. " failed to retrieve specified revision, id $oldid\n" );
339 $oldid = $this->mPage
->getLatest();
341 wfDebug( __METHOD__
. " failed to find page data for title " .
342 $this->getTitle()->getPrefixedText() . "\n" );
346 # Update error message with correct oldid
347 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
349 $this->mRevision
= $this->mPage
->getRevision();
351 if ( !$this->mRevision
) {
352 wfDebug( __METHOD__
. " failed to retrieve current page, rev_id $oldid\n" );
357 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
358 // We should instead work with the Revision object when we need it...
359 // Loads if user is allowed
360 $content = $this->mRevision
->getContent(
361 Revision
::FOR_THIS_USER
,
362 $this->getContext()->getUser()
366 wfDebug( __METHOD__
. " failed to retrieve content of revision " .
367 $this->mRevision
->getId() . "\n" );
371 $this->mContentObject
= $content;
372 $this->mRevIdFetched
= $this->mRevision
->getId();
374 // Avoid PHP 7.1 warning of passing $this by reference
375 $articlePage = $this;
378 'ArticleAfterFetchContentObject',
379 [ &$articlePage, &$this->mContentObject
]
382 return $this->mContentObject
;
386 * Returns true if the currently-referenced revision is the current edit
387 * to this page (and it exists).
390 public function isCurrent() {
391 # If no oldid, this is the current version.
392 if ( $this->getOldID() == 0 ) {
396 return $this->mPage
->exists() && $this->mRevision
&& $this->mRevision
->isCurrent();
400 * Get the fetched Revision object depending on request parameters or null
404 * @return Revision|null
406 public function getRevisionFetched() {
407 $this->fetchContentObject();
409 return $this->mRevision
;
413 * Use this to fetch the rev ID used on page views
415 * @return int Revision ID of last article revision
417 public function getRevIdFetched() {
418 if ( $this->mRevIdFetched
) {
419 return $this->mRevIdFetched
;
421 return $this->mPage
->getLatest();
426 * This is the default action of the index.php entry point: just view the
427 * page of the given title.
429 public function view() {
430 global $wgUseFileCache, $wgDebugToolbar;
432 # Get variables from query string
433 # As side effect this will load the revision and update the title
434 # in a revision ID is passed in the request, so this should remain
435 # the first call of this method even if $oldid is used way below.
436 $oldid = $this->getOldID();
438 $user = $this->getContext()->getUser();
439 # Another whitelist check in case getOldID() is altering the title
440 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
441 if ( count( $permErrors ) ) {
442 wfDebug( __METHOD__
. ": denied on secondary read check\n" );
443 throw new PermissionsError( 'read', $permErrors );
446 $outputPage = $this->getContext()->getOutput();
447 # getOldID() may as well want us to redirect somewhere else
448 if ( $this->mRedirectUrl
) {
449 $outputPage->redirect( $this->mRedirectUrl
);
450 wfDebug( __METHOD__
. ": redirecting due to oldid\n" );
455 # If we got diff in the query, we want to see a diff page instead of the article.
456 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
457 wfDebug( __METHOD__
. ": showing diff page\n" );
458 $this->showDiffPage();
463 # Set page title (may be overridden by DISPLAYTITLE)
464 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
466 $outputPage->setArticleFlag( true );
467 # Allow frames by default
468 $outputPage->allowClickjacking();
470 $parserCache = ParserCache
::singleton();
472 $parserOptions = $this->getParserOptions();
473 # Render printable version, use printable version cache
474 if ( $outputPage->isPrintable() ) {
475 $parserOptions->setIsPrintable( true );
476 $parserOptions->setEditSection( false );
477 } elseif ( !$this->isCurrent() ||
!$this->getTitle()->quickUserCan( 'edit', $user ) ) {
478 $parserOptions->setEditSection( false );
481 # Try client and file cache
482 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage
->checkTouched() ) {
483 # Try to stream the output from file cache
484 if ( $wgUseFileCache && $this->tryFileCache() ) {
485 wfDebug( __METHOD__
. ": done file cache\n" );
486 # tell wgOut that output is taken care of
487 $outputPage->disable();
488 $this->mPage
->doViewUpdates( $user, $oldid );
494 # Should the parser cache be used?
495 $useParserCache = $this->mPage
->shouldCheckParserCache( $parserOptions, $oldid );
496 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ?
'yes' : 'no' ) . "\n" );
497 if ( $user->getStubThreshold() ) {
498 MediaWikiServices
::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
501 $this->showRedirectedFromHeader();
502 $this->showNamespaceHeader();
504 # Iterate through the possible ways of constructing the output text.
505 # Keep going until $outputDone is set, or we run out of things to do.
508 $this->mParserOutput
= false;
510 while ( !$outputDone && ++
$pass ) {
513 // Avoid PHP 7.1 warning of passing $this by reference
514 $articlePage = $this;
515 Hooks
::run( 'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
518 # Early abort if the page doesn't exist
519 if ( !$this->mPage
->exists() ) {
520 wfDebug( __METHOD__
. ": showing missing article\n" );
521 $this->showMissingArticle();
522 $this->mPage
->doViewUpdates( $user );
526 # Try the parser cache
527 if ( $useParserCache ) {
528 $this->mParserOutput
= $parserCache->get( $this->mPage
, $parserOptions );
530 if ( $this->mParserOutput
!== false ) {
532 wfDebug( __METHOD__
. ": showing parser cache contents for current rev permalink\n" );
533 $this->setOldSubtitle( $oldid );
535 wfDebug( __METHOD__
. ": showing parser cache contents\n" );
537 $outputPage->addParserOutput( $this->mParserOutput
);
538 # Ensure that UI elements requiring revision ID have
539 # the correct version information.
540 $outputPage->setRevisionId( $this->mPage
->getLatest() );
541 # Preload timestamp to avoid a DB hit
542 $cachedTimestamp = $this->mParserOutput
->getTimestamp();
543 if ( $cachedTimestamp !== null ) {
544 $outputPage->setRevisionTimestamp( $cachedTimestamp );
545 $this->mPage
->setTimestamp( $cachedTimestamp );
552 # This will set $this->mRevision if needed
553 $this->fetchContentObject();
555 # Are we looking at an old revision
556 if ( $oldid && $this->mRevision
) {
557 $this->setOldSubtitle( $oldid );
559 if ( !$this->showDeletedRevisionHeader() ) {
560 wfDebug( __METHOD__
. ": cannot view deleted revision\n" );
565 # Ensure that UI elements requiring revision ID have
566 # the correct version information.
567 $outputPage->setRevisionId( $this->getRevIdFetched() );
568 # Preload timestamp to avoid a DB hit
569 $outputPage->setRevisionTimestamp( $this->mPage
->getTimestamp() );
571 if ( !Hooks
::run( 'ArticleContentViewCustom',
572 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
574 # Allow extensions do their own custom view for certain pages
579 # Run the parse, protected by a pool counter
580 wfDebug( __METHOD__
. ": doing uncached parse\n" );
582 $content = $this->getContentObject();
583 $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
584 $this->getRevIdFetched(), $useParserCache, $content );
586 if ( !$poolArticleView->execute() ) {
587 $error = $poolArticleView->getError();
589 $outputPage->clearHTML(); // for release() errors
590 $outputPage->enableClientCache( false );
591 $outputPage->setRobotPolicy( 'noindex,nofollow' );
593 $errortext = $error->getWikiText( false, 'view-pool-error' );
594 $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
596 # Connection or timeout error
600 $this->mParserOutput
= $poolArticleView->getParserOutput();
601 $outputPage->addParserOutput( $this->mParserOutput
);
602 if ( $content->getRedirectTarget() ) {
603 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
604 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
607 # Don't cache a dirty ParserOutput object
608 if ( $poolArticleView->getIsDirty() ) {
609 $outputPage->setCdnMaxage( 0 );
610 $outputPage->addHTML( "<!-- parser cache is expired, " .
611 "sending anyway due to pool overload-->\n" );
616 # Should be unreachable, but just in case...
622 # Get the ParserOutput actually *displayed* here.
623 # Note that $this->mParserOutput is the *current*/oldid version output.
624 $pOutput = ( $outputDone instanceof ParserOutput
)
625 ?
$outputDone // object fetched by hook
626 : $this->mParserOutput
;
628 # Adjust title for main page & pages with displaytitle
630 $this->adjustDisplayTitle( $pOutput );
633 # For the main page, overwrite the <title> element with the con-
634 # tents of 'pagetitle-view-mainpage' instead of the default (if
636 # This message always exists because it is in the i18n files
637 if ( $this->getTitle()->isMainPage() ) {
638 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
639 if ( !$msg->isDisabled() ) {
640 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
644 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
645 # This could use getTouched(), but that could be scary for major template edits.
646 $outputPage->adaptCdnTTL( $this->mPage
->getTimestamp(), IExpiringStore
::TTL_DAY
);
648 # Check for any __NOINDEX__ tags on the page using $pOutput
649 $policy = $this->getRobotPolicy( 'view', $pOutput );
650 $outputPage->setIndexPolicy( $policy['index'] );
651 $outputPage->setFollowPolicy( $policy['follow'] );
653 $this->showViewFooter();
654 $this->mPage
->doViewUpdates( $user, $oldid );
656 $outputPage->addModules( 'mediawiki.action.view.postEdit' );
660 * Adjust title for pages with displaytitle, -{T|}- or language conversion
661 * @param ParserOutput $pOutput
663 public function adjustDisplayTitle( ParserOutput
$pOutput ) {
664 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
665 $titleText = $pOutput->getTitleText();
666 if ( strval( $titleText ) !== '' ) {
667 $this->getContext()->getOutput()->setPageTitle( $titleText );
672 * Show a diff page according to current request variables. For use within
673 * Article::view() only, other callers should use the DifferenceEngine class.
675 protected function showDiffPage() {
676 $request = $this->getContext()->getRequest();
677 $user = $this->getContext()->getUser();
678 $diff = $request->getVal( 'diff' );
679 $rcid = $request->getVal( 'rcid' );
680 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
681 $purge = $request->getVal( 'action' ) == 'purge';
682 $unhide = $request->getInt( 'unhide' ) == 1;
683 $oldid = $this->getOldID();
685 $rev = $this->getRevisionFetched();
688 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
689 $msg = $this->getContext()->msg( 'difference-missing-revision' )
693 $this->getContext()->getOutput()->addHTML( $msg );
697 $contentHandler = $rev->getContentHandler();
698 $de = $contentHandler->createDifferenceEngine(
707 // DifferenceEngine directly fetched the revision:
708 $this->mRevIdFetched
= $de->mNewid
;
709 $de->showDiffPage( $diffOnly );
711 // Run view updates for the newer revision being diffed (and shown
712 // below the diff if not $diffOnly).
713 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
714 // New can be false, convert it to 0 - this conveniently means the latest revision
715 $this->mPage
->doViewUpdates( $user, (int)$new );
719 * Get the robot policy to be used for the current view
720 * @param string $action The action= GET parameter
721 * @param ParserOutput|null $pOutput
722 * @return array The policy that should be set
723 * @todo actions other than 'view'
725 public function getRobotPolicy( $action, $pOutput = null ) {
726 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
728 $ns = $this->getTitle()->getNamespace();
730 # Don't index user and user talk pages for blocked users (T13443)
731 if ( ( $ns == NS_USER ||
$ns == NS_USER_TALK
) && !$this->getTitle()->isSubpage() ) {
732 $specificTarget = null;
734 $titleText = $this->getTitle()->getText();
735 if ( IP
::isValid( $titleText ) ) {
736 $vagueTarget = $titleText;
738 $specificTarget = $titleText;
740 if ( Block
::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block
) {
742 'index' => 'noindex',
743 'follow' => 'nofollow'
748 if ( $this->mPage
->getId() === 0 ||
$this->getOldID() ) {
749 # Non-articles (special pages etc), and old revisions
751 'index' => 'noindex',
752 'follow' => 'nofollow'
754 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
755 # Discourage indexing of printable versions, but encourage following
757 'index' => 'noindex',
760 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
761 # For ?curid=x urls, disallow indexing
763 'index' => 'noindex',
768 # Otherwise, construct the policy based on the various config variables.
769 $policy = self
::formatRobotPolicy( $wgDefaultRobotPolicy );
771 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
772 # Honour customised robot policies for this namespace
773 $policy = array_merge(
775 self
::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
778 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
779 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
780 # a final sanity check that we have really got the parser output.
781 $policy = array_merge(
783 [ 'index' => $pOutput->getIndexPolicy() ]
787 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
788 # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
789 $policy = array_merge(
791 self
::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
799 * Converts a String robot policy into an associative array, to allow
800 * merging of several policies using array_merge().
801 * @param array|string $policy Returns empty array on null/false/'', transparent
802 * to already-converted arrays, converts string.
803 * @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
805 public static function formatRobotPolicy( $policy ) {
806 if ( is_array( $policy ) ) {
808 } elseif ( !$policy ) {
812 $policy = explode( ',', $policy );
813 $policy = array_map( 'trim', $policy );
816 foreach ( $policy as $var ) {
817 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
818 $arr['index'] = $var;
819 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
820 $arr['follow'] = $var;
828 * If this request is a redirect view, send "redirected from" subtitle to
829 * the output. Returns true if the header was needed, false if this is not
830 * a redirect view. Handles both local and remote redirects.
834 public function showRedirectedFromHeader() {
835 global $wgRedirectSources;
837 $context = $this->getContext();
838 $outputPage = $context->getOutput();
839 $request = $context->getRequest();
840 $rdfrom = $request->getVal( 'rdfrom' );
842 // Construct a URL for the current page view, but with the target title
843 $query = $request->getValues();
844 unset( $query['rdfrom'] );
845 unset( $query['title'] );
846 if ( $this->getTitle()->isRedirect() ) {
847 // Prevent double redirects
848 $query['redirect'] = 'no';
850 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
852 if ( isset( $this->mRedirectedFrom
) ) {
853 // Avoid PHP 7.1 warning of passing $this by reference
854 $articlePage = $this;
856 // This is an internally redirected page view.
857 // We'll need a backlink to the source page for navigation.
858 if ( Hooks
::run( 'ArticleViewRedirect', [ &$articlePage ] ) ) {
859 $redir = Linker
::linkKnown(
860 $this->mRedirectedFrom
,
863 [ 'redirect' => 'no' ]
866 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
867 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
870 // Add the script to update the displayed URL and
871 // set the fragment if one was specified in the redirect
872 $outputPage->addJsConfigVars( [
873 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
875 $outputPage->addModules( 'mediawiki.action.view.redirect' );
877 // Add a <link rel="canonical"> tag
878 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
880 // Tell the output object that the user arrived at this article through a redirect
881 $outputPage->setRedirectedFrom( $this->mRedirectedFrom
);
885 } elseif ( $rdfrom ) {
886 // This is an externally redirected view, from some other wiki.
887 // If it was reported from a trusted site, supply a backlink.
888 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
889 $redir = Linker
::makeExternalLink( $rdfrom, $rdfrom );
890 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
891 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
894 // Add the script to update the displayed URL
895 $outputPage->addJsConfigVars( [
896 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
898 $outputPage->addModules( 'mediawiki.action.view.redirect' );
908 * Show a header specific to the namespace currently being viewed, like
909 * [[MediaWiki:Talkpagetext]]. For Article::view().
911 public function showNamespaceHeader() {
912 if ( $this->getTitle()->isTalkPage() ) {
913 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
914 $this->getContext()->getOutput()->wrapWikiMsg(
915 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
923 * Show the footer section of an ordinary page view
925 public function showViewFooter() {
926 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
927 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
928 && IP
::isValid( $this->getTitle()->getText() )
930 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
933 // Show a footer allowing the user to patrol the shown revision or page if possible
934 $patrolFooterShown = $this->showPatrolFooter();
936 Hooks
::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
940 * If patrol is possible, output a patrol UI box. This is called from the
941 * footer section of ordinary page views. If patrol is not possible or not
942 * desired, does nothing.
943 * Side effect: When the patrol link is build, this method will call
944 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
948 public function showPatrolFooter() {
949 global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
951 $outputPage = $this->getContext()->getOutput();
952 $user = $this->getContext()->getUser();
953 $title = $this->getTitle();
956 if ( !$title->quickUserCan( 'patrol', $user )
957 ||
!( $wgUseRCPatrol ||
$wgUseNPPatrol
958 ||
( $wgUseFilePatrol && $title->inNamespace( NS_FILE
) ) )
960 // Patrolling is disabled or the user isn't allowed to
964 if ( $this->mRevision
965 && !RecentChange
::isInRCLifespan( $this->mRevision
->getTimestamp(), 21600 )
967 // The current revision is already older than what could be in the RC table
968 // 6h tolerance because the RC might not be cleaned out regularly
972 // Check for cached results
973 $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() );
974 $cache = ObjectCache
::getMainWANInstance();
975 if ( $cache->get( $key ) ) {
979 $dbr = wfGetDB( DB_REPLICA
);
980 $oldestRevisionTimestamp = $dbr->selectField(
982 'MIN( rev_timestamp )',
983 [ 'rev_page' => $title->getArticleID() ],
987 // New page patrol: Get the timestamp of the oldest revison which
988 // the revision table holds for the given page. Then we look
989 // whether it's within the RC lifespan and if it is, we try
990 // to get the recentchanges row belonging to that entry
991 // (with rc_new = 1).
992 $recentPageCreation = false;
993 if ( $oldestRevisionTimestamp
994 && RecentChange
::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
996 // 6h tolerance because the RC might not be cleaned out regularly
997 $recentPageCreation = true;
998 $rc = RecentChange
::newFromConds(
1001 'rc_timestamp' => $oldestRevisionTimestamp,
1002 'rc_namespace' => $title->getNamespace(),
1003 'rc_cur_id' => $title->getArticleID()
1008 // Use generic patrol message for new pages
1009 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1013 // File patrol: Get the timestamp of the latest upload for this page,
1014 // check whether it is within the RC lifespan and if it is, we try
1015 // to get the recentchanges row belonging to that entry
1016 // (with rc_type = RC_LOG, rc_log_type = upload).
1017 $recentFileUpload = false;
1018 if ( ( !$rc ||
$rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1019 && $title->getNamespace() === NS_FILE
) {
1020 // Retrieve timestamp of most recent upload
1021 $newestUploadTimestamp = $dbr->selectField(
1023 'MAX( img_timestamp )',
1024 [ 'img_name' => $title->getDBkey() ],
1027 if ( $newestUploadTimestamp
1028 && RecentChange
::isInRCLifespan( $newestUploadTimestamp, 21600 )
1030 // 6h tolerance because the RC might not be cleaned out regularly
1031 $recentFileUpload = true;
1032 $rc = RecentChange
::newFromConds(
1034 'rc_type' => RC_LOG
,
1035 'rc_log_type' => 'upload',
1036 'rc_timestamp' => $newestUploadTimestamp,
1037 'rc_namespace' => NS_FILE
,
1038 'rc_cur_id' => $title->getArticleID()
1041 [ 'USE INDEX' => 'rc_timestamp' ]
1044 // Use patrol message specific to files
1045 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1050 if ( !$recentPageCreation && !$recentFileUpload ) {
1051 // Page creation and latest upload (for files) is too old to be in RC
1053 // We definitely can't patrol so cache the information
1054 // When a new file version is uploaded, the cache is cleared
1055 $cache->set( $key, '1' );
1061 // Don't cache: This can be hit if the page gets accessed very fast after
1062 // its creation / latest upload or in case we have high replica DB lag. In case
1063 // the revision is too old, we will already return above.
1067 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1068 // Patrolled RC entry around
1070 // Cache the information we gathered above in case we can't patrol
1071 // Don't cache in case we can patrol as this could change
1072 $cache->set( $key, '1' );
1077 if ( $rc->getPerformer()->equals( $user ) ) {
1078 // Don't show a patrol link for own creations/uploads. If the user could
1079 // patrol them, they already would be patrolled
1083 $outputPage->preventClickjacking();
1084 if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
1085 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1088 $link = Linker
::linkKnown(
1090 $markPatrolledMsg->escaped(),
1093 'action' => 'markpatrolled',
1094 'rcid' => $rc->getAttribute( 'rc_id' ),
1098 $outputPage->addHTML(
1099 "<div class='patrollink' data-mw='interface'>" .
1100 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1108 * Purge the cache used to check if it is worth showing the patrol footer
1109 * For example, it is done during re-uploads when file patrol is used.
1110 * @param int $articleID ID of the article to purge
1113 public static function purgePatrolFooterCache( $articleID ) {
1114 $cache = ObjectCache
::getMainWANInstance();
1115 $cache->delete( wfMemcKey( 'unpatrollable-page', $articleID ) );
1119 * Show the error text for a missing article. For articles in the MediaWiki
1120 * namespace, show the default message text. To be called from Article::view().
1122 public function showMissingArticle() {
1123 global $wgSend404Code;
1125 $outputPage = $this->getContext()->getOutput();
1126 // Whether the page is a root user page of an existing user (but not a subpage)
1127 $validUserPage = false;
1129 $title = $this->getTitle();
1131 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1132 if ( $title->getNamespace() == NS_USER
1133 ||
$title->getNamespace() == NS_USER_TALK
1135 $rootPart = explode( '/', $title->getText() )[0];
1136 $user = User
::newFromName( $rootPart, false /* allow IP users*/ );
1137 $ip = User
::isIP( $rootPart );
1138 $block = Block
::newFromTarget( $user, $user );
1140 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1141 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1142 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1143 } elseif ( !is_null( $block ) && $block->getType() != Block
::TYPE_AUTO
) {
1144 # Show log extract if the user is currently blocked
1145 LogEventsList
::showLogExtract(
1148 MWNamespace
::getCanonicalName( NS_USER
) . ':' . $block->getTarget(),
1152 'showIfEmpty' => false,
1154 'blocked-notice-logextract',
1155 $user->getName() # Support GENDER in notice
1159 $validUserPage = !$title->isSubpage();
1161 $validUserPage = !$title->isSubpage();
1165 Hooks
::run( 'ShowMissingArticle', [ $this ] );
1167 # Show delete and move logs if there were any such events.
1168 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1169 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1170 $cache = ObjectCache
::getMainStashInstance();
1171 $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1172 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1173 if ( $loggedIn ||
$cache->get( $key ) ) {
1174 $logTypes = [ 'delete', 'move' ];
1176 $dbr = wfGetDB( DB_REPLICA
);
1178 $conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
1179 // Give extensions a chance to hide their (unrelated) log entries
1180 Hooks
::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1181 LogEventsList
::showLogExtract(
1189 'showIfEmpty' => false,
1190 'msgKey' => [ $loggedIn
1191 ?
'moveddeleted-notice'
1192 : 'moveddeleted-notice-recent'
1198 if ( !$this->mPage
->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1199 // If there's no backing content, send a 404 Not Found
1200 // for better machine handling of broken links.
1201 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1204 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1205 $policy = $this->getRobotPolicy( 'view' );
1206 $outputPage->setIndexPolicy( $policy['index'] );
1207 $outputPage->setFollowPolicy( $policy['follow'] );
1209 $hookResult = Hooks
::run( 'BeforeDisplayNoArticleText', [ $this ] );
1211 if ( !$hookResult ) {
1215 # Show error message
1216 $oldid = $this->getOldID();
1217 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI
&& $title->hasSourceText() ) {
1218 $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
1221 $text = wfMessage( 'missing-revision', $oldid )->plain();
1222 } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1223 && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1225 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
1226 $text = wfMessage( $message )->plain();
1228 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1231 $dir = $this->getContext()->getLanguage()->getDir();
1232 $lang = $this->getContext()->getLanguage()->getCode();
1233 $outputPage->addWikiText( Xml
::openElement( 'div', [
1234 'class' => "noarticletext mw-content-$dir",
1237 ] ) . "\n$text\n</div>" );
1242 * If the revision requested for view is deleted, check permissions.
1243 * Send either an error message or a warning header to the output.
1245 * @return bool True if the view is allowed, false if not.
1247 public function showDeletedRevisionHeader() {
1248 if ( !$this->mRevision
->isDeleted( Revision
::DELETED_TEXT
) ) {
1253 $outputPage = $this->getContext()->getOutput();
1254 $user = $this->getContext()->getUser();
1255 // If the user is not allowed to see it...
1256 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
, $user ) ) {
1257 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1258 'rev-deleted-text-permission' );
1261 // If the user needs to confirm that they want to see it...
1262 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1263 # Give explanation and add a link to view the revision...
1264 $oldid = intval( $this->getOldID() );
1265 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1266 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1267 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1268 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1272 // We are allowed to see...
1274 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1275 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1276 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1283 * Generate the navigation links when browsing through an article revisions
1284 * It shows the information as:
1285 * Revision as of \<date\>; view current revision
1286 * \<- Previous version | Next Version -\>
1288 * @param int $oldid Revision ID of this article revision
1290 public function setOldSubtitle( $oldid = 0 ) {
1291 // Avoid PHP 7.1 warning of passing $this by reference
1292 $articlePage = $this;
1294 if ( !Hooks
::run( 'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1298 $context = $this->getContext();
1299 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1301 # Cascade unhide param in links for easy deletion browsing
1304 $extraParams['unhide'] = 1;
1307 if ( $this->mRevision
&& $this->mRevision
->getId() === $oldid ) {
1308 $revision = $this->mRevision
;
1310 $revision = Revision
::newFromId( $oldid );
1313 $timestamp = $revision->getTimestamp();
1315 $current = ( $oldid == $this->mPage
->getLatest() );
1316 $language = $context->getLanguage();
1317 $user = $context->getUser();
1319 $td = $language->userTimeAndDate( $timestamp, $user );
1320 $tddate = $language->userDate( $timestamp, $user );
1321 $tdtime = $language->userTime( $timestamp, $user );
1323 # Show user links if allowed to see them. If hidden, then show them only if requested...
1324 $userlinks = Linker
::revUserTools( $revision, !$unhide );
1326 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1327 ?
'revision-info-current'
1330 $outputPage = $context->getOutput();
1331 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1332 $context->msg( $infomsg, $td )
1333 ->rawParams( $userlinks )
1334 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1335 ->rawParams( Linker
::revComment( $revision, true, true ) )
1340 ?
$context->msg( 'currentrevisionlink' )->escaped()
1341 : Linker
::linkKnown(
1343 $context->msg( 'currentrevisionlink' )->escaped(),
1348 ?
$context->msg( 'diff' )->escaped()
1349 : Linker
::linkKnown(
1351 $context->msg( 'diff' )->escaped(),
1358 $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1360 ? Linker
::linkKnown(
1362 $context->msg( 'previousrevision' )->escaped(),
1365 'direction' => 'prev',
1369 : $context->msg( 'previousrevision' )->escaped();
1371 ? Linker
::linkKnown(
1373 $context->msg( 'diff' )->escaped(),
1380 : $context->msg( 'diff' )->escaped();
1381 $nextlink = $current
1382 ?
$context->msg( 'nextrevision' )->escaped()
1383 : Linker
::linkKnown(
1385 $context->msg( 'nextrevision' )->escaped(),
1388 'direction' => 'next',
1392 $nextdiff = $current
1393 ?
$context->msg( 'diff' )->escaped()
1394 : Linker
::linkKnown(
1396 $context->msg( 'diff' )->escaped(),
1404 $cdel = Linker
::getRevDeleteLink( $user, $revision, $this->getTitle() );
1405 if ( $cdel !== '' ) {
1409 // the outer div is need for styling the revision info and nav in MobileFrontend
1410 $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1411 "<div id=\"mw-revision-nav\">" . $cdel .
1412 $context->msg( 'revision-nav' )->rawParams(
1413 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1414 )->escaped() . "</div></div>" );
1418 * Return the HTML for the top of a redirect page
1420 * Chances are you should just be using the ParserOutput from
1421 * WikitextContent::getParserOutput instead of calling this for redirects.
1423 * @param Title|array $target Destination(s) to redirect
1424 * @param bool $appendSubtitle [optional]
1425 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1426 * @return string Containing HTML with redirect link
1428 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1429 $lang = $this->getTitle()->getPageLanguage();
1430 $out = $this->getContext()->getOutput();
1431 if ( $appendSubtitle ) {
1432 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1434 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1435 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1439 * Return the HTML for the top of a redirect page
1441 * Chances are you should just be using the ParserOutput from
1442 * WikitextContent::getParserOutput instead of calling this for redirects.
1445 * @param Language $lang
1446 * @param Title|array $target Destination(s) to redirect
1447 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1448 * @return string Containing HTML with redirect link
1450 public static function getRedirectHeaderHtml( Language
$lang, $target, $forceKnown = false ) {
1451 if ( !is_array( $target ) ) {
1452 $target = [ $target ];
1455 $html = '<ul class="redirectText">';
1456 /** @var Title $title */
1457 foreach ( $target as $title ) {
1458 $html .= '<li>' . Linker
::link(
1460 htmlspecialchars( $title->getFullText() ),
1462 // Make sure wiki page redirects are not followed
1463 $title->isRedirect() ?
[ 'redirect' => 'no' ] : [],
1464 ( $forceKnown ?
[ 'known', 'noclasses' ] : [] )
1469 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1471 return '<div class="redirectMsg">' .
1472 '<p>' . $redirectToText . '</p>' .
1478 * Adds help link with an icon via page indicators.
1479 * Link target can be overridden by a local message containing a wikilink:
1480 * the message key is: 'namespace-' + namespace number + '-helppage'.
1481 * @param string $to Target MediaWiki.org page title or encoded URL.
1482 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
1485 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1487 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1490 $out = $this->getContext()->getOutput();
1491 if ( !$msg->isDisabled() ) {
1492 $helpUrl = Skin
::makeUrl( $msg->plain() );
1493 $out->addHelpLink( $helpUrl, true );
1495 $out->addHelpLink( $to, $overrideBaseUrl );
1500 * Handle action=render
1502 public function render() {
1503 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1504 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1505 $this->getContext()->getOutput()->enableSectionEditLinks( false );
1510 * action=protect handler
1512 public function protect() {
1513 $form = new ProtectionForm( $this );
1518 * action=unprotect handler (alias)
1520 public function unprotect() {
1525 * UI entry point for page deletion
1527 public function delete() {
1528 # This code desperately needs to be totally rewritten
1530 $title = $this->getTitle();
1531 $context = $this->getContext();
1532 $user = $context->getUser();
1533 $request = $context->getRequest();
1536 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1537 if ( count( $permissionErrors ) ) {
1538 throw new PermissionsError( 'delete', $permissionErrors );
1541 # Read-only check...
1542 if ( wfReadOnly() ) {
1543 throw new ReadOnlyError
;
1546 # Better double-check that it hasn't been deleted yet!
1547 $this->mPage
->loadPageData(
1548 $request->wasPosted() ? WikiPage
::READ_LATEST
: WikiPage
::READ_NORMAL
1550 if ( !$this->mPage
->exists() ) {
1551 $deleteLogPage = new LogPage( 'delete' );
1552 $outputPage = $context->getOutput();
1553 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1554 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1555 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1557 $outputPage->addHTML(
1558 Xml
::element( 'h2', null, $deleteLogPage->getName()->text() )
1560 LogEventsList
::showLogExtract(
1569 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1570 $deleteReason = $request->getText( 'wpReason' );
1572 if ( $deleteReasonList == 'other' ) {
1573 $reason = $deleteReason;
1574 } elseif ( $deleteReason != '' ) {
1575 // Entry from drop down menu + additional comment
1576 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1577 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1579 $reason = $deleteReasonList;
1582 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1583 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1585 # Flag to hide all contents of the archived revisions
1586 $suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1588 $this->doDelete( $reason, $suppress );
1590 WatchAction
::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1595 // Generate deletion reason
1596 $hasHistory = false;
1599 $reason = $this->generateReason( $hasHistory );
1600 } catch ( Exception
$e ) {
1601 # if a page is horribly broken, we still want to be able to
1602 # delete it. So be lenient about errors here.
1603 wfDebug( "Error while building auto delete summary: $e" );
1608 // If the page has a history, insert a warning
1609 if ( $hasHistory ) {
1610 $title = $this->getTitle();
1612 // The following can use the real revision count as this is only being shown for users
1613 // that can delete this page.
1614 // This, as a side-effect, also makes sure that the following query isn't being run for
1615 // pages with a larger history, unless the user has the 'bigdelete' right
1616 // (and is about to delete this page).
1617 $dbr = wfGetDB( DB_REPLICA
);
1618 $revisions = $edits = (int)$dbr->selectField(
1621 [ 'rev_page' => $title->getArticleID() ],
1625 // @todo FIXME: i18n issue/patchwork message
1626 $context->getOutput()->addHTML(
1627 '<strong class="mw-delete-warning-revisions">' .
1628 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1629 $context->msg( 'word-separator' )->escaped() . Linker
::linkKnown( $title,
1630 $context->msg( 'history' )->escaped(),
1632 [ 'action' => 'history' ] ) .
1636 if ( $title->isBigDeletion() ) {
1637 global $wgDeleteRevisionsLimit;
1638 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1640 'delete-warning-toobig',
1641 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1647 $this->confirmDelete( $reason );
1651 * Output deletion confirmation dialog
1652 * @todo FIXME: Move to another file?
1653 * @param string $reason Prefilled reason
1655 public function confirmDelete( $reason ) {
1656 wfDebug( "Article::confirmDelete\n" );
1658 $title = $this->getTitle();
1659 $ctx = $this->getContext();
1660 $outputPage = $ctx->getOutput();
1661 $useMediaWikiUIEverywhere = $ctx->getConfig()->get( 'UseMediaWikiUIEverywhere' );
1662 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1663 $outputPage->addBacklinkSubtitle( $title );
1664 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1665 $backlinkCache = $title->getBacklinkCache();
1666 if ( $backlinkCache->hasLinks( 'pagelinks' ) ||
$backlinkCache->hasLinks( 'templatelinks' ) ) {
1667 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1668 'deleting-backlinks-warning' );
1670 $outputPage->addWikiMsg( 'confirmdeletetext' );
1672 Hooks
::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1674 $user = $this->getContext()->getUser();
1675 if ( $user->isAllowed( 'suppressrevision' ) ) {
1676 $suppress = Html
::openElement( 'div', [ 'id' => 'wpDeleteSuppressRow' ] ) .
1677 Xml
::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
1678 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '4' ] ) .
1679 Html
::closeElement( 'div' );
1683 $checkWatch = $user->getBoolOption( 'watchdeletion' ) ||
$user->isWatched( $title );
1684 $form = Html
::openElement( 'form', [ 'method' => 'post',
1685 'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ] ) .
1686 Html
::openElement( 'fieldset', [ 'id' => 'mw-delete-table' ] ) .
1687 Html
::element( 'legend', null, wfMessage( 'delete-legend' )->text() ) .
1688 Html
::openElement( 'div', [ 'id' => 'mw-deleteconfirm-table' ] ) .
1689 Html
::openElement( 'div', [ 'id' => 'wpDeleteReasonListRow' ] ) .
1690 Html
::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
1693 'wpDeleteReasonList',
1694 wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
1695 wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(),
1700 Html
::closeElement( 'div' ) .
1701 Html
::openElement( 'div', [ 'id' => 'wpDeleteReasonRow' ] ) .
1702 Html
::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) .
1704 Html
::input( 'wpReason', $reason, 'text', [
1706 'maxlength' => '255',
1709 'class' => 'mw-ui-input-inline',
1712 Html
::closeElement( 'div' );
1714 # Disallow watching if user is not logged in
1715 if ( $user->isLoggedIn() ) {
1717 Xml
::checkLabel( wfMessage( 'watchthis' )->text(),
1718 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] );
1722 Html
::openElement( 'div' ) .
1724 Xml
::submitButton( wfMessage( 'deletepage' )->text(),
1726 'name' => 'wpConfirmB',
1727 'id' => 'wpConfirmB',
1729 'class' => $useMediaWikiUIEverywhere ?
'mw-ui-button mw-ui-destructive' : '',
1732 Html
::closeElement( 'div' ) .
1733 Html
::closeElement( 'div' ) .
1734 Xml
::closeElement( 'fieldset' ) .
1737 $user->getEditToken( [ 'delete', $title->getPrefixedText() ] )
1739 Xml
::closeElement( 'form' );
1741 if ( $user->isAllowed( 'editinterface' ) ) {
1742 $link = Linker
::linkKnown(
1743 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1744 wfMessage( 'delete-edit-reasonlist' )->escaped(),
1746 [ 'action' => 'edit' ]
1748 $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
1751 $outputPage->addHTML( $form );
1753 $deleteLogPage = new LogPage( 'delete' );
1754 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1755 LogEventsList
::showLogExtract( $outputPage, 'delete', $title );
1759 * Perform a deletion and output success or failure messages
1760 * @param string $reason
1761 * @param bool $suppress
1763 public function doDelete( $reason, $suppress = false ) {
1765 $context = $this->getContext();
1766 $outputPage = $context->getOutput();
1767 $user = $context->getUser();
1768 $status = $this->mPage
->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
1770 if ( $status->isGood() ) {
1771 $deleted = $this->getTitle()->getPrefixedText();
1773 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1774 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1776 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1778 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1780 Hooks
::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
1782 $outputPage->returnToMain( false );
1784 $outputPage->setPageTitle(
1785 wfMessage( 'cannotdelete-title',
1786 $this->getTitle()->getPrefixedText() )
1789 if ( $error == '' ) {
1790 $outputPage->addWikiText(
1791 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1793 $deleteLogPage = new LogPage( 'delete' );
1794 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1796 LogEventsList
::showLogExtract(
1802 $outputPage->addHTML( $error );
1807 /* Caching functions */
1810 * checkLastModified returns true if it has taken care of all
1811 * output to the client that is necessary for this request.
1812 * (that is, it has sent a cached version of the page)
1814 * @return bool True if cached version send, false otherwise
1816 protected function tryFileCache() {
1817 static $called = false;
1820 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1825 if ( $this->isFileCacheable() ) {
1826 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
1827 if ( $cache->isCacheGood( $this->mPage
->getTouched() ) ) {
1828 wfDebug( "Article::tryFileCache(): about to load file\n" );
1829 $cache->loadFromFileCache( $this->getContext() );
1832 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1833 ob_start( [ &$cache, 'saveToFileCache' ] );
1836 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1843 * Check if the page can be cached
1844 * @param integer $mode One of the HTMLFileCache::MODE_* constants (since 1.28)
1847 public function isFileCacheable( $mode = HTMLFileCache
::MODE_NORMAL
) {
1850 if ( HTMLFileCache
::useFileCache( $this->getContext(), $mode ) ) {
1851 $cacheable = $this->mPage
->getId()
1852 && !$this->mRedirectedFrom
&& !$this->getTitle()->isRedirect();
1853 // Extension may have reason to disable file caching on some pages.
1855 // Avoid PHP 7.1 warning of passing $this by reference
1856 $articlePage = $this;
1857 $cacheable = Hooks
::run( 'IsFileCacheable', [ &$articlePage ] );
1867 * Lightweight method to get the parser output for a page, checking the parser cache
1868 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1869 * consider, so it's not appropriate to use there.
1871 * @since 1.16 (r52326) for LiquidThreads
1873 * @param int|null $oldid Revision ID or null
1874 * @param User $user The relevant user
1875 * @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
1877 public function getParserOutput( $oldid = null, User
$user = null ) {
1878 // XXX: bypasses mParserOptions and thus setParserOptions()
1880 if ( $user === null ) {
1881 $parserOptions = $this->getParserOptions();
1883 $parserOptions = $this->mPage
->makeParserOptions( $user );
1886 return $this->mPage
->getParserOutput( $parserOptions, $oldid );
1890 * Override the ParserOptions used to render the primary article wikitext.
1892 * @param ParserOptions $options
1893 * @throws MWException If the parser options where already initialized.
1895 public function setParserOptions( ParserOptions
$options ) {
1896 if ( $this->mParserOptions
) {
1897 throw new MWException( "can't change parser options after they have already been set" );
1900 // clone, so if $options is modified later, it doesn't confuse the parser cache.
1901 $this->mParserOptions
= clone $options;
1905 * Get parser options suitable for rendering the primary article wikitext
1906 * @return ParserOptions
1908 public function getParserOptions() {
1909 if ( !$this->mParserOptions
) {
1910 $this->mParserOptions
= $this->mPage
->makeParserOptions( $this->getContext() );
1912 // Clone to allow modifications of the return value without affecting cache
1913 return clone $this->mParserOptions
;
1917 * Sets the context this Article is executed in
1919 * @param IContextSource $context
1922 public function setContext( $context ) {
1923 $this->mContext
= $context;
1927 * Gets the context this Article is executed in
1929 * @return IContextSource
1932 public function getContext() {
1933 if ( $this->mContext
instanceof IContextSource
) {
1934 return $this->mContext
;
1936 wfDebug( __METHOD__
. " called and \$mContext is null. " .
1937 "Return RequestContext::getMain(); for sanity\n" );
1938 return RequestContext
::getMain();
1943 * Use PHP's magic __get handler to handle accessing of
1944 * raw WikiPage fields for backwards compatibility.
1946 * @param string $fname Field name
1949 public function __get( $fname ) {
1950 if ( property_exists( $this->mPage
, $fname ) ) {
1951 # wfWarn( "Access to raw $fname field " . __CLASS__ );
1952 return $this->mPage
->$fname;
1954 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE
);
1958 * Use PHP's magic __set handler to handle setting of
1959 * raw WikiPage fields for backwards compatibility.
1961 * @param string $fname Field name
1962 * @param mixed $fvalue New value
1964 public function __set( $fname, $fvalue ) {
1965 if ( property_exists( $this->mPage
, $fname ) ) {
1966 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
1967 $this->mPage
->$fname = $fvalue;
1968 // Note: extensions may want to toss on new fields
1969 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
1970 $this->mPage
->$fname = $fvalue;
1972 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE
);
1977 * Call to WikiPage function for backwards compatibility.
1978 * @see WikiPage::checkFlags
1980 public function checkFlags( $flags ) {
1981 return $this->mPage
->checkFlags( $flags );
1985 * Call to WikiPage function for backwards compatibility.
1986 * @see WikiPage::checkTouched
1988 public function checkTouched() {
1989 return $this->mPage
->checkTouched();
1993 * Call to WikiPage function for backwards compatibility.
1994 * @see WikiPage::clearPreparedEdit
1996 public function clearPreparedEdit() {
1997 $this->mPage
->clearPreparedEdit();
2001 * Call to WikiPage function for backwards compatibility.
2002 * @see WikiPage::doDeleteArticleReal
2004 public function doDeleteArticleReal(
2005 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User
$user = null,
2008 return $this->mPage
->doDeleteArticleReal(
2009 $reason, $suppress, $u1, $u2, $error, $user, $tags
2014 * Call to WikiPage function for backwards compatibility.
2015 * @see WikiPage::doDeleteUpdates
2017 public function doDeleteUpdates( $id, Content
$content = null ) {
2018 return $this->mPage
->doDeleteUpdates( $id, $content );
2022 * Call to WikiPage function for backwards compatibility.
2023 * @deprecated since 1.29. Use WikiPage::doEditContent() directly instead
2024 * @see WikiPage::doEditContent
2026 public function doEditContent( Content
$content, $summary, $flags = 0, $baseRevId = false,
2027 User
$user = null, $serialFormat = null
2029 wfDeprecated( __METHOD__
, '1.29' );
2030 return $this->mPage
->doEditContent( $content, $summary, $flags, $baseRevId,
2031 $user, $serialFormat
2036 * Call to WikiPage function for backwards compatibility.
2037 * @see WikiPage::doEditUpdates
2039 public function doEditUpdates( Revision
$revision, User
$user, array $options = [] ) {
2040 return $this->mPage
->doEditUpdates( $revision, $user, $options );
2044 * Call to WikiPage function for backwards compatibility.
2045 * @see WikiPage::doPurge
2046 * @note In 1.28 (and only 1.28), this took a $flags parameter that
2047 * controlled how much purging was done.
2049 public function doPurge() {
2050 return $this->mPage
->doPurge();
2054 * Call to WikiPage function for backwards compatibility.
2055 * @see WikiPage::getLastPurgeTimestamp
2056 * @deprecated since 1.29
2058 public function getLastPurgeTimestamp() {
2059 wfDeprecated( __METHOD__
, '1.29' );
2060 return $this->mPage
->getLastPurgeTimestamp();
2064 * Call to WikiPage function for backwards compatibility.
2065 * @see WikiPage::doViewUpdates
2067 public function doViewUpdates( User
$user, $oldid = 0 ) {
2068 $this->mPage
->doViewUpdates( $user, $oldid );
2072 * Call to WikiPage function for backwards compatibility.
2073 * @see WikiPage::exists
2075 public function exists() {
2076 return $this->mPage
->exists();
2080 * Call to WikiPage function for backwards compatibility.
2081 * @see WikiPage::followRedirect
2083 public function followRedirect() {
2084 return $this->mPage
->followRedirect();
2088 * Call to WikiPage function for backwards compatibility.
2089 * @see ContentHandler::getActionOverrides
2091 public function getActionOverrides() {
2092 return $this->mPage
->getActionOverrides();
2096 * Call to WikiPage function for backwards compatibility.
2097 * @see WikiPage::getAutoDeleteReason
2099 public function getAutoDeleteReason( &$hasHistory ) {
2100 return $this->mPage
->getAutoDeleteReason( $hasHistory );
2104 * Call to WikiPage function for backwards compatibility.
2105 * @see WikiPage::getCategories
2107 public function getCategories() {
2108 return $this->mPage
->getCategories();
2112 * Call to WikiPage function for backwards compatibility.
2113 * @see WikiPage::getComment
2115 public function getComment( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2116 return $this->mPage
->getComment( $audience, $user );
2120 * Call to WikiPage function for backwards compatibility.
2121 * @see WikiPage::getContentHandler
2123 public function getContentHandler() {
2124 return $this->mPage
->getContentHandler();
2128 * Call to WikiPage function for backwards compatibility.
2129 * @see WikiPage::getContentModel
2131 public function getContentModel() {
2132 return $this->mPage
->getContentModel();
2136 * Call to WikiPage function for backwards compatibility.
2137 * @see WikiPage::getContributors
2139 public function getContributors() {
2140 return $this->mPage
->getContributors();
2144 * Call to WikiPage function for backwards compatibility.
2145 * @see WikiPage::getCreator
2147 public function getCreator( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2148 return $this->mPage
->getCreator( $audience, $user );
2152 * Call to WikiPage function for backwards compatibility.
2153 * @see WikiPage::getDeletionUpdates
2155 public function getDeletionUpdates( Content
$content = null ) {
2156 return $this->mPage
->getDeletionUpdates( $content );
2160 * Call to WikiPage function for backwards compatibility.
2161 * @see WikiPage::getHiddenCategories
2163 public function getHiddenCategories() {
2164 return $this->mPage
->getHiddenCategories();
2168 * Call to WikiPage function for backwards compatibility.
2169 * @see WikiPage::getId
2171 public function getId() {
2172 return $this->mPage
->getId();
2176 * Call to WikiPage function for backwards compatibility.
2177 * @see WikiPage::getLatest
2179 public function getLatest() {
2180 return $this->mPage
->getLatest();
2184 * Call to WikiPage function for backwards compatibility.
2185 * @see WikiPage::getLinksTimestamp
2187 public function getLinksTimestamp() {
2188 return $this->mPage
->getLinksTimestamp();
2192 * Call to WikiPage function for backwards compatibility.
2193 * @see WikiPage::getMinorEdit
2195 public function getMinorEdit() {
2196 return $this->mPage
->getMinorEdit();
2200 * Call to WikiPage function for backwards compatibility.
2201 * @see WikiPage::getOldestRevision
2203 public function getOldestRevision() {
2204 return $this->mPage
->getOldestRevision();
2208 * Call to WikiPage function for backwards compatibility.
2209 * @see WikiPage::getRedirectTarget
2211 public function getRedirectTarget() {
2212 return $this->mPage
->getRedirectTarget();
2216 * Call to WikiPage function for backwards compatibility.
2217 * @see WikiPage::getRedirectURL
2219 public function getRedirectURL( $rt ) {
2220 return $this->mPage
->getRedirectURL( $rt );
2224 * Call to WikiPage function for backwards compatibility.
2225 * @see WikiPage::getRevision
2227 public function getRevision() {
2228 return $this->mPage
->getRevision();
2232 * Call to WikiPage function for backwards compatibility.
2233 * @see WikiPage::getTimestamp
2235 public function getTimestamp() {
2236 return $this->mPage
->getTimestamp();
2240 * Call to WikiPage function for backwards compatibility.
2241 * @see WikiPage::getTouched
2243 public function getTouched() {
2244 return $this->mPage
->getTouched();
2248 * Call to WikiPage function for backwards compatibility.
2249 * @see WikiPage::getUndoContent
2251 public function getUndoContent( Revision
$undo, Revision
$undoafter = null ) {
2252 return $this->mPage
->getUndoContent( $undo, $undoafter );
2256 * Call to WikiPage function for backwards compatibility.
2257 * @see WikiPage::getUser
2259 public function getUser( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2260 return $this->mPage
->getUser( $audience, $user );
2264 * Call to WikiPage function for backwards compatibility.
2265 * @see WikiPage::getUserText
2267 public function getUserText( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2268 return $this->mPage
->getUserText( $audience, $user );
2272 * Call to WikiPage function for backwards compatibility.
2273 * @see WikiPage::hasViewableContent
2275 public function hasViewableContent() {
2276 return $this->mPage
->hasViewableContent();
2280 * Call to WikiPage function for backwards compatibility.
2281 * @see WikiPage::insertOn
2283 public function insertOn( $dbw, $pageId = null ) {
2284 return $this->mPage
->insertOn( $dbw, $pageId );
2288 * Call to WikiPage function for backwards compatibility.
2289 * @see WikiPage::insertProtectNullRevision
2291 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2292 array $expiry, $cascade, $reason, $user = null
2294 return $this->mPage
->insertProtectNullRevision( $revCommentMsg, $limit,
2295 $expiry, $cascade, $reason, $user
2300 * Call to WikiPage function for backwards compatibility.
2301 * @see WikiPage::insertRedirect
2303 public function insertRedirect() {
2304 return $this->mPage
->insertRedirect();
2308 * Call to WikiPage function for backwards compatibility.
2309 * @see WikiPage::insertRedirectEntry
2311 public function insertRedirectEntry( Title
$rt, $oldLatest = null ) {
2312 return $this->mPage
->insertRedirectEntry( $rt, $oldLatest );
2316 * Call to WikiPage function for backwards compatibility.
2317 * @see WikiPage::isCountable
2319 public function isCountable( $editInfo = false ) {
2320 return $this->mPage
->isCountable( $editInfo );
2324 * Call to WikiPage function for backwards compatibility.
2325 * @see WikiPage::isRedirect
2327 public function isRedirect() {
2328 return $this->mPage
->isRedirect();
2332 * Call to WikiPage function for backwards compatibility.
2333 * @see WikiPage::loadFromRow
2335 public function loadFromRow( $data, $from ) {
2336 return $this->mPage
->loadFromRow( $data, $from );
2340 * Call to WikiPage function for backwards compatibility.
2341 * @see WikiPage::loadPageData
2343 public function loadPageData( $from = 'fromdb' ) {
2344 $this->mPage
->loadPageData( $from );
2348 * Call to WikiPage function for backwards compatibility.
2349 * @see WikiPage::lockAndGetLatest
2351 public function lockAndGetLatest() {
2352 return $this->mPage
->lockAndGetLatest();
2356 * Call to WikiPage function for backwards compatibility.
2357 * @see WikiPage::makeParserOptions
2359 public function makeParserOptions( $context ) {
2360 return $this->mPage
->makeParserOptions( $context );
2364 * Call to WikiPage function for backwards compatibility.
2365 * @see WikiPage::pageDataFromId
2367 public function pageDataFromId( $dbr, $id, $options = [] ) {
2368 return $this->mPage
->pageDataFromId( $dbr, $id, $options );
2372 * Call to WikiPage function for backwards compatibility.
2373 * @see WikiPage::pageDataFromTitle
2375 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2376 return $this->mPage
->pageDataFromTitle( $dbr, $title, $options );
2380 * Call to WikiPage function for backwards compatibility.
2381 * @see WikiPage::prepareContentForEdit
2383 public function prepareContentForEdit(
2384 Content
$content, $revision = null, User
$user = null,
2385 $serialFormat = null, $useCache = true
2387 return $this->mPage
->prepareContentForEdit(
2388 $content, $revision, $user,
2389 $serialFormat, $useCache
2394 * Call to WikiPage function for backwards compatibility.
2395 * @see WikiPage::protectDescription
2397 public function protectDescription( array $limit, array $expiry ) {
2398 return $this->mPage
->protectDescription( $limit, $expiry );
2402 * Call to WikiPage function for backwards compatibility.
2403 * @see WikiPage::protectDescriptionLog
2405 public function protectDescriptionLog( array $limit, array $expiry ) {
2406 return $this->mPage
->protectDescriptionLog( $limit, $expiry );
2410 * Call to WikiPage function for backwards compatibility.
2411 * @see WikiPage::replaceSectionAtRev
2413 public function replaceSectionAtRev( $sectionId, Content
$sectionContent,
2414 $sectionTitle = '', $baseRevId = null
2416 return $this->mPage
->replaceSectionAtRev( $sectionId, $sectionContent,
2417 $sectionTitle, $baseRevId
2422 * Call to WikiPage function for backwards compatibility.
2423 * @see WikiPage::replaceSectionContent
2425 public function replaceSectionContent(
2426 $sectionId, Content
$sectionContent, $sectionTitle = '', $edittime = null
2428 return $this->mPage
->replaceSectionContent(
2429 $sectionId, $sectionContent, $sectionTitle, $edittime
2434 * Call to WikiPage function for backwards compatibility.
2435 * @see WikiPage::setTimestamp
2437 public function setTimestamp( $ts ) {
2438 return $this->mPage
->setTimestamp( $ts );
2442 * Call to WikiPage function for backwards compatibility.
2443 * @see WikiPage::shouldCheckParserCache
2445 public function shouldCheckParserCache( ParserOptions
$parserOptions, $oldId ) {
2446 return $this->mPage
->shouldCheckParserCache( $parserOptions, $oldId );
2450 * Call to WikiPage function for backwards compatibility.
2451 * @see WikiPage::supportsSections
2453 public function supportsSections() {
2454 return $this->mPage
->supportsSections();
2458 * Call to WikiPage function for backwards compatibility.
2459 * @see WikiPage::triggerOpportunisticLinksUpdate
2461 public function triggerOpportunisticLinksUpdate( ParserOutput
$parserOutput ) {
2462 return $this->mPage
->triggerOpportunisticLinksUpdate( $parserOutput );
2466 * Call to WikiPage function for backwards compatibility.
2467 * @see WikiPage::updateCategoryCounts
2469 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2470 return $this->mPage
->updateCategoryCounts( $added, $deleted, $id );
2474 * Call to WikiPage function for backwards compatibility.
2475 * @see WikiPage::updateIfNewerOn
2477 public function updateIfNewerOn( $dbw, $revision ) {
2478 return $this->mPage
->updateIfNewerOn( $dbw, $revision );
2482 * Call to WikiPage function for backwards compatibility.
2483 * @see WikiPage::updateRedirectOn
2485 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2486 return $this->mPage
->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null );
2490 * Call to WikiPage function for backwards compatibility.
2491 * @see WikiPage::updateRevisionOn
2493 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2494 $lastRevIsRedirect = null
2496 return $this->mPage
->updateRevisionOn( $dbw, $revision, $lastRevision,
2502 * @param array $limit
2503 * @param array $expiry
2504 * @param bool $cascade
2505 * @param string $reason
2509 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2512 return $this->mPage
->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2516 * @param array $limit
2517 * @param string $reason
2518 * @param int $cascade
2519 * @param array $expiry
2522 public function updateRestrictions( $limit = [], $reason = '',
2523 &$cascade = 0, $expiry = []
2525 return $this->mPage
->doUpdateRestrictions(
2530 $this->getContext()->getUser()
2535 * @param string $reason
2536 * @param bool $suppress
2537 * @param int $u1 Unused
2538 * @param bool $u2 Unused
2539 * @param string $error
2542 public function doDeleteArticle(
2543 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2545 return $this->mPage
->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2549 * @param string $fromP
2550 * @param string $summary
2551 * @param string $token
2553 * @param array $resultDetails
2554 * @param User|null $user
2557 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User
$user = null ) {
2558 $user = is_null( $user ) ?
$this->getContext()->getUser() : $user;
2559 return $this->mPage
->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2563 * @param string $fromP
2564 * @param string $summary
2566 * @param array $resultDetails
2567 * @param User|null $guser
2570 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User
$guser = null ) {
2571 $guser = is_null( $guser ) ?
$this->getContext()->getUser() : $guser;
2572 return $this->mPage
->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2576 * @param bool $hasHistory
2579 public function generateReason( &$hasHistory ) {
2580 $title = $this->mPage
->getTitle();
2581 $handler = ContentHandler
::getForTitle( $title );
2582 return $handler->getAutoDeleteReason( $title, $hasHistory );
2588 * @deprecated since 1.24, use WikiPage::selectFields() instead
2590 public static function selectFields() {
2591 wfDeprecated( __METHOD__
, '1.24' );
2592 return WikiPage
::selectFields();
2596 * @param Title $title
2598 * @deprecated since 1.24, use WikiPage::onArticleCreate() instead
2600 public static function onArticleCreate( $title ) {
2601 wfDeprecated( __METHOD__
, '1.24' );
2602 WikiPage
::onArticleCreate( $title );
2606 * @param Title $title
2608 * @deprecated since 1.24, use WikiPage::onArticleDelete() instead
2610 public static function onArticleDelete( $title ) {
2611 wfDeprecated( __METHOD__
, '1.24' );
2612 WikiPage
::onArticleDelete( $title );
2616 * @param Title $title
2618 * @deprecated since 1.24, use WikiPage::onArticleEdit() instead
2620 public static function onArticleEdit( $title ) {
2621 wfDeprecated( __METHOD__
, '1.24' );
2622 WikiPage
::onArticleEdit( $title );