cc3ef26b6ba83090320622a637c2f746c78fb928
3 * User interface for page actions.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 * Class for viewing MediaWiki article and history.
26 * This maintains WikiPage functions for backwards compatibility.
28 * @todo Move and rewrite code to an Action class
30 * See design.txt for an overview.
31 * Note: edit user interface and cache support functions have been
32 * moved to separate EditPage and HTMLFileCache classes.
34 class Article
implements Page
{
35 /** @var IContextSource The context this Article is executed in */
38 /** @var WikiPage The WikiPage object of this instance */
41 /** @var ParserOptions ParserOptions object for $wgUser articles */
42 public $mParserOptions;
45 * @var string Text of the revision we are working on
51 * @var Content Content of the revision we are working on
54 public $mContentObject;
56 /** @var bool Is the content ($mContent) already loaded? */
57 public $mContentLoaded = false;
59 /** @var int|null The oldid of the article that is to be shown, 0 for the current revision */
62 /** @var Title Title from which we were redirected here */
63 public $mRedirectedFrom = null;
65 /** @var string|bool URL to redirect to or false if none */
66 public $mRedirectUrl = false;
68 /** @var int Revision ID of revision we are working on */
69 public $mRevIdFetched = 0;
71 /** @var Revision Revision we are working on */
72 public $mRevision = null;
74 /** @var ParserOutput */
75 public $mParserOutput;
78 * Constructor and clear the article
79 * @param Title $title Reference to a Title object.
80 * @param int $oldId Revision ID, null to fetch from request, zero for current
82 public function __construct( Title
$title, $oldId = null ) {
83 $this->mOldId
= $oldId;
84 $this->mPage
= $this->newPage( $title );
91 protected function newPage( Title
$title ) {
92 return new WikiPage( $title );
96 * Constructor from a page id
97 * @param int $id Article ID to load
98 * @return Article|null
100 public static function newFromID( $id ) {
101 $t = Title
::newFromID( $id );
102 return $t == null ?
null : new static( $t );
106 * Create an Article object of the appropriate class for the given page.
108 * @param Title $title
109 * @param IContextSource $context
112 public static function newFromTitle( $title, IContextSource
$context ) {
113 if ( NS_MEDIA
== $title->getNamespace() ) {
114 // FIXME: where should this go?
115 $title = Title
::makeTitle( NS_FILE
, $title->getDBkey() );
119 Hooks
::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
121 switch ( $title->getNamespace() ) {
123 $page = new ImagePage( $title );
126 $page = new CategoryPage( $title );
129 $page = new Article( $title );
132 $page->setContext( $context );
138 * Create an Article object of the appropriate class for the given page.
140 * @param WikiPage $page
141 * @param IContextSource $context
144 public static function newFromWikiPage( WikiPage
$page, IContextSource
$context ) {
145 $article = self
::newFromTitle( $page->getTitle(), $context );
146 $article->mPage
= $page; // override to keep process cached vars
151 * Get the page this view was redirected from
155 public function getRedirectedFrom() {
156 return $this->mRedirectedFrom
;
160 * Tell the page view functions that this view was redirected
161 * from another page on the wiki.
164 public function setRedirectedFrom( Title
$from ) {
165 $this->mRedirectedFrom
= $from;
169 * Get the title object of the article
171 * @return Title Title object of this page
173 public function getTitle() {
174 return $this->mPage
->getTitle();
178 * Get the WikiPage object of this instance
183 public function getPage() {
190 public function clear() {
191 $this->mContentLoaded
= false;
193 $this->mRedirectedFrom
= null; # Title object if set
194 $this->mRevIdFetched
= 0;
195 $this->mRedirectUrl
= false;
197 $this->mPage
->clear();
201 * Note that getContent does not follow redirects anymore.
202 * If you need to fetch redirectable content easily, try
203 * the shortcut in WikiPage::getRedirectTarget()
205 * This function has side effects! Do not use this function if you
206 * only want the real revision text if any.
208 * @deprecated since 1.21; use WikiPage::getContent() instead
210 * @return string Return the text of this revision
212 public function getContent() {
213 wfDeprecated( __METHOD__
, '1.21' );
214 $content = $this->getContentObject();
215 return ContentHandler
::getContentText( $content );
219 * Returns a Content object representing the pages effective display content,
220 * not necessarily the revision's content!
222 * Note that getContent does not follow redirects anymore.
223 * If you need to fetch redirectable content easily, try
224 * the shortcut in WikiPage::getRedirectTarget()
226 * This function has side effects! Do not use this function if you
227 * only want the real revision text if any.
229 * @return Content Return the content of this revision
233 protected function getContentObject() {
235 if ( $this->mPage
->getId() === 0 ) {
236 # If this is a MediaWiki:x message, then load the messages
237 # and return the message value for x.
238 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI
) {
239 $text = $this->getTitle()->getDefaultMessageText();
240 if ( $text === false ) {
244 $content = ContentHandler
::makeContent( $text, $this->getTitle() );
246 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
247 $content = new MessageContent( $message, null, 'parsemag' );
250 $this->fetchContentObject();
251 $content = $this->mContentObject
;
258 * @return int The oldid of the article that is to be shown, 0 for the current revision
260 public function getOldID() {
261 if ( is_null( $this->mOldId
) ) {
262 $this->mOldId
= $this->getOldIDFromRequest();
265 return $this->mOldId
;
269 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
271 * @return int The old id for the request
273 public function getOldIDFromRequest() {
274 $this->mRedirectUrl
= false;
276 $request = $this->getContext()->getRequest();
277 $oldid = $request->getIntOrNull( 'oldid' );
279 if ( $oldid === null ) {
283 if ( $oldid !== 0 ) {
284 # Load the given revision and check whether the page is another one.
285 # In that case, update this instance to reflect the change.
286 if ( $oldid === $this->mPage
->getLatest() ) {
287 $this->mRevision
= $this->mPage
->getRevision();
289 $this->mRevision
= Revision
::newFromId( $oldid );
290 if ( $this->mRevision
!== null ) {
291 // Revision title doesn't match the page title given?
292 if ( $this->mPage
->getId() != $this->mRevision
->getPage() ) {
293 $function = [ get_class( $this->mPage
), 'newFromID' ];
294 $this->mPage
= call_user_func( $function, $this->mRevision
->getPage() );
300 if ( $request->getVal( 'direction' ) == 'next' ) {
301 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
304 $this->mRevision
= null;
306 $this->mRedirectUrl
= $this->getTitle()->getFullURL( 'redirect=no' );
308 } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
309 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
312 $this->mRevision
= null;
320 * Get text of an article from database
321 * Does *NOT* follow redirects.
324 * @note This is really internal functionality that should really NOT be
325 * used by other functions. For accessing article content, use the WikiPage
326 * class, especially WikiBase::getContent(). However, a lot of legacy code
327 * uses this method to retrieve page text from the database, so the function
328 * has to remain public for now.
330 * @return string|bool String containing article contents, or false if null
331 * @deprecated since 1.21, use WikiPage::getContent() instead
333 function fetchContent() {
336 wfDeprecated( __METHOD__
, '1.21' );
338 if ( $this->mContentLoaded
&& $this->mContent
) {
339 return $this->mContent
;
342 $content = $this->fetchContentObject();
348 // @todo Get rid of mContent everywhere!
349 $this->mContent
= ContentHandler
::getContentText( $content );
350 ContentHandler
::runLegacyHooks(
351 'ArticleAfterFetchContent',
352 [ &$this, &$this->mContent
],
356 return $this->mContent
;
360 * Get text content object
361 * Does *NOT* follow redirects.
362 * @todo When is this null?
364 * @note Code that wants to retrieve page content from the database should
365 * use WikiPage::getContent().
367 * @return Content|null|bool
371 protected function fetchContentObject() {
372 if ( $this->mContentLoaded
) {
373 return $this->mContentObject
;
376 $this->mContentLoaded
= true;
377 $this->mContent
= null;
379 $oldid = $this->getOldID();
381 # Pre-fill content with error message so that if something
382 # fails we'll have something telling us what we intended.
383 // XXX: this isn't page content but a UI message. horrible.
384 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
387 # $this->mRevision might already be fetched by getOldIDFromRequest()
388 if ( !$this->mRevision
) {
389 $this->mRevision
= Revision
::newFromId( $oldid );
390 if ( !$this->mRevision
) {
391 wfDebug( __METHOD__
. " failed to retrieve specified revision, id $oldid\n" );
396 $oldid = $this->mPage
->getLatest();
398 wfDebug( __METHOD__
. " failed to find page data for title " .
399 $this->getTitle()->getPrefixedText() . "\n" );
403 # Update error message with correct oldid
404 $this->mContentObject
= new MessageContent( 'missing-revision', [ $oldid ] );
406 $this->mRevision
= $this->mPage
->getRevision();
408 if ( !$this->mRevision
) {
409 wfDebug( __METHOD__
. " failed to retrieve current page, rev_id $oldid\n" );
414 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
415 // We should instead work with the Revision object when we need it...
416 // Loads if user is allowed
417 $content = $this->mRevision
->getContent(
418 Revision
::FOR_THIS_USER
,
419 $this->getContext()->getUser()
423 wfDebug( __METHOD__
. " failed to retrieve content of revision " .
424 $this->mRevision
->getId() . "\n" );
428 $this->mContentObject
= $content;
429 $this->mRevIdFetched
= $this->mRevision
->getId();
431 ContentHandler
::runLegacyHooks(
432 'ArticleAfterFetchContentObject',
433 [ &$this, &$this->mContentObject
],
437 return $this->mContentObject
;
441 * Returns true if the currently-referenced revision is the current edit
442 * to this page (and it exists).
445 public function isCurrent() {
446 # If no oldid, this is the current version.
447 if ( $this->getOldID() == 0 ) {
451 return $this->mPage
->exists() && $this->mRevision
&& $this->mRevision
->isCurrent();
455 * Get the fetched Revision object depending on request parameters or null
459 * @return Revision|null
461 public function getRevisionFetched() {
462 $this->fetchContentObject();
464 return $this->mRevision
;
468 * Use this to fetch the rev ID used on page views
470 * @return int Revision ID of last article revision
472 public function getRevIdFetched() {
473 if ( $this->mRevIdFetched
) {
474 return $this->mRevIdFetched
;
476 return $this->mPage
->getLatest();
481 * This is the default action of the index.php entry point: just view the
482 * page of the given title.
484 public function view() {
485 global $wgUseFileCache, $wgDebugToolbar;
487 # Get variables from query string
488 # As side effect this will load the revision and update the title
489 # in a revision ID is passed in the request, so this should remain
490 # the first call of this method even if $oldid is used way below.
491 $oldid = $this->getOldID();
493 $user = $this->getContext()->getUser();
494 # Another whitelist check in case getOldID() is altering the title
495 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
496 if ( count( $permErrors ) ) {
497 wfDebug( __METHOD__
. ": denied on secondary read check\n" );
498 throw new PermissionsError( 'read', $permErrors );
501 $outputPage = $this->getContext()->getOutput();
502 # getOldID() may as well want us to redirect somewhere else
503 if ( $this->mRedirectUrl
) {
504 $outputPage->redirect( $this->mRedirectUrl
);
505 wfDebug( __METHOD__
. ": redirecting due to oldid\n" );
510 # If we got diff in the query, we want to see a diff page instead of the article.
511 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
512 wfDebug( __METHOD__
. ": showing diff page\n" );
513 $this->showDiffPage();
518 # Set page title (may be overridden by DISPLAYTITLE)
519 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
521 $outputPage->setArticleFlag( true );
522 # Allow frames by default
523 $outputPage->allowClickjacking();
525 $parserCache = ParserCache
::singleton();
527 $parserOptions = $this->getParserOptions();
528 # Render printable version, use printable version cache
529 if ( $outputPage->isPrintable() ) {
530 $parserOptions->setIsPrintable( true );
531 $parserOptions->setEditSection( false );
532 } elseif ( !$this->isCurrent() ||
!$this->getTitle()->quickUserCan( 'edit', $user ) ) {
533 $parserOptions->setEditSection( false );
536 # Try client and file cache
537 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage
->checkTouched() ) {
538 # Try to stream the output from file cache
539 if ( $wgUseFileCache && $this->tryFileCache() ) {
540 wfDebug( __METHOD__
. ": done file cache\n" );
541 # tell wgOut that output is taken care of
542 $outputPage->disable();
543 $this->mPage
->doViewUpdates( $user, $oldid );
549 # Should the parser cache be used?
550 $useParserCache = $this->mPage
->shouldCheckParserCache( $parserOptions, $oldid );
551 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ?
'yes' : 'no' ) . "\n" );
552 if ( $user->getStubThreshold() ) {
553 $this->getContext()->getStats()->increment( 'pcache_miss_stub' );
556 $this->showRedirectedFromHeader();
557 $this->showNamespaceHeader();
559 # Iterate through the possible ways of constructing the output text.
560 # Keep going until $outputDone is set, or we run out of things to do.
563 $this->mParserOutput
= false;
565 while ( !$outputDone && ++
$pass ) {
568 Hooks
::run( 'ArticleViewHeader', [ &$this, &$outputDone, &$useParserCache ] );
571 # Early abort if the page doesn't exist
572 if ( !$this->mPage
->exists() ) {
573 wfDebug( __METHOD__
. ": showing missing article\n" );
574 $this->showMissingArticle();
575 $this->mPage
->doViewUpdates( $user );
579 # Try the parser cache
580 if ( $useParserCache ) {
581 $this->mParserOutput
= $parserCache->get( $this->mPage
, $parserOptions );
583 if ( $this->mParserOutput
!== false ) {
585 wfDebug( __METHOD__
. ": showing parser cache contents for current rev permalink\n" );
586 $this->setOldSubtitle( $oldid );
588 wfDebug( __METHOD__
. ": showing parser cache contents\n" );
590 $outputPage->addParserOutput( $this->mParserOutput
);
591 # Ensure that UI elements requiring revision ID have
592 # the correct version information.
593 $outputPage->setRevisionId( $this->mPage
->getLatest() );
594 # Preload timestamp to avoid a DB hit
595 $cachedTimestamp = $this->mParserOutput
->getTimestamp();
596 if ( $cachedTimestamp !== null ) {
597 $outputPage->setRevisionTimestamp( $cachedTimestamp );
598 $this->mPage
->setTimestamp( $cachedTimestamp );
605 # This will set $this->mRevision if needed
606 $this->fetchContentObject();
608 # Are we looking at an old revision
609 if ( $oldid && $this->mRevision
) {
610 $this->setOldSubtitle( $oldid );
612 if ( !$this->showDeletedRevisionHeader() ) {
613 wfDebug( __METHOD__
. ": cannot view deleted revision\n" );
618 # Ensure that UI elements requiring revision ID have
619 # the correct version information.
620 $outputPage->setRevisionId( $this->getRevIdFetched() );
621 # Preload timestamp to avoid a DB hit
622 $outputPage->setRevisionTimestamp( $this->mPage
->getTimestamp() );
624 if ( !Hooks
::run( 'ArticleContentViewCustom',
625 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
627 # Allow extensions do their own custom view for certain pages
632 # Run the parse, protected by a pool counter
633 wfDebug( __METHOD__
. ": doing uncached parse\n" );
635 $content = $this->getContentObject();
636 $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
637 $this->getRevIdFetched(), $useParserCache, $content );
639 if ( !$poolArticleView->execute() ) {
640 $error = $poolArticleView->getError();
642 $outputPage->clearHTML(); // for release() errors
643 $outputPage->enableClientCache( false );
644 $outputPage->setRobotPolicy( 'noindex,nofollow' );
646 $errortext = $error->getWikiText( false, 'view-pool-error' );
647 $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
649 # Connection or timeout error
653 $this->mParserOutput
= $poolArticleView->getParserOutput();
654 $outputPage->addParserOutput( $this->mParserOutput
);
655 if ( $content->getRedirectTarget() ) {
656 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
657 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
660 # Don't cache a dirty ParserOutput object
661 if ( $poolArticleView->getIsDirty() ) {
662 $outputPage->setCdnMaxage( 0 );
663 $outputPage->addHTML( "<!-- parser cache is expired, " .
664 "sending anyway due to pool overload-->\n" );
669 # Should be unreachable, but just in case...
675 # Get the ParserOutput actually *displayed* here.
676 # Note that $this->mParserOutput is the *current*/oldid version output.
677 $pOutput = ( $outputDone instanceof ParserOutput
)
678 ?
$outputDone // object fetched by hook
679 : $this->mParserOutput
;
681 # Adjust title for main page & pages with displaytitle
683 $this->adjustDisplayTitle( $pOutput );
686 # For the main page, overwrite the <title> element with the con-
687 # tents of 'pagetitle-view-mainpage' instead of the default (if
689 # This message always exists because it is in the i18n files
690 if ( $this->getTitle()->isMainPage() ) {
691 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
692 if ( !$msg->isDisabled() ) {
693 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
697 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
698 # This could use getTouched(), but that could be scary for major template edits.
699 $outputPage->adaptCdnTTL( $this->mPage
->getTimestamp(), IExpiringStore
::TTL_DAY
);
701 # Check for any __NOINDEX__ tags on the page using $pOutput
702 $policy = $this->getRobotPolicy( 'view', $pOutput );
703 $outputPage->setIndexPolicy( $policy['index'] );
704 $outputPage->setFollowPolicy( $policy['follow'] );
706 $this->showViewFooter();
707 $this->mPage
->doViewUpdates( $user, $oldid );
709 $outputPage->addModules( 'mediawiki.action.view.postEdit' );
713 * Adjust title for pages with displaytitle, -{T|}- or language conversion
714 * @param ParserOutput $pOutput
716 public function adjustDisplayTitle( ParserOutput
$pOutput ) {
717 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
718 $titleText = $pOutput->getTitleText();
719 if ( strval( $titleText ) !== '' ) {
720 $this->getContext()->getOutput()->setPageTitle( $titleText );
725 * Show a diff page according to current request variables. For use within
726 * Article::view() only, other callers should use the DifferenceEngine class.
729 protected function showDiffPage() {
730 $request = $this->getContext()->getRequest();
731 $user = $this->getContext()->getUser();
732 $diff = $request->getVal( 'diff' );
733 $rcid = $request->getVal( 'rcid' );
734 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
735 $purge = $request->getVal( 'action' ) == 'purge';
736 $unhide = $request->getInt( 'unhide' ) == 1;
737 $oldid = $this->getOldID();
739 $rev = $this->getRevisionFetched();
742 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
743 $msg = $this->getContext()->msg( 'difference-missing-revision' )
747 $this->getContext()->getOutput()->addHTML( $msg );
751 $contentHandler = $rev->getContentHandler();
752 $de = $contentHandler->createDifferenceEngine(
761 // DifferenceEngine directly fetched the revision:
762 $this->mRevIdFetched
= $de->mNewid
;
763 $de->showDiffPage( $diffOnly );
765 // Run view updates for the newer revision being diffed (and shown
766 // below the diff if not $diffOnly).
767 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
768 // New can be false, convert it to 0 - this conveniently means the latest revision
769 $this->mPage
->doViewUpdates( $user, (int)$new );
773 * Get the robot policy to be used for the current view
774 * @param string $action The action= GET parameter
775 * @param ParserOutput|null $pOutput
776 * @return array The policy that should be set
777 * @todo actions other than 'view'
779 public function getRobotPolicy( $action, $pOutput = null ) {
780 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
782 $ns = $this->getTitle()->getNamespace();
784 # Don't index user and user talk pages for blocked users (bug 11443)
785 if ( ( $ns == NS_USER ||
$ns == NS_USER_TALK
) && !$this->getTitle()->isSubpage() ) {
786 $specificTarget = null;
788 $titleText = $this->getTitle()->getText();
789 if ( IP
::isValid( $titleText ) ) {
790 $vagueTarget = $titleText;
792 $specificTarget = $titleText;
794 if ( Block
::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block
) {
796 'index' => 'noindex',
797 'follow' => 'nofollow'
802 if ( $this->mPage
->getId() === 0 ||
$this->getOldID() ) {
803 # Non-articles (special pages etc), and old revisions
805 'index' => 'noindex',
806 'follow' => 'nofollow'
808 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
809 # Discourage indexing of printable versions, but encourage following
811 'index' => 'noindex',
814 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
815 # For ?curid=x urls, disallow indexing
817 'index' => 'noindex',
822 # Otherwise, construct the policy based on the various config variables.
823 $policy = self
::formatRobotPolicy( $wgDefaultRobotPolicy );
825 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
826 # Honour customised robot policies for this namespace
827 $policy = array_merge(
829 self
::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
832 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
833 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
834 # a final sanity check that we have really got the parser output.
835 $policy = array_merge(
837 [ 'index' => $pOutput->getIndexPolicy() ]
841 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
842 # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
843 $policy = array_merge(
845 self
::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
853 * Converts a String robot policy into an associative array, to allow
854 * merging of several policies using array_merge().
855 * @param array|string $policy Returns empty array on null/false/'', transparent
856 * to already-converted arrays, converts string.
857 * @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
859 public static function formatRobotPolicy( $policy ) {
860 if ( is_array( $policy ) ) {
862 } elseif ( !$policy ) {
866 $policy = explode( ',', $policy );
867 $policy = array_map( 'trim', $policy );
870 foreach ( $policy as $var ) {
871 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
872 $arr['index'] = $var;
873 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
874 $arr['follow'] = $var;
882 * If this request is a redirect view, send "redirected from" subtitle to
883 * the output. Returns true if the header was needed, false if this is not
884 * a redirect view. Handles both local and remote redirects.
888 public function showRedirectedFromHeader() {
889 global $wgRedirectSources;
891 $context = $this->getContext();
892 $outputPage = $context->getOutput();
893 $request = $context->getRequest();
894 $rdfrom = $request->getVal( 'rdfrom' );
896 // Construct a URL for the current page view, but with the target title
897 $query = $request->getValues();
898 unset( $query['rdfrom'] );
899 unset( $query['title'] );
900 if ( $this->getTitle()->isRedirect() ) {
901 // Prevent double redirects
902 $query['redirect'] = 'no';
904 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
906 if ( isset( $this->mRedirectedFrom
) ) {
907 // This is an internally redirected page view.
908 // We'll need a backlink to the source page for navigation.
909 if ( Hooks
::run( 'ArticleViewRedirect', [ &$this ] ) ) {
910 $redir = Linker
::linkKnown(
911 $this->mRedirectedFrom
,
914 [ 'redirect' => 'no' ]
917 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
918 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
921 // Add the script to update the displayed URL and
922 // set the fragment if one was specified in the redirect
923 $outputPage->addJsConfigVars( [
924 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
926 $outputPage->addModules( 'mediawiki.action.view.redirect' );
928 // Add a <link rel="canonical"> tag
929 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
931 // Tell the output object that the user arrived at this article through a redirect
932 $outputPage->setRedirectedFrom( $this->mRedirectedFrom
);
936 } elseif ( $rdfrom ) {
937 // This is an externally redirected view, from some other wiki.
938 // If it was reported from a trusted site, supply a backlink.
939 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
940 $redir = Linker
::makeExternalLink( $rdfrom, $rdfrom );
941 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
942 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
945 // Add the script to update the displayed URL
946 $outputPage->addJsConfigVars( [
947 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
949 $outputPage->addModules( 'mediawiki.action.view.redirect' );
959 * Show a header specific to the namespace currently being viewed, like
960 * [[MediaWiki:Talkpagetext]]. For Article::view().
962 public function showNamespaceHeader() {
963 if ( $this->getTitle()->isTalkPage() ) {
964 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
965 $this->getContext()->getOutput()->wrapWikiMsg(
966 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
974 * Show the footer section of an ordinary page view
976 public function showViewFooter() {
977 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
978 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
979 && IP
::isValid( $this->getTitle()->getText() )
981 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
984 // Show a footer allowing the user to patrol the shown revision or page if possible
985 $patrolFooterShown = $this->showPatrolFooter();
987 Hooks
::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
991 * If patrol is possible, output a patrol UI box. This is called from the
992 * footer section of ordinary page views. If patrol is not possible or not
993 * desired, does nothing.
994 * Side effect: When the patrol link is build, this method will call
995 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
999 public function showPatrolFooter() {
1000 global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
1002 $outputPage = $this->getContext()->getOutput();
1003 $user = $this->getContext()->getUser();
1004 $title = $this->getTitle();
1007 if ( !$title->quickUserCan( 'patrol', $user )
1008 ||
!( $wgUseRCPatrol ||
$wgUseNPPatrol
1009 ||
( $wgUseFilePatrol && $title->inNamespace( NS_FILE
) ) )
1011 // Patrolling is disabled or the user isn't allowed to
1015 if ( $this->mRevision
1016 && !RecentChange
::isInRCLifespan( $this->mRevision
->getTimestamp(), 21600 )
1018 // The current revision is already older than what could be in the RC table
1019 // 6h tolerance because the RC might not be cleaned out regularly
1023 // Check for cached results
1024 $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() );
1025 $cache = ObjectCache
::getMainWANInstance();
1026 if ( $cache->get( $key ) ) {
1030 $dbr = wfGetDB( DB_REPLICA
);
1031 $oldestRevisionTimestamp = $dbr->selectField(
1033 'MIN( rev_timestamp )',
1034 [ 'rev_page' => $title->getArticleID() ],
1038 // New page patrol: Get the timestamp of the oldest revison which
1039 // the revision table holds for the given page. Then we look
1040 // whether it's within the RC lifespan and if it is, we try
1041 // to get the recentchanges row belonging to that entry
1042 // (with rc_new = 1).
1043 $recentPageCreation = false;
1044 if ( $oldestRevisionTimestamp
1045 && RecentChange
::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
1047 // 6h tolerance because the RC might not be cleaned out regularly
1048 $recentPageCreation = true;
1049 $rc = RecentChange
::newFromConds(
1052 'rc_timestamp' => $oldestRevisionTimestamp,
1053 'rc_namespace' => $title->getNamespace(),
1054 'rc_cur_id' => $title->getArticleID()
1059 // Use generic patrol message for new pages
1060 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1064 // File patrol: Get the timestamp of the latest upload for this page,
1065 // check whether it is within the RC lifespan and if it is, we try
1066 // to get the recentchanges row belonging to that entry
1067 // (with rc_type = RC_LOG, rc_log_type = upload).
1068 $recentFileUpload = false;
1069 if ( ( !$rc ||
$rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1070 && $title->getNamespace() === NS_FILE
) {
1071 // Retrieve timestamp of most recent upload
1072 $newestUploadTimestamp = $dbr->selectField(
1074 'MAX( img_timestamp )',
1075 [ 'img_name' => $title->getDBkey() ],
1078 if ( $newestUploadTimestamp
1079 && RecentChange
::isInRCLifespan( $newestUploadTimestamp, 21600 )
1081 // 6h tolerance because the RC might not be cleaned out regularly
1082 $recentFileUpload = true;
1083 $rc = RecentChange
::newFromConds(
1085 'rc_type' => RC_LOG
,
1086 'rc_log_type' => 'upload',
1087 'rc_timestamp' => $newestUploadTimestamp,
1088 'rc_namespace' => NS_FILE
,
1089 'rc_cur_id' => $title->getArticleID()
1092 [ 'USE INDEX' => 'rc_timestamp' ]
1095 // Use patrol message specific to files
1096 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1101 if ( !$recentPageCreation && !$recentFileUpload ) {
1102 // Page creation and latest upload (for files) is too old to be in RC
1104 // We definitely can't patrol so cache the information
1105 // When a new file version is uploaded, the cache is cleared
1106 $cache->set( $key, '1' );
1112 // Don't cache: This can be hit if the page gets accessed very fast after
1113 // its creation / latest upload or in case we have high replica DB lag. In case
1114 // the revision is too old, we will already return above.
1118 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1119 // Patrolled RC entry around
1121 // Cache the information we gathered above in case we can't patrol
1122 // Don't cache in case we can patrol as this could change
1123 $cache->set( $key, '1' );
1128 if ( $rc->getPerformer()->equals( $user ) ) {
1129 // Don't show a patrol link for own creations/uploads. If the user could
1130 // patrol them, they already would be patrolled
1134 $outputPage->preventClickjacking();
1135 if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
1136 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1139 $link = Linker
::linkKnown(
1141 $markPatrolledMsg->escaped(),
1144 'action' => 'markpatrolled',
1145 'rcid' => $rc->getAttribute( 'rc_id' ),
1149 $outputPage->addHTML(
1150 "<div class='patrollink' data-mw='interface'>" .
1151 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1159 * Purge the cache used to check if it is worth showing the patrol footer
1160 * For example, it is done during re-uploads when file patrol is used.
1161 * @param int $articleID ID of the article to purge
1164 public static function purgePatrolFooterCache( $articleID ) {
1165 $cache = ObjectCache
::getMainWANInstance();
1166 $cache->delete( wfMemcKey( 'unpatrollable-page', $articleID ) );
1170 * Show the error text for a missing article. For articles in the MediaWiki
1171 * namespace, show the default message text. To be called from Article::view().
1173 public function showMissingArticle() {
1174 global $wgSend404Code;
1176 $outputPage = $this->getContext()->getOutput();
1177 // Whether the page is a root user page of an existing user (but not a subpage)
1178 $validUserPage = false;
1180 $title = $this->getTitle();
1182 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1183 if ( $title->getNamespace() == NS_USER
1184 ||
$title->getNamespace() == NS_USER_TALK
1186 $rootPart = explode( '/', $title->getText() )[0];
1187 $user = User
::newFromName( $rootPart, false /* allow IP users*/ );
1188 $ip = User
::isIP( $rootPart );
1189 $block = Block
::newFromTarget( $user, $user );
1191 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1192 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1193 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1194 } elseif ( !is_null( $block ) && $block->getType() != Block
::TYPE_AUTO
) {
1195 # Show log extract if the user is currently blocked
1196 LogEventsList
::showLogExtract(
1199 MWNamespace
::getCanonicalName( NS_USER
) . ':' . $block->getTarget(),
1203 'showIfEmpty' => false,
1205 'blocked-notice-logextract',
1206 $user->getName() # Support GENDER in notice
1210 $validUserPage = !$title->isSubpage();
1212 $validUserPage = !$title->isSubpage();
1216 Hooks
::run( 'ShowMissingArticle', [ $this ] );
1218 # Show delete and move logs if there were any such events.
1219 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1220 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1221 $cache = ObjectCache
::getMainStashInstance();
1222 $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1223 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1224 if ( $loggedIn ||
$cache->get( $key ) ) {
1225 $logTypes = [ 'delete', 'move' ];
1226 $conds = [ "log_action != 'revision'" ];
1227 // Give extensions a chance to hide their (unrelated) log entries
1228 Hooks
::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1229 LogEventsList
::showLogExtract(
1237 'showIfEmpty' => false,
1238 'msgKey' => [ $loggedIn
1239 ?
'moveddeleted-notice'
1240 : 'moveddeleted-notice-recent'
1246 if ( !$this->mPage
->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1247 // If there's no backing content, send a 404 Not Found
1248 // for better machine handling of broken links.
1249 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1252 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1253 $policy = $this->getRobotPolicy( 'view' );
1254 $outputPage->setIndexPolicy( $policy['index'] );
1255 $outputPage->setFollowPolicy( $policy['follow'] );
1257 $hookResult = Hooks
::run( 'BeforeDisplayNoArticleText', [ $this ] );
1259 if ( !$hookResult ) {
1263 # Show error message
1264 $oldid = $this->getOldID();
1265 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI
&& $title->hasSourceText() ) {
1266 $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
1269 $text = wfMessage( 'missing-revision', $oldid )->plain();
1270 } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1271 && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1273 $message = $this->getContext()->getUser()->isLoggedIn() ?
'noarticletext' : 'noarticletextanon';
1274 $text = wfMessage( $message )->plain();
1276 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1279 $dir = $this->getContext()->getLanguage()->getDir();
1280 $lang = $this->getContext()->getLanguage()->getCode();
1281 $outputPage->addWikiText( Xml
::openElement( 'div', [
1282 'class' => "noarticletext mw-content-$dir",
1285 ] ) . "\n$text\n</div>" );
1290 * If the revision requested for view is deleted, check permissions.
1291 * Send either an error message or a warning header to the output.
1293 * @return bool True if the view is allowed, false if not.
1295 public function showDeletedRevisionHeader() {
1296 if ( !$this->mRevision
->isDeleted( Revision
::DELETED_TEXT
) ) {
1301 $outputPage = $this->getContext()->getOutput();
1302 $user = $this->getContext()->getUser();
1303 // If the user is not allowed to see it...
1304 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
, $user ) ) {
1305 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1306 'rev-deleted-text-permission' );
1309 // If the user needs to confirm that they want to see it...
1310 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1311 # Give explanation and add a link to view the revision...
1312 $oldid = intval( $this->getOldID() );
1313 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1314 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1315 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1316 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1320 // We are allowed to see...
1322 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1323 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1324 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1331 * Generate the navigation links when browsing through an article revisions
1332 * It shows the information as:
1333 * Revision as of \<date\>; view current revision
1334 * \<- Previous version | Next Version -\>
1336 * @param int $oldid Revision ID of this article revision
1338 public function setOldSubtitle( $oldid = 0 ) {
1339 if ( !Hooks
::run( 'DisplayOldSubtitle', [ &$this, &$oldid ] ) ) {
1343 $context = $this->getContext();
1344 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1346 # Cascade unhide param in links for easy deletion browsing
1349 $extraParams['unhide'] = 1;
1352 if ( $this->mRevision
&& $this->mRevision
->getId() === $oldid ) {
1353 $revision = $this->mRevision
;
1355 $revision = Revision
::newFromId( $oldid );
1358 $timestamp = $revision->getTimestamp();
1360 $current = ( $oldid == $this->mPage
->getLatest() );
1361 $language = $context->getLanguage();
1362 $user = $context->getUser();
1364 $td = $language->userTimeAndDate( $timestamp, $user );
1365 $tddate = $language->userDate( $timestamp, $user );
1366 $tdtime = $language->userTime( $timestamp, $user );
1368 # Show user links if allowed to see them. If hidden, then show them only if requested...
1369 $userlinks = Linker
::revUserTools( $revision, !$unhide );
1371 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1372 ?
'revision-info-current'
1375 $outputPage = $context->getOutput();
1376 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1377 $context->msg( $infomsg, $td )
1378 ->rawParams( $userlinks )
1379 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1380 ->rawParams( Linker
::revComment( $revision, true, true ) )
1385 ?
$context->msg( 'currentrevisionlink' )->escaped()
1386 : Linker
::linkKnown(
1388 $context->msg( 'currentrevisionlink' )->escaped(),
1393 ?
$context->msg( 'diff' )->escaped()
1394 : Linker
::linkKnown(
1396 $context->msg( 'diff' )->escaped(),
1403 $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1405 ? Linker
::linkKnown(
1407 $context->msg( 'previousrevision' )->escaped(),
1410 'direction' => 'prev',
1414 : $context->msg( 'previousrevision' )->escaped();
1416 ? Linker
::linkKnown(
1418 $context->msg( 'diff' )->escaped(),
1425 : $context->msg( 'diff' )->escaped();
1426 $nextlink = $current
1427 ?
$context->msg( 'nextrevision' )->escaped()
1428 : Linker
::linkKnown(
1430 $context->msg( 'nextrevision' )->escaped(),
1433 'direction' => 'next',
1437 $nextdiff = $current
1438 ?
$context->msg( 'diff' )->escaped()
1439 : Linker
::linkKnown(
1441 $context->msg( 'diff' )->escaped(),
1449 $cdel = Linker
::getRevDeleteLink( $user, $revision, $this->getTitle() );
1450 if ( $cdel !== '' ) {
1454 // the outer div is need for styling the revision info and nav in MobileFrontend
1455 $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1456 "<div id=\"mw-revision-nav\">" . $cdel .
1457 $context->msg( 'revision-nav' )->rawParams(
1458 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1459 )->escaped() . "</div></div>" );
1463 * Return the HTML for the top of a redirect page
1465 * Chances are you should just be using the ParserOutput from
1466 * WikitextContent::getParserOutput instead of calling this for redirects.
1468 * @param Title|array $target Destination(s) to redirect
1469 * @param bool $appendSubtitle [optional]
1470 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1471 * @return string Containing HTML with redirect link
1473 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1474 $lang = $this->getTitle()->getPageLanguage();
1475 $out = $this->getContext()->getOutput();
1476 if ( $appendSubtitle ) {
1477 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1479 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1480 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1484 * Return the HTML for the top of a redirect page
1486 * Chances are you should just be using the ParserOutput from
1487 * WikitextContent::getParserOutput instead of calling this for redirects.
1490 * @param Language $lang
1491 * @param Title|array $target Destination(s) to redirect
1492 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1493 * @return string Containing HTML with redirect link
1495 public static function getRedirectHeaderHtml( Language
$lang, $target, $forceKnown = false ) {
1496 if ( !is_array( $target ) ) {
1497 $target = [ $target ];
1500 $html = '<ul class="redirectText">';
1501 /** @var Title $title */
1502 foreach ( $target as $title ) {
1503 $html .= '<li>' . Linker
::link(
1505 htmlspecialchars( $title->getFullText() ),
1507 // Make sure wiki page redirects are not followed
1508 $title->isRedirect() ?
[ 'redirect' => 'no' ] : [],
1509 ( $forceKnown ?
[ 'known', 'noclasses' ] : [] )
1514 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1516 return '<div class="redirectMsg">' .
1517 '<p>' . $redirectToText . '</p>' .
1523 * Adds help link with an icon via page indicators.
1524 * Link target can be overridden by a local message containing a wikilink:
1525 * the message key is: 'namespace-' + namespace number + '-helppage'.
1526 * @param string $to Target MediaWiki.org page title or encoded URL.
1527 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
1530 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1532 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1535 $out = $this->getContext()->getOutput();
1536 if ( !$msg->isDisabled() ) {
1537 $helpUrl = Skin
::makeUrl( $msg->plain() );
1538 $out->addHelpLink( $helpUrl, true );
1540 $out->addHelpLink( $to, $overrideBaseUrl );
1545 * Handle action=render
1547 public function render() {
1548 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1549 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1550 $this->getContext()->getOutput()->enableSectionEditLinks( false );
1555 * action=protect handler
1557 public function protect() {
1558 $form = new ProtectionForm( $this );
1563 * action=unprotect handler (alias)
1565 public function unprotect() {
1570 * UI entry point for page deletion
1572 public function delete() {
1573 # This code desperately needs to be totally rewritten
1575 $title = $this->getTitle();
1576 $context = $this->getContext();
1577 $user = $context->getUser();
1578 $request = $context->getRequest();
1581 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1582 if ( count( $permissionErrors ) ) {
1583 throw new PermissionsError( 'delete', $permissionErrors );
1586 # Read-only check...
1587 if ( wfReadOnly() ) {
1588 throw new ReadOnlyError
;
1591 # Better double-check that it hasn't been deleted yet!
1592 $this->mPage
->loadPageData(
1593 $request->wasPosted() ? WikiPage
::READ_LATEST
: WikiPage
::READ_NORMAL
1595 if ( !$this->mPage
->exists() ) {
1596 $deleteLogPage = new LogPage( 'delete' );
1597 $outputPage = $context->getOutput();
1598 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1599 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1600 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1602 $outputPage->addHTML(
1603 Xml
::element( 'h2', null, $deleteLogPage->getName()->text() )
1605 LogEventsList
::showLogExtract(
1614 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1615 $deleteReason = $request->getText( 'wpReason' );
1617 if ( $deleteReasonList == 'other' ) {
1618 $reason = $deleteReason;
1619 } elseif ( $deleteReason != '' ) {
1620 // Entry from drop down menu + additional comment
1621 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1622 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1624 $reason = $deleteReasonList;
1627 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1628 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1630 # Flag to hide all contents of the archived revisions
1631 $suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1633 $this->doDelete( $reason, $suppress );
1635 WatchAction
::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1640 // Generate deletion reason
1641 $hasHistory = false;
1644 $reason = $this->generateReason( $hasHistory );
1645 } catch ( Exception
$e ) {
1646 # if a page is horribly broken, we still want to be able to
1647 # delete it. So be lenient about errors here.
1648 wfDebug( "Error while building auto delete summary: $e" );
1653 // If the page has a history, insert a warning
1654 if ( $hasHistory ) {
1655 $title = $this->getTitle();
1657 // The following can use the real revision count as this is only being shown for users
1658 // that can delete this page.
1659 // This, as a side-effect, also makes sure that the following query isn't being run for
1660 // pages with a larger history, unless the user has the 'bigdelete' right
1661 // (and is about to delete this page).
1662 $dbr = wfGetDB( DB_REPLICA
);
1663 $revisions = $edits = (int)$dbr->selectField(
1666 [ 'rev_page' => $title->getArticleID() ],
1670 // @todo FIXME: i18n issue/patchwork message
1671 $context->getOutput()->addHTML(
1672 '<strong class="mw-delete-warning-revisions">' .
1673 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1674 $context->msg( 'word-separator' )->escaped() . Linker
::linkKnown( $title,
1675 $context->msg( 'history' )->escaped(),
1677 [ 'action' => 'history' ] ) .
1681 if ( $title->isBigDeletion() ) {
1682 global $wgDeleteRevisionsLimit;
1683 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1685 'delete-warning-toobig',
1686 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1692 $this->confirmDelete( $reason );
1696 * Output deletion confirmation dialog
1697 * @todo FIXME: Move to another file?
1698 * @param string $reason Prefilled reason
1700 public function confirmDelete( $reason ) {
1701 wfDebug( "Article::confirmDelete\n" );
1703 $title = $this->getTitle();
1704 $ctx = $this->getContext();
1705 $outputPage = $ctx->getOutput();
1706 $useMediaWikiUIEverywhere = $ctx->getConfig()->get( 'UseMediaWikiUIEverywhere' );
1707 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1708 $outputPage->addBacklinkSubtitle( $title );
1709 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1710 $backlinkCache = $title->getBacklinkCache();
1711 if ( $backlinkCache->hasLinks( 'pagelinks' ) ||
$backlinkCache->hasLinks( 'templatelinks' ) ) {
1712 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1713 'deleting-backlinks-warning' );
1715 $outputPage->addWikiMsg( 'confirmdeletetext' );
1717 Hooks
::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1719 $user = $this->getContext()->getUser();
1721 if ( $user->isAllowed( 'suppressrevision' ) ) {
1722 $suppress = Html
::openElement( 'div', [ 'id' => 'wpDeleteSuppressRow' ] ) .
1723 Xml
::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
1724 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '4' ] ) .
1725 Html
::closeElement( 'div' );
1729 $checkWatch = $user->getBoolOption( 'watchdeletion' ) ||
$user->isWatched( $title );
1731 $form = Html
::openElement( 'form', [ 'method' => 'post',
1732 'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ] ) .
1733 Html
::openElement( 'fieldset', [ 'id' => 'mw-delete-table' ] ) .
1734 Html
::element( 'legend', null, wfMessage( 'delete-legend' )->text() ) .
1735 Html
::openElement( 'div', [ 'id' => 'mw-deleteconfirm-table' ] ) .
1736 Html
::openElement( 'div', [ 'id' => 'wpDeleteReasonListRow' ] ) .
1737 Html
::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
1740 'wpDeleteReasonList',
1741 wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
1742 wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(),
1747 Html
::closeElement( 'div' ) .
1748 Html
::openElement( 'div', [ 'id' => 'wpDeleteReasonRow' ] ) .
1749 Html
::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) .
1751 Html
::input( 'wpReason', $reason, 'text', [
1753 'maxlength' => '255',
1756 'class' => 'mw-ui-input-inline',
1759 Html
::closeElement( 'div' );
1761 # Disallow watching if user is not logged in
1762 if ( $user->isLoggedIn() ) {
1764 Xml
::checkLabel( wfMessage( 'watchthis' )->text(),
1765 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] );
1769 Html
::openElement( 'div' ) .
1771 Xml
::submitButton( wfMessage( 'deletepage' )->text(),
1773 'name' => 'wpConfirmB',
1774 'id' => 'wpConfirmB',
1776 'class' => $useMediaWikiUIEverywhere ?
'mw-ui-button mw-ui-destructive' : '',
1779 Html
::closeElement( 'div' ) .
1780 Html
::closeElement( 'div' ) .
1781 Xml
::closeElement( 'fieldset' ) .
1784 $user->getEditToken( [ 'delete', $title->getPrefixedText() ] )
1786 Xml
::closeElement( 'form' );
1788 if ( $user->isAllowed( 'editinterface' ) ) {
1789 $link = Linker
::linkKnown(
1790 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1791 wfMessage( 'delete-edit-reasonlist' )->escaped(),
1793 [ 'action' => 'edit' ]
1795 $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
1798 $outputPage->addHTML( $form );
1800 $deleteLogPage = new LogPage( 'delete' );
1801 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1802 LogEventsList
::showLogExtract( $outputPage, 'delete', $title );
1806 * Perform a deletion and output success or failure messages
1807 * @param string $reason
1808 * @param bool $suppress
1810 public function doDelete( $reason, $suppress = false ) {
1812 $context = $this->getContext();
1813 $outputPage = $context->getOutput();
1814 $user = $context->getUser();
1815 $status = $this->mPage
->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
1817 if ( $status->isGood() ) {
1818 $deleted = $this->getTitle()->getPrefixedText();
1820 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1821 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1823 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1825 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1827 Hooks
::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
1829 $outputPage->returnToMain( false );
1831 $outputPage->setPageTitle(
1832 wfMessage( 'cannotdelete-title',
1833 $this->getTitle()->getPrefixedText() )
1836 if ( $error == '' ) {
1837 $outputPage->addWikiText(
1838 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1840 $deleteLogPage = new LogPage( 'delete' );
1841 $outputPage->addHTML( Xml
::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1843 LogEventsList
::showLogExtract(
1849 $outputPage->addHTML( $error );
1854 /* Caching functions */
1857 * checkLastModified returns true if it has taken care of all
1858 * output to the client that is necessary for this request.
1859 * (that is, it has sent a cached version of the page)
1861 * @return bool True if cached version send, false otherwise
1863 protected function tryFileCache() {
1864 static $called = false;
1867 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1872 if ( $this->isFileCacheable() ) {
1873 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
1874 if ( $cache->isCacheGood( $this->mPage
->getTouched() ) ) {
1875 wfDebug( "Article::tryFileCache(): about to load file\n" );
1876 $cache->loadFromFileCache( $this->getContext() );
1879 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1880 ob_start( [ &$cache, 'saveToFileCache' ] );
1883 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1890 * Check if the page can be cached
1891 * @param integer $mode One of the HTMLFileCache::MODE_* constants (since 1.28)
1894 public function isFileCacheable( $mode = HTMLFileCache
::MODE_NORMAL
) {
1897 if ( HTMLFileCache
::useFileCache( $this->getContext(), $mode ) ) {
1898 $cacheable = $this->mPage
->getId()
1899 && !$this->mRedirectedFrom
&& !$this->getTitle()->isRedirect();
1900 // Extension may have reason to disable file caching on some pages.
1902 $cacheable = Hooks
::run( 'IsFileCacheable', [ &$this ] );
1912 * Lightweight method to get the parser output for a page, checking the parser cache
1913 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1914 * consider, so it's not appropriate to use there.
1916 * @since 1.16 (r52326) for LiquidThreads
1918 * @param int|null $oldid Revision ID or null
1919 * @param User $user The relevant user
1920 * @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
1922 public function getParserOutput( $oldid = null, User
$user = null ) {
1923 // XXX: bypasses mParserOptions and thus setParserOptions()
1925 if ( $user === null ) {
1926 $parserOptions = $this->getParserOptions();
1928 $parserOptions = $this->mPage
->makeParserOptions( $user );
1931 return $this->mPage
->getParserOutput( $parserOptions, $oldid );
1935 * Override the ParserOptions used to render the primary article wikitext.
1937 * @param ParserOptions $options
1938 * @throws MWException If the parser options where already initialized.
1940 public function setParserOptions( ParserOptions
$options ) {
1941 if ( $this->mParserOptions
) {
1942 throw new MWException( "can't change parser options after they have already been set" );
1945 // clone, so if $options is modified later, it doesn't confuse the parser cache.
1946 $this->mParserOptions
= clone $options;
1950 * Get parser options suitable for rendering the primary article wikitext
1951 * @return ParserOptions
1953 public function getParserOptions() {
1954 if ( !$this->mParserOptions
) {
1955 $this->mParserOptions
= $this->mPage
->makeParserOptions( $this->getContext() );
1957 // Clone to allow modifications of the return value without affecting cache
1958 return clone $this->mParserOptions
;
1962 * Sets the context this Article is executed in
1964 * @param IContextSource $context
1967 public function setContext( $context ) {
1968 $this->mContext
= $context;
1972 * Gets the context this Article is executed in
1974 * @return IContextSource
1977 public function getContext() {
1978 if ( $this->mContext
instanceof IContextSource
) {
1979 return $this->mContext
;
1981 wfDebug( __METHOD__
. " called and \$mContext is null. " .
1982 "Return RequestContext::getMain(); for sanity\n" );
1983 return RequestContext
::getMain();
1988 * Use PHP's magic __get handler to handle accessing of
1989 * raw WikiPage fields for backwards compatibility.
1991 * @param string $fname Field name
1994 public function __get( $fname ) {
1995 if ( property_exists( $this->mPage
, $fname ) ) {
1996 # wfWarn( "Access to raw $fname field " . __CLASS__ );
1997 return $this->mPage
->$fname;
1999 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE
);
2003 * Use PHP's magic __set handler to handle setting of
2004 * raw WikiPage fields for backwards compatibility.
2006 * @param string $fname Field name
2007 * @param mixed $fvalue New value
2009 public function __set( $fname, $fvalue ) {
2010 if ( property_exists( $this->mPage
, $fname ) ) {
2011 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2012 $this->mPage
->$fname = $fvalue;
2013 // Note: extensions may want to toss on new fields
2014 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
2015 $this->mPage
->$fname = $fvalue;
2017 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE
);
2022 * Call to WikiPage function for backwards compatibility.
2023 * @see WikiPage::checkFlags
2025 public function checkFlags( $flags ) {
2026 return $this->mPage
->checkFlags( $flags );
2030 * Call to WikiPage function for backwards compatibility.
2031 * @see WikiPage::checkTouched
2033 public function checkTouched() {
2034 return $this->mPage
->checkTouched();
2038 * Call to WikiPage function for backwards compatibility.
2039 * @see WikiPage::clearPreparedEdit
2041 public function clearPreparedEdit() {
2042 $this->mPage
->clearPreparedEdit();
2046 * Call to WikiPage function for backwards compatibility.
2047 * @see WikiPage::doDeleteArticleReal
2049 public function doDeleteArticleReal(
2050 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User
$user = null,
2053 return $this->mPage
->doDeleteArticleReal(
2054 $reason, $suppress, $u1, $u2, $error, $user, $tags
2059 * Call to WikiPage function for backwards compatibility.
2060 * @see WikiPage::doDeleteUpdates
2062 public function doDeleteUpdates( $id, Content
$content = null ) {
2063 return $this->mPage
->doDeleteUpdates( $id, $content );
2067 * Call to WikiPage function for backwards compatibility.
2068 * @see WikiPage::doEdit
2070 * @deprecated since 1.21: use doEditContent() instead.
2072 public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
2073 wfDeprecated( __METHOD__
, '1.21' );
2074 return $this->mPage
->doEdit( $text, $summary, $flags, $baseRevId, $user );
2078 * Call to WikiPage function for backwards compatibility.
2079 * @see WikiPage::doEditContent
2081 public function doEditContent( Content
$content, $summary, $flags = 0, $baseRevId = false,
2082 User
$user = null, $serialFormat = null
2084 return $this->mPage
->doEditContent( $content, $summary, $flags, $baseRevId,
2085 $user, $serialFormat
2090 * Call to WikiPage function for backwards compatibility.
2091 * @see WikiPage::doEditUpdates
2093 public function doEditUpdates( Revision
$revision, User
$user, array $options = [] ) {
2094 return $this->mPage
->doEditUpdates( $revision, $user, $options );
2098 * Call to WikiPage function for backwards compatibility.
2099 * @see WikiPage::doPurge
2101 public function doPurge( $flags = WikiPage
::PURGE_ALL
) {
2102 return $this->mPage
->doPurge( $flags );
2106 * Call to WikiPage function for backwards compatibility.
2107 * @see WikiPage::getLastPurgeTimestamp
2109 public function getLastPurgeTimestamp() {
2110 return $this->mPage
->getLastPurgeTimestamp();
2114 * Call to WikiPage function for backwards compatibility.
2115 * @see WikiPage::doViewUpdates
2117 public function doViewUpdates( User
$user, $oldid = 0 ) {
2118 $this->mPage
->doViewUpdates( $user, $oldid );
2122 * Call to WikiPage function for backwards compatibility.
2123 * @see WikiPage::exists
2125 public function exists() {
2126 return $this->mPage
->exists();
2130 * Call to WikiPage function for backwards compatibility.
2131 * @see WikiPage::followRedirect
2133 public function followRedirect() {
2134 return $this->mPage
->followRedirect();
2138 * Call to WikiPage function for backwards compatibility.
2139 * @see ContentHandler::getActionOverrides
2141 public function getActionOverrides() {
2142 return $this->mPage
->getActionOverrides();
2146 * Call to WikiPage function for backwards compatibility.
2147 * @see WikiPage::getAutoDeleteReason
2149 public function getAutoDeleteReason( &$hasHistory ) {
2150 return $this->mPage
->getAutoDeleteReason( $hasHistory );
2154 * Call to WikiPage function for backwards compatibility.
2155 * @see WikiPage::getCategories
2157 public function getCategories() {
2158 return $this->mPage
->getCategories();
2162 * Call to WikiPage function for backwards compatibility.
2163 * @see WikiPage::getComment
2165 public function getComment( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2166 return $this->mPage
->getComment( $audience, $user );
2170 * Call to WikiPage function for backwards compatibility.
2171 * @see WikiPage::getContentHandler
2173 public function getContentHandler() {
2174 return $this->mPage
->getContentHandler();
2178 * Call to WikiPage function for backwards compatibility.
2179 * @see WikiPage::getContentModel
2181 public function getContentModel() {
2182 return $this->mPage
->getContentModel();
2186 * Call to WikiPage function for backwards compatibility.
2187 * @see WikiPage::getContributors
2189 public function getContributors() {
2190 return $this->mPage
->getContributors();
2194 * Call to WikiPage function for backwards compatibility.
2195 * @see WikiPage::getCreator
2197 public function getCreator( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2198 return $this->mPage
->getCreator( $audience, $user );
2202 * Call to WikiPage function for backwards compatibility.
2203 * @see WikiPage::getDeletionUpdates
2205 public function getDeletionUpdates( Content
$content = null ) {
2206 return $this->mPage
->getDeletionUpdates( $content );
2210 * Call to WikiPage function for backwards compatibility.
2211 * @see WikiPage::getHiddenCategories
2213 public function getHiddenCategories() {
2214 return $this->mPage
->getHiddenCategories();
2218 * Call to WikiPage function for backwards compatibility.
2219 * @see WikiPage::getId
2221 public function getId() {
2222 return $this->mPage
->getId();
2226 * Call to WikiPage function for backwards compatibility.
2227 * @see WikiPage::getLatest
2229 public function getLatest() {
2230 return $this->mPage
->getLatest();
2234 * Call to WikiPage function for backwards compatibility.
2235 * @see WikiPage::getLinksTimestamp
2237 public function getLinksTimestamp() {
2238 return $this->mPage
->getLinksTimestamp();
2242 * Call to WikiPage function for backwards compatibility.
2243 * @see WikiPage::getMinorEdit
2245 public function getMinorEdit() {
2246 return $this->mPage
->getMinorEdit();
2250 * Call to WikiPage function for backwards compatibility.
2251 * @see WikiPage::getOldestRevision
2253 public function getOldestRevision() {
2254 return $this->mPage
->getOldestRevision();
2258 * Call to WikiPage function for backwards compatibility.
2259 * @see WikiPage::getRedirectTarget
2261 public function getRedirectTarget() {
2262 return $this->mPage
->getRedirectTarget();
2266 * Call to WikiPage function for backwards compatibility.
2267 * @see WikiPage::getRedirectURL
2269 public function getRedirectURL( $rt ) {
2270 return $this->mPage
->getRedirectURL( $rt );
2274 * Call to WikiPage function for backwards compatibility.
2275 * @see WikiPage::getRevision
2277 public function getRevision() {
2278 return $this->mPage
->getRevision();
2282 * Call to WikiPage function for backwards compatibility.
2283 * @see WikiPage::getTimestamp
2285 public function getTimestamp() {
2286 return $this->mPage
->getTimestamp();
2290 * Call to WikiPage function for backwards compatibility.
2291 * @see WikiPage::getTouched
2293 public function getTouched() {
2294 return $this->mPage
->getTouched();
2298 * Call to WikiPage function for backwards compatibility.
2299 * @see WikiPage::getUndoContent
2301 public function getUndoContent( Revision
$undo, Revision
$undoafter = null ) {
2302 return $this->mPage
->getUndoContent( $undo, $undoafter );
2306 * Call to WikiPage function for backwards compatibility.
2307 * @see WikiPage::getUser
2309 public function getUser( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2310 return $this->mPage
->getUser( $audience, $user );
2314 * Call to WikiPage function for backwards compatibility.
2315 * @see WikiPage::getUserText
2317 public function getUserText( $audience = Revision
::FOR_PUBLIC
, User
$user = null ) {
2318 return $this->mPage
->getUserText( $audience, $user );
2322 * Call to WikiPage function for backwards compatibility.
2323 * @see WikiPage::hasViewableContent
2325 public function hasViewableContent() {
2326 return $this->mPage
->hasViewableContent();
2330 * Call to WikiPage function for backwards compatibility.
2331 * @see WikiPage::insertOn
2333 public function insertOn( $dbw, $pageId = null ) {
2334 return $this->mPage
->insertOn( $dbw, $pageId );
2338 * Call to WikiPage function for backwards compatibility.
2339 * @see WikiPage::insertProtectNullRevision
2341 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2342 array $expiry, $cascade, $reason, $user = null
2344 return $this->mPage
->insertProtectNullRevision( $revCommentMsg, $limit,
2345 $expiry, $cascade, $reason, $user
2350 * Call to WikiPage function for backwards compatibility.
2351 * @see WikiPage::insertRedirect
2353 public function insertRedirect() {
2354 return $this->mPage
->insertRedirect();
2358 * Call to WikiPage function for backwards compatibility.
2359 * @see WikiPage::insertRedirectEntry
2361 public function insertRedirectEntry( Title
$rt, $oldLatest = null ) {
2362 return $this->mPage
->insertRedirectEntry( $rt, $oldLatest );
2366 * Call to WikiPage function for backwards compatibility.
2367 * @see WikiPage::isCountable
2369 public function isCountable( $editInfo = false ) {
2370 return $this->mPage
->isCountable( $editInfo );
2374 * Call to WikiPage function for backwards compatibility.
2375 * @see WikiPage::isRedirect
2377 public function isRedirect() {
2378 return $this->mPage
->isRedirect();
2382 * Call to WikiPage function for backwards compatibility.
2383 * @see WikiPage::loadFromRow
2385 public function loadFromRow( $data, $from ) {
2386 return $this->mPage
->loadFromRow( $data, $from );
2390 * Call to WikiPage function for backwards compatibility.
2391 * @see WikiPage::loadPageData
2393 public function loadPageData( $from = 'fromdb' ) {
2394 $this->mPage
->loadPageData( $from );
2398 * Call to WikiPage function for backwards compatibility.
2399 * @see WikiPage::lockAndGetLatest
2401 public function lockAndGetLatest() {
2402 return $this->mPage
->lockAndGetLatest();
2406 * Call to WikiPage function for backwards compatibility.
2407 * @see WikiPage::makeParserOptions
2409 public function makeParserOptions( $context ) {
2410 return $this->mPage
->makeParserOptions( $context );
2414 * Call to WikiPage function for backwards compatibility.
2415 * @see WikiPage::pageDataFromId
2417 public function pageDataFromId( $dbr, $id, $options = [] ) {
2418 return $this->mPage
->pageDataFromId( $dbr, $id, $options );
2422 * Call to WikiPage function for backwards compatibility.
2423 * @see WikiPage::pageDataFromTitle
2425 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2426 return $this->mPage
->pageDataFromTitle( $dbr, $title, $options );
2430 * Call to WikiPage function for backwards compatibility.
2431 * @see WikiPage::prepareContentForEdit
2433 public function prepareContentForEdit(
2434 Content
$content, $revision = null, User
$user = null,
2435 $serialFormat = null, $useCache = true
2437 return $this->mPage
->prepareContentForEdit(
2438 $content, $revision, $user,
2439 $serialFormat, $useCache
2444 * Call to WikiPage function for backwards compatibility.
2445 * @see WikiPage::protectDescription
2447 public function protectDescription( array $limit, array $expiry ) {
2448 return $this->mPage
->protectDescription( $limit, $expiry );
2452 * Call to WikiPage function for backwards compatibility.
2453 * @see WikiPage::protectDescriptionLog
2455 public function protectDescriptionLog( array $limit, array $expiry ) {
2456 return $this->mPage
->protectDescriptionLog( $limit, $expiry );
2460 * Call to WikiPage function for backwards compatibility.
2461 * @see WikiPage::replaceSectionAtRev
2463 public function replaceSectionAtRev( $sectionId, Content
$sectionContent,
2464 $sectionTitle = '', $baseRevId = null
2466 return $this->mPage
->replaceSectionAtRev( $sectionId, $sectionContent,
2467 $sectionTitle, $baseRevId
2472 * Call to WikiPage function for backwards compatibility.
2473 * @see WikiPage::replaceSectionContent
2475 public function replaceSectionContent(
2476 $sectionId, Content
$sectionContent, $sectionTitle = '', $edittime = null
2478 return $this->mPage
->replaceSectionContent(
2479 $sectionId, $sectionContent, $sectionTitle, $edittime
2484 * Call to WikiPage function for backwards compatibility.
2485 * @see WikiPage::setTimestamp
2487 public function setTimestamp( $ts ) {
2488 return $this->mPage
->setTimestamp( $ts );
2492 * Call to WikiPage function for backwards compatibility.
2493 * @see WikiPage::shouldCheckParserCache
2495 public function shouldCheckParserCache( ParserOptions
$parserOptions, $oldId ) {
2496 return $this->mPage
->shouldCheckParserCache( $parserOptions, $oldId );
2500 * Call to WikiPage function for backwards compatibility.
2501 * @see WikiPage::supportsSections
2503 public function supportsSections() {
2504 return $this->mPage
->supportsSections();
2508 * Call to WikiPage function for backwards compatibility.
2509 * @see WikiPage::triggerOpportunisticLinksUpdate
2511 public function triggerOpportunisticLinksUpdate( ParserOutput
$parserOutput ) {
2512 return $this->mPage
->triggerOpportunisticLinksUpdate( $parserOutput );
2516 * Call to WikiPage function for backwards compatibility.
2517 * @see WikiPage::updateCategoryCounts
2519 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2520 return $this->mPage
->updateCategoryCounts( $added, $deleted, $id );
2524 * Call to WikiPage function for backwards compatibility.
2525 * @see WikiPage::updateIfNewerOn
2527 public function updateIfNewerOn( $dbw, $revision ) {
2528 return $this->mPage
->updateIfNewerOn( $dbw, $revision );
2532 * Call to WikiPage function for backwards compatibility.
2533 * @see WikiPage::updateRedirectOn
2535 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2536 return $this->mPage
->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null );
2540 * Call to WikiPage function for backwards compatibility.
2541 * @see WikiPage::updateRevisionOn
2543 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2544 $lastRevIsRedirect = null
2546 return $this->mPage
->updateRevisionOn( $dbw, $revision, $lastRevision,
2552 * @param array $limit
2553 * @param array $expiry
2554 * @param bool $cascade
2555 * @param string $reason
2559 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2562 return $this->mPage
->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2566 * @param array $limit
2567 * @param string $reason
2568 * @param int $cascade
2569 * @param array $expiry
2572 public function updateRestrictions( $limit = [], $reason = '',
2573 &$cascade = 0, $expiry = []
2575 return $this->mPage
->doUpdateRestrictions(
2580 $this->getContext()->getUser()
2585 * @param string $reason
2586 * @param bool $suppress
2587 * @param int $u1 Unused
2588 * @param bool $u2 Unused
2589 * @param string $error
2592 public function doDeleteArticle(
2593 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2595 return $this->mPage
->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2599 * @param string $fromP
2600 * @param string $summary
2601 * @param string $token
2603 * @param array $resultDetails
2604 * @param User|null $user
2607 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User
$user = null ) {
2608 $user = is_null( $user ) ?
$this->getContext()->getUser() : $user;
2609 return $this->mPage
->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2613 * @param string $fromP
2614 * @param string $summary
2616 * @param array $resultDetails
2617 * @param User|null $guser
2620 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User
$guser = null ) {
2621 $guser = is_null( $guser ) ?
$this->getContext()->getUser() : $guser;
2622 return $this->mPage
->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2626 * @param bool $hasHistory
2629 public function generateReason( &$hasHistory ) {
2630 $title = $this->mPage
->getTitle();
2631 $handler = ContentHandler
::getForTitle( $title );
2632 return $handler->getAutoDeleteReason( $title, $hasHistory );
2638 * @deprecated since 1.24, use WikiPage::selectFields() instead
2640 public static function selectFields() {
2641 wfDeprecated( __METHOD__
, '1.24' );
2642 return WikiPage
::selectFields();
2646 * @param Title $title
2648 * @deprecated since 1.24, use WikiPage::onArticleCreate() instead
2650 public static function onArticleCreate( $title ) {
2651 wfDeprecated( __METHOD__
, '1.24' );
2652 WikiPage
::onArticleCreate( $title );
2656 * @param Title $title
2658 * @deprecated since 1.24, use WikiPage::onArticleDelete() instead
2660 public static function onArticleDelete( $title ) {
2661 wfDeprecated( __METHOD__
, '1.24' );
2662 WikiPage
::onArticleDelete( $title );
2666 * @param Title $title
2668 * @deprecated since 1.24, use WikiPage::onArticleEdit() instead
2670 public static function onArticleEdit( $title ) {
2671 wfDeprecated( __METHOD__
, '1.24' );
2672 WikiPage
::onArticleEdit( $title );