Merge "Move MediaHandler defaults out of global scope"
[lhc/web/wiklou.git] / includes / page / Article.php
1 <?php
2 /**
3 * User interface for page actions.
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 */
22
23 /**
24 * Class for viewing MediaWiki article and history.
25 *
26 * This maintains WikiPage functions for backwards compatibility.
27 *
28 * @todo Move and rewrite code to an Action class
29 *
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.
33 */
34 class Article implements Page {
35 /** @var IContextSource The context this Article is executed in */
36 protected $mContext;
37
38 /** @var WikiPage The WikiPage object of this instance */
39 protected $mPage;
40
41 /** @var ParserOptions ParserOptions object for $wgUser articles */
42 public $mParserOptions;
43
44 /**
45 * @var string Text of the revision we are working on
46 * @todo BC cruft
47 */
48 public $mContent;
49
50 /**
51 * @var Content Content of the revision we are working on
52 * @since 1.21
53 */
54 public $mContentObject;
55
56 /** @var bool Is the content ($mContent) already loaded? */
57 public $mContentLoaded = false;
58
59 /** @var int|null The oldid of the article that is to be shown, 0 for the current revision */
60 public $mOldId;
61
62 /** @var Title Title from which we were redirected here */
63 public $mRedirectedFrom = null;
64
65 /** @var string|bool URL to redirect to or false if none */
66 public $mRedirectUrl = false;
67
68 /** @var int Revision ID of revision we are working on */
69 public $mRevIdFetched = 0;
70
71 /** @var Revision Revision we are working on */
72 public $mRevision = null;
73
74 /** @var ParserOutput */
75 public $mParserOutput;
76
77 /**
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
81 */
82 public function __construct( Title $title, $oldId = null ) {
83 $this->mOldId = $oldId;
84 $this->mPage = $this->newPage( $title );
85 }
86
87 /**
88 * @param Title $title
89 * @return WikiPage
90 */
91 protected function newPage( Title $title ) {
92 return new WikiPage( $title );
93 }
94
95 /**
96 * Constructor from a page id
97 * @param int $id Article ID to load
98 * @return Article|null
99 */
100 public static function newFromID( $id ) {
101 $t = Title::newFromID( $id );
102 # @todo FIXME: Doesn't inherit right
103 return $t == null ? null : new self( $t );
104 # return $t == null ? null : new static( $t ); // PHP 5.3
105 }
106
107 /**
108 * Create an Article object of the appropriate class for the given page.
109 *
110 * @param Title $title
111 * @param IContextSource $context
112 * @return Article
113 */
114 public static function newFromTitle( $title, IContextSource $context ) {
115 if ( NS_MEDIA == $title->getNamespace() ) {
116 // FIXME: where should this go?
117 $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
118 }
119
120 $page = null;
121 Hooks::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
122 if ( !$page ) {
123 switch ( $title->getNamespace() ) {
124 case NS_FILE:
125 $page = new ImagePage( $title );
126 break;
127 case NS_CATEGORY:
128 $page = new CategoryPage( $title );
129 break;
130 default:
131 $page = new Article( $title );
132 }
133 }
134 $page->setContext( $context );
135
136 return $page;
137 }
138
139 /**
140 * Create an Article object of the appropriate class for the given page.
141 *
142 * @param WikiPage $page
143 * @param IContextSource $context
144 * @return Article
145 */
146 public static function newFromWikiPage( WikiPage $page, IContextSource $context ) {
147 $article = self::newFromTitle( $page->getTitle(), $context );
148 $article->mPage = $page; // override to keep process cached vars
149 return $article;
150 }
151
152 /**
153 * Tell the page view functions that this view was redirected
154 * from another page on the wiki.
155 * @param Title $from
156 */
157 public function setRedirectedFrom( Title $from ) {
158 $this->mRedirectedFrom = $from;
159 }
160
161 /**
162 * Get the title object of the article
163 *
164 * @return Title Title object of this page
165 */
166 public function getTitle() {
167 return $this->mPage->getTitle();
168 }
169
170 /**
171 * Get the WikiPage object of this instance
172 *
173 * @since 1.19
174 * @return WikiPage
175 */
176 public function getPage() {
177 return $this->mPage;
178 }
179
180 /**
181 * Clear the object
182 */
183 public function clear() {
184 $this->mContentLoaded = false;
185
186 $this->mRedirectedFrom = null; # Title object if set
187 $this->mRevIdFetched = 0;
188 $this->mRedirectUrl = false;
189
190 $this->mPage->clear();
191 }
192
193 /**
194 * Note that getContent does not follow redirects anymore.
195 * If you need to fetch redirectable content easily, try
196 * the shortcut in WikiPage::getRedirectTarget()
197 *
198 * This function has side effects! Do not use this function if you
199 * only want the real revision text if any.
200 *
201 * @deprecated since 1.21; use WikiPage::getContent() instead
202 *
203 * @return string Return the text of this revision
204 */
205 public function getContent() {
206 ContentHandler::deprecated( __METHOD__, '1.21' );
207 $content = $this->getContentObject();
208 return ContentHandler::getContentText( $content );
209 }
210
211 /**
212 * Returns a Content object representing the pages effective display content,
213 * not necessarily the revision's content!
214 *
215 * Note that getContent does not follow redirects anymore.
216 * If you need to fetch redirectable content easily, try
217 * the shortcut in WikiPage::getRedirectTarget()
218 *
219 * This function has side effects! Do not use this function if you
220 * only want the real revision text if any.
221 *
222 * @return Content Return the content of this revision
223 *
224 * @since 1.21
225 */
226 protected function getContentObject() {
227
228 if ( $this->mPage->getId() === 0 ) {
229 # If this is a MediaWiki:x message, then load the messages
230 # and return the message value for x.
231 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) {
232 $text = $this->getTitle()->getDefaultMessageText();
233 if ( $text === false ) {
234 $text = '';
235 }
236
237 $content = ContentHandler::makeContent( $text, $this->getTitle() );
238 } else {
239 $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
240 $content = new MessageContent( $message, null, 'parsemag' );
241 }
242 } else {
243 $this->fetchContentObject();
244 $content = $this->mContentObject;
245 }
246
247 return $content;
248 }
249
250 /**
251 * @return int The oldid of the article that is to be shown, 0 for the current revision
252 */
253 public function getOldID() {
254 if ( is_null( $this->mOldId ) ) {
255 $this->mOldId = $this->getOldIDFromRequest();
256 }
257
258 return $this->mOldId;
259 }
260
261 /**
262 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
263 *
264 * @return int The old id for the request
265 */
266 public function getOldIDFromRequest() {
267 $this->mRedirectUrl = false;
268
269 $request = $this->getContext()->getRequest();
270 $oldid = $request->getIntOrNull( 'oldid' );
271
272 if ( $oldid === null ) {
273 return 0;
274 }
275
276 if ( $oldid !== 0 ) {
277 # Load the given revision and check whether the page is another one.
278 # In that case, update this instance to reflect the change.
279 if ( $oldid === $this->mPage->getLatest() ) {
280 $this->mRevision = $this->mPage->getRevision();
281 } else {
282 $this->mRevision = Revision::newFromId( $oldid );
283 if ( $this->mRevision !== null ) {
284 // Revision title doesn't match the page title given?
285 if ( $this->mPage->getId() != $this->mRevision->getPage() ) {
286 $function = [ get_class( $this->mPage ), 'newFromID' ];
287 $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
288 }
289 }
290 }
291 }
292
293 if ( $request->getVal( 'direction' ) == 'next' ) {
294 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
295 if ( $nextid ) {
296 $oldid = $nextid;
297 $this->mRevision = null;
298 } else {
299 $this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
300 }
301 } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
302 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
303 if ( $previd ) {
304 $oldid = $previd;
305 $this->mRevision = null;
306 }
307 }
308
309 return $oldid;
310 }
311
312 /**
313 * Get text of an article from database
314 * Does *NOT* follow redirects.
315 *
316 * @protected
317 * @note This is really internal functionality that should really NOT be
318 * used by other functions. For accessing article content, use the WikiPage
319 * class, especially WikiBase::getContent(). However, a lot of legacy code
320 * uses this method to retrieve page text from the database, so the function
321 * has to remain public for now.
322 *
323 * @return string|bool String containing article contents, or false if null
324 * @deprecated since 1.21, use WikiPage::getContent() instead
325 */
326 function fetchContent() {
327 // BC cruft!
328
329 ContentHandler::deprecated( __METHOD__, '1.21' );
330
331 if ( $this->mContentLoaded && $this->mContent ) {
332 return $this->mContent;
333 }
334
335 $content = $this->fetchContentObject();
336
337 if ( !$content ) {
338 return false;
339 }
340
341 // @todo Get rid of mContent everywhere!
342 $this->mContent = ContentHandler::getContentText( $content );
343 ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', [ &$this, &$this->mContent ] );
344
345 return $this->mContent;
346 }
347
348 /**
349 * Get text content object
350 * Does *NOT* follow redirects.
351 * @todo When is this null?
352 *
353 * @note Code that wants to retrieve page content from the database should
354 * use WikiPage::getContent().
355 *
356 * @return Content|null|bool
357 *
358 * @since 1.21
359 */
360 protected function fetchContentObject() {
361 if ( $this->mContentLoaded ) {
362 return $this->mContentObject;
363 }
364
365 $this->mContentLoaded = true;
366 $this->mContent = null;
367
368 $oldid = $this->getOldID();
369
370 # Pre-fill content with error message so that if something
371 # fails we'll have something telling us what we intended.
372 // XXX: this isn't page content but a UI message. horrible.
373 $this->mContentObject = new MessageContent( 'missing-revision', [ $oldid ] );
374
375 if ( $oldid ) {
376 # $this->mRevision might already be fetched by getOldIDFromRequest()
377 if ( !$this->mRevision ) {
378 $this->mRevision = Revision::newFromId( $oldid );
379 if ( !$this->mRevision ) {
380 wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" );
381 return false;
382 }
383 }
384 } else {
385 $oldid = $this->mPage->getLatest();
386 if ( !$oldid ) {
387 wfDebug( __METHOD__ . " failed to find page data for title " .
388 $this->getTitle()->getPrefixedText() . "\n" );
389 return false;
390 }
391
392 # Update error message with correct oldid
393 $this->mContentObject = new MessageContent( 'missing-revision', [ $oldid ] );
394
395 $this->mRevision = $this->mPage->getRevision();
396
397 if ( !$this->mRevision ) {
398 wfDebug( __METHOD__ . " failed to retrieve current page, rev_id $oldid\n" );
399 return false;
400 }
401 }
402
403 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
404 // We should instead work with the Revision object when we need it...
405 // Loads if user is allowed
406 $content = $this->mRevision->getContent(
407 Revision::FOR_THIS_USER,
408 $this->getContext()->getUser()
409 );
410
411 if ( !$content ) {
412 wfDebug( __METHOD__ . " failed to retrieve content of revision " .
413 $this->mRevision->getId() . "\n" );
414 return false;
415 }
416
417 $this->mContentObject = $content;
418 $this->mRevIdFetched = $this->mRevision->getId();
419
420 Hooks::run( 'ArticleAfterFetchContentObject', [ &$this, &$this->mContentObject ] );
421
422 return $this->mContentObject;
423 }
424
425 /**
426 * Returns true if the currently-referenced revision is the current edit
427 * to this page (and it exists).
428 * @return bool
429 */
430 public function isCurrent() {
431 # If no oldid, this is the current version.
432 if ( $this->getOldID() == 0 ) {
433 return true;
434 }
435
436 return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent();
437 }
438
439 /**
440 * Get the fetched Revision object depending on request parameters or null
441 * on failure.
442 *
443 * @since 1.19
444 * @return Revision|null
445 */
446 public function getRevisionFetched() {
447 $this->fetchContentObject();
448
449 return $this->mRevision;
450 }
451
452 /**
453 * Use this to fetch the rev ID used on page views
454 *
455 * @return int Revision ID of last article revision
456 */
457 public function getRevIdFetched() {
458 if ( $this->mRevIdFetched ) {
459 return $this->mRevIdFetched;
460 } else {
461 return $this->mPage->getLatest();
462 }
463 }
464
465 /**
466 * This is the default action of the index.php entry point: just view the
467 * page of the given title.
468 */
469 public function view() {
470 global $wgUseFileCache, $wgDebugToolbar, $wgMaxRedirects;
471
472 # Get variables from query string
473 # As side effect this will load the revision and update the title
474 # in a revision ID is passed in the request, so this should remain
475 # the first call of this method even if $oldid is used way below.
476 $oldid = $this->getOldID();
477
478 $user = $this->getContext()->getUser();
479 # Another whitelist check in case getOldID() is altering the title
480 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
481 if ( count( $permErrors ) ) {
482 wfDebug( __METHOD__ . ": denied on secondary read check\n" );
483 throw new PermissionsError( 'read', $permErrors );
484 }
485
486 $outputPage = $this->getContext()->getOutput();
487 # getOldID() may as well want us to redirect somewhere else
488 if ( $this->mRedirectUrl ) {
489 $outputPage->redirect( $this->mRedirectUrl );
490 wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
491
492 return;
493 }
494
495 # If we got diff in the query, we want to see a diff page instead of the article.
496 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
497 wfDebug( __METHOD__ . ": showing diff page\n" );
498 $this->showDiffPage();
499
500 return;
501 }
502
503 # Set page title (may be overridden by DISPLAYTITLE)
504 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
505
506 $outputPage->setArticleFlag( true );
507 # Allow frames by default
508 $outputPage->allowClickjacking();
509
510 $parserCache = ParserCache::singleton();
511
512 $parserOptions = $this->getParserOptions();
513 # Render printable version, use printable version cache
514 if ( $outputPage->isPrintable() ) {
515 $parserOptions->setIsPrintable( true );
516 $parserOptions->setEditSection( false );
517 } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user ) ) {
518 $parserOptions->setEditSection( false );
519 }
520
521 # Try client and file cache
522 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) {
523 # Use the greatest of the page's timestamp or the timestamp of any
524 # redirect in the chain (bug 67849)
525 $timestamp = $this->mPage->getTouched();
526 if ( isset( $this->mRedirectedFrom ) ) {
527 $timestamp = max( $timestamp, $this->mRedirectedFrom->getTouched() );
528
529 # If there can be more than one redirect in the chain, we have
530 # to go through the whole chain too in case an intermediate
531 # redirect was changed.
532 if ( $wgMaxRedirects > 1 ) {
533 $titles = Revision::newFromTitle( $this->mRedirectedFrom )
534 ->getContent( Revision::FOR_THIS_USER, $user )
535 ->getRedirectChain();
536 $thisTitle = $this->getTitle();
537 foreach ( $titles as $title ) {
538 if ( Title::compare( $title, $thisTitle ) === 0 ) {
539 break;
540 }
541 $timestamp = max( $timestamp, $title->getTouched() );
542 }
543 }
544 }
545
546 # Is it client cached?
547 if ( $outputPage->checkLastModified( $timestamp ) ) {
548 wfDebug( __METHOD__ . ": done 304\n" );
549
550 return;
551 # Try file cache
552 } elseif ( $wgUseFileCache && $this->tryFileCache() ) {
553 wfDebug( __METHOD__ . ": done file cache\n" );
554 # tell wgOut that output is taken care of
555 $outputPage->disable();
556 $this->mPage->doViewUpdates( $user, $oldid );
557
558 return;
559 }
560 }
561
562 # Should the parser cache be used?
563 $useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid );
564 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
565 if ( $user->getStubThreshold() ) {
566 $this->getContext()->getStats()->increment( 'pcache_miss_stub' );
567 }
568
569 $this->showRedirectedFromHeader();
570 $this->showNamespaceHeader();
571
572 # Iterate through the possible ways of constructing the output text.
573 # Keep going until $outputDone is set, or we run out of things to do.
574 $pass = 0;
575 $outputDone = false;
576 $this->mParserOutput = false;
577
578 while ( !$outputDone && ++$pass ) {
579 switch ( $pass ) {
580 case 1:
581 Hooks::run( 'ArticleViewHeader', [ &$this, &$outputDone, &$useParserCache ] );
582 break;
583 case 2:
584 # Early abort if the page doesn't exist
585 if ( !$this->mPage->exists() ) {
586 wfDebug( __METHOD__ . ": showing missing article\n" );
587 $this->showMissingArticle();
588 $this->mPage->doViewUpdates( $user );
589 return;
590 }
591
592 # Try the parser cache
593 if ( $useParserCache ) {
594 $this->mParserOutput = $parserCache->get( $this->mPage, $parserOptions );
595
596 if ( $this->mParserOutput !== false ) {
597 if ( $oldid ) {
598 wfDebug( __METHOD__ . ": showing parser cache contents for current rev permalink\n" );
599 $this->setOldSubtitle( $oldid );
600 } else {
601 wfDebug( __METHOD__ . ": showing parser cache contents\n" );
602 }
603 $outputPage->addParserOutput( $this->mParserOutput );
604 # Ensure that UI elements requiring revision ID have
605 # the correct version information.
606 $outputPage->setRevisionId( $this->mPage->getLatest() );
607 # Preload timestamp to avoid a DB hit
608 $cachedTimestamp = $this->mParserOutput->getTimestamp();
609 if ( $cachedTimestamp !== null ) {
610 $outputPage->setRevisionTimestamp( $cachedTimestamp );
611 $this->mPage->setTimestamp( $cachedTimestamp );
612 }
613 $outputDone = true;
614 }
615 }
616 break;
617 case 3:
618 # This will set $this->mRevision if needed
619 $this->fetchContentObject();
620
621 # Are we looking at an old revision
622 if ( $oldid && $this->mRevision ) {
623 $this->setOldSubtitle( $oldid );
624
625 if ( !$this->showDeletedRevisionHeader() ) {
626 wfDebug( __METHOD__ . ": cannot view deleted revision\n" );
627 return;
628 }
629 }
630
631 # Ensure that UI elements requiring revision ID have
632 # the correct version information.
633 $outputPage->setRevisionId( $this->getRevIdFetched() );
634 # Preload timestamp to avoid a DB hit
635 $outputPage->setRevisionTimestamp( $this->mPage->getTimestamp() );
636
637 # Pages containing custom CSS or JavaScript get special treatment
638 if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) {
639 wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
640 $this->showCssOrJsPage();
641 $outputDone = true;
642 } elseif ( !Hooks::run( 'ArticleContentViewCustom',
643 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
644
645 # Allow extensions do their own custom view for certain pages
646 $outputDone = true;
647 } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom',
648 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
649
650 # Allow extensions do their own custom view for certain pages
651 $outputDone = true;
652 }
653 break;
654 case 4:
655 # Run the parse, protected by a pool counter
656 wfDebug( __METHOD__ . ": doing uncached parse\n" );
657
658 $content = $this->getContentObject();
659 $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
660 $this->getRevIdFetched(), $useParserCache, $content );
661
662 if ( !$poolArticleView->execute() ) {
663 $error = $poolArticleView->getError();
664 if ( $error ) {
665 $outputPage->clearHTML(); // for release() errors
666 $outputPage->enableClientCache( false );
667 $outputPage->setRobotPolicy( 'noindex,nofollow' );
668
669 $errortext = $error->getWikiText( false, 'view-pool-error' );
670 $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
671 }
672 # Connection or timeout error
673 return;
674 }
675
676 $this->mParserOutput = $poolArticleView->getParserOutput();
677 $outputPage->addParserOutput( $this->mParserOutput );
678 if ( $content->getRedirectTarget() ) {
679 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
680 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
681 }
682
683 # Don't cache a dirty ParserOutput object
684 if ( $poolArticleView->getIsDirty() ) {
685 $outputPage->setCdnMaxage( 0 );
686 $outputPage->addHTML( "<!-- parser cache is expired, " .
687 "sending anyway due to pool overload-->\n" );
688 }
689
690 $outputDone = true;
691 break;
692 # Should be unreachable, but just in case...
693 default:
694 break 2;
695 }
696 }
697
698 # Get the ParserOutput actually *displayed* here.
699 # Note that $this->mParserOutput is the *current*/oldid version output.
700 $pOutput = ( $outputDone instanceof ParserOutput )
701 ? $outputDone // object fetched by hook
702 : $this->mParserOutput;
703
704 # Adjust title for main page & pages with displaytitle
705 if ( $pOutput ) {
706 $this->adjustDisplayTitle( $pOutput );
707 }
708
709 # For the main page, overwrite the <title> element with the con-
710 # tents of 'pagetitle-view-mainpage' instead of the default (if
711 # that's not empty).
712 # This message always exists because it is in the i18n files
713 if ( $this->getTitle()->isMainPage() ) {
714 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
715 if ( !$msg->isDisabled() ) {
716 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
717 }
718 }
719
720 # Check for any __NOINDEX__ tags on the page using $pOutput
721 $policy = $this->getRobotPolicy( 'view', $pOutput );
722 $outputPage->setIndexPolicy( $policy['index'] );
723 $outputPage->setFollowPolicy( $policy['follow'] );
724
725 $this->showViewFooter();
726 $this->mPage->doViewUpdates( $user, $oldid );
727
728 $outputPage->addModules( 'mediawiki.action.view.postEdit' );
729
730 }
731
732 /**
733 * Adjust title for pages with displaytitle, -{T|}- or language conversion
734 * @param ParserOutput $pOutput
735 */
736 public function adjustDisplayTitle( ParserOutput $pOutput ) {
737 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
738 $titleText = $pOutput->getTitleText();
739 if ( strval( $titleText ) !== '' ) {
740 $this->getContext()->getOutput()->setPageTitle( $titleText );
741 }
742 }
743
744 /**
745 * Show a diff page according to current request variables. For use within
746 * Article::view() only, other callers should use the DifferenceEngine class.
747 *
748 */
749 protected function showDiffPage() {
750 $request = $this->getContext()->getRequest();
751 $user = $this->getContext()->getUser();
752 $diff = $request->getVal( 'diff' );
753 $rcid = $request->getVal( 'rcid' );
754 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
755 $purge = $request->getVal( 'action' ) == 'purge';
756 $unhide = $request->getInt( 'unhide' ) == 1;
757 $oldid = $this->getOldID();
758
759 $rev = $this->getRevisionFetched();
760
761 if ( !$rev ) {
762 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
763 $msg = $this->getContext()->msg( 'difference-missing-revision' )
764 ->params( $oldid )
765 ->numParams( 1 )
766 ->parseAsBlock();
767 $this->getContext()->getOutput()->addHTML( $msg );
768 return;
769 }
770
771 $contentHandler = $rev->getContentHandler();
772 $de = $contentHandler->createDifferenceEngine(
773 $this->getContext(),
774 $oldid,
775 $diff,
776 $rcid,
777 $purge,
778 $unhide
779 );
780
781 // DifferenceEngine directly fetched the revision:
782 $this->mRevIdFetched = $de->mNewid;
783 $de->showDiffPage( $diffOnly );
784
785 // Run view updates for the newer revision being diffed (and shown
786 // below the diff if not $diffOnly).
787 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
788 // New can be false, convert it to 0 - this conveniently means the latest revision
789 $this->mPage->doViewUpdates( $user, (int)$new );
790 }
791
792 /**
793 * Show a page view for a page formatted as CSS or JavaScript. To be called by
794 * Article::view() only.
795 *
796 * This exists mostly to serve the deprecated ShowRawCssJs hook (used to customize these views).
797 * It has been replaced by the ContentGetParserOutput hook, which lets you do the same but with
798 * more flexibility.
799 *
800 * @param bool $showCacheHint Whether to show a message telling the user
801 * to clear the browser cache (default: true).
802 */
803 protected function showCssOrJsPage( $showCacheHint = true ) {
804 $outputPage = $this->getContext()->getOutput();
805
806 if ( $showCacheHint ) {
807 $dir = $this->getContext()->getLanguage()->getDir();
808 $lang = $this->getContext()->getLanguage()->getHtmlCode();
809
810 $outputPage->wrapWikiMsg(
811 "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
812 'clearyourcache'
813 );
814 }
815
816 $this->fetchContentObject();
817
818 if ( $this->mContentObject ) {
819 // Give hooks a chance to customise the output
820 if ( ContentHandler::runLegacyHooks(
821 'ShowRawCssJs',
822 [ $this->mContentObject, $this->getTitle(), $outputPage ] )
823 ) {
824 // If no legacy hooks ran, display the content of the parser output, including RL modules,
825 // but excluding metadata like categories and language links
826 $po = $this->mContentObject->getParserOutput( $this->getTitle() );
827 $outputPage->addParserOutputContent( $po );
828 }
829 }
830 }
831
832 /**
833 * Get the robot policy to be used for the current view
834 * @param string $action The action= GET parameter
835 * @param ParserOutput|null $pOutput
836 * @return array The policy that should be set
837 * @todo actions other than 'view'
838 */
839 public function getRobotPolicy( $action, $pOutput = null ) {
840 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
841
842 $ns = $this->getTitle()->getNamespace();
843
844 # Don't index user and user talk pages for blocked users (bug 11443)
845 if ( ( $ns == NS_USER || $ns == NS_USER_TALK ) && !$this->getTitle()->isSubpage() ) {
846 $specificTarget = null;
847 $vagueTarget = null;
848 $titleText = $this->getTitle()->getText();
849 if ( IP::isValid( $titleText ) ) {
850 $vagueTarget = $titleText;
851 } else {
852 $specificTarget = $titleText;
853 }
854 if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) {
855 return [
856 'index' => 'noindex',
857 'follow' => 'nofollow'
858 ];
859 }
860 }
861
862 if ( $this->mPage->getId() === 0 || $this->getOldID() ) {
863 # Non-articles (special pages etc), and old revisions
864 return [
865 'index' => 'noindex',
866 'follow' => 'nofollow'
867 ];
868 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
869 # Discourage indexing of printable versions, but encourage following
870 return [
871 'index' => 'noindex',
872 'follow' => 'follow'
873 ];
874 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
875 # For ?curid=x urls, disallow indexing
876 return [
877 'index' => 'noindex',
878 'follow' => 'follow'
879 ];
880 }
881
882 # Otherwise, construct the policy based on the various config variables.
883 $policy = self::formatRobotPolicy( $wgDefaultRobotPolicy );
884
885 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
886 # Honour customised robot policies for this namespace
887 $policy = array_merge(
888 $policy,
889 self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
890 );
891 }
892 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
893 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
894 # a final sanity check that we have really got the parser output.
895 $policy = array_merge(
896 $policy,
897 [ 'index' => $pOutput->getIndexPolicy() ]
898 );
899 }
900
901 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
902 # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
903 $policy = array_merge(
904 $policy,
905 self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
906 );
907 }
908
909 return $policy;
910 }
911
912 /**
913 * Converts a String robot policy into an associative array, to allow
914 * merging of several policies using array_merge().
915 * @param array|string $policy Returns empty array on null/false/'', transparent
916 * to already-converted arrays, converts string.
917 * @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
918 */
919 public static function formatRobotPolicy( $policy ) {
920 if ( is_array( $policy ) ) {
921 return $policy;
922 } elseif ( !$policy ) {
923 return [];
924 }
925
926 $policy = explode( ',', $policy );
927 $policy = array_map( 'trim', $policy );
928
929 $arr = [];
930 foreach ( $policy as $var ) {
931 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
932 $arr['index'] = $var;
933 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
934 $arr['follow'] = $var;
935 }
936 }
937
938 return $arr;
939 }
940
941 /**
942 * If this request is a redirect view, send "redirected from" subtitle to
943 * the output. Returns true if the header was needed, false if this is not
944 * a redirect view. Handles both local and remote redirects.
945 *
946 * @return bool
947 */
948 public function showRedirectedFromHeader() {
949 global $wgRedirectSources;
950
951 $context = $this->getContext();
952 $outputPage = $context->getOutput();
953 $request = $context->getRequest();
954 $rdfrom = $request->getVal( 'rdfrom' );
955
956 // Construct a URL for the current page view, but with the target title
957 $query = $request->getValues();
958 unset( $query['rdfrom'] );
959 unset( $query['title'] );
960 if ( $this->getTitle()->isRedirect() ) {
961 // Prevent double redirects
962 $query['redirect'] = 'no';
963 }
964 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
965
966 if ( isset( $this->mRedirectedFrom ) ) {
967 // This is an internally redirected page view.
968 // We'll need a backlink to the source page for navigation.
969 if ( Hooks::run( 'ArticleViewRedirect', [ &$this ] ) ) {
970 $redir = Linker::linkKnown(
971 $this->mRedirectedFrom,
972 null,
973 [],
974 [ 'redirect' => 'no' ]
975 );
976
977 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
978 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
979 . "</span>" );
980
981 // Add the script to update the displayed URL and
982 // set the fragment if one was specified in the redirect
983 $outputPage->addJsConfigVars( [
984 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
985 ] );
986 $outputPage->addModules( 'mediawiki.action.view.redirect' );
987
988 // Add a <link rel="canonical"> tag
989 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
990
991 // Tell the output object that the user arrived at this article through a redirect
992 $outputPage->setRedirectedFrom( $this->mRedirectedFrom );
993
994 return true;
995 }
996 } elseif ( $rdfrom ) {
997 // This is an externally redirected view, from some other wiki.
998 // If it was reported from a trusted site, supply a backlink.
999 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
1000 $redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
1001 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
1002 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
1003 . "</span>" );
1004
1005 // Add the script to update the displayed URL
1006 $outputPage->addJsConfigVars( [
1007 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
1008 ] );
1009 $outputPage->addModules( 'mediawiki.action.view.redirect' );
1010
1011 return true;
1012 }
1013 }
1014
1015 return false;
1016 }
1017
1018 /**
1019 * Show a header specific to the namespace currently being viewed, like
1020 * [[MediaWiki:Talkpagetext]]. For Article::view().
1021 */
1022 public function showNamespaceHeader() {
1023 if ( $this->getTitle()->isTalkPage() ) {
1024 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
1025 $this->getContext()->getOutput()->wrapWikiMsg(
1026 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
1027 [ 'talkpageheader' ]
1028 );
1029 }
1030 }
1031 }
1032
1033 /**
1034 * Show the footer section of an ordinary page view
1035 */
1036 public function showViewFooter() {
1037 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
1038 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
1039 && IP::isValid( $this->getTitle()->getText() )
1040 ) {
1041 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
1042 }
1043
1044 // Show a footer allowing the user to patrol the shown revision or page if possible
1045 $patrolFooterShown = $this->showPatrolFooter();
1046
1047 Hooks::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
1048 }
1049
1050 /**
1051 * If patrol is possible, output a patrol UI box. This is called from the
1052 * footer section of ordinary page views. If patrol is not possible or not
1053 * desired, does nothing.
1054 * Side effect: When the patrol link is build, this method will call
1055 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
1056 *
1057 * @return bool
1058 */
1059 public function showPatrolFooter() {
1060 global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
1061
1062 $outputPage = $this->getContext()->getOutput();
1063 $user = $this->getContext()->getUser();
1064 $title = $this->getTitle();
1065 $rc = false;
1066
1067 if ( !$title->quickUserCan( 'patrol', $user )
1068 || !( $wgUseRCPatrol || $wgUseNPPatrol
1069 || ( $wgUseFilePatrol && $title->inNamespace( NS_FILE ) ) )
1070 ) {
1071 // Patrolling is disabled or the user isn't allowed to
1072 return false;
1073 }
1074
1075 if ( $this->mRevision
1076 && !RecentChange::isInRCLifespan( $this->mRevision->getTimestamp(), 21600 )
1077 ) {
1078 // The current revision is already older than what could be in the RC table
1079 // 6h tolerance because the RC might not be cleaned out regularly
1080 return false;
1081 }
1082
1083 // Check for cached results
1084 $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() );
1085 $cache = ObjectCache::getMainWANInstance();
1086 if ( $cache->get( $key ) ) {
1087 return false;
1088 }
1089
1090 $dbr = wfGetDB( DB_SLAVE );
1091 $oldestRevisionTimestamp = $dbr->selectField(
1092 'revision',
1093 'MIN( rev_timestamp )',
1094 [ 'rev_page' => $title->getArticleID() ],
1095 __METHOD__
1096 );
1097
1098 // New page patrol: Get the timestamp of the oldest revison which
1099 // the revision table holds for the given page. Then we look
1100 // whether it's within the RC lifespan and if it is, we try
1101 // to get the recentchanges row belonging to that entry
1102 // (with rc_new = 1).
1103 $recentPageCreation = false;
1104 if ( $oldestRevisionTimestamp
1105 && RecentChange::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
1106 ) {
1107 // 6h tolerance because the RC might not be cleaned out regularly
1108 $recentPageCreation = true;
1109 $rc = RecentChange::newFromConds(
1110 [
1111 'rc_new' => 1,
1112 'rc_timestamp' => $oldestRevisionTimestamp,
1113 'rc_namespace' => $title->getNamespace(),
1114 'rc_cur_id' => $title->getArticleID()
1115 ],
1116 __METHOD__
1117 );
1118 if ( $rc ) {
1119 // Use generic patrol message for new pages
1120 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1121 }
1122 }
1123
1124 // File patrol: Get the timestamp of the latest upload for this page,
1125 // check whether it is within the RC lifespan and if it is, we try
1126 // to get the recentchanges row belonging to that entry
1127 // (with rc_type = RC_LOG, rc_log_type = upload).
1128 $recentFileUpload = false;
1129 if ( ( !$rc || $rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1130 && $title->getNamespace() === NS_FILE ) {
1131 // Retrieve timestamp of most recent upload
1132 $newestUploadTimestamp = $dbr->selectField(
1133 'image',
1134 'MAX( img_timestamp )',
1135 [ 'img_name' => $title->getDBkey() ],
1136 __METHOD__
1137 );
1138 if ( $newestUploadTimestamp
1139 && RecentChange::isInRCLifespan( $newestUploadTimestamp, 21600 )
1140 ) {
1141 // 6h tolerance because the RC might not be cleaned out regularly
1142 $recentFileUpload = true;
1143 $rc = RecentChange::newFromConds(
1144 [
1145 'rc_type' => RC_LOG,
1146 'rc_log_type' => 'upload',
1147 'rc_timestamp' => $newestUploadTimestamp,
1148 'rc_namespace' => NS_FILE,
1149 'rc_cur_id' => $title->getArticleID()
1150 ],
1151 __METHOD__,
1152 [ 'USE INDEX' => 'rc_timestamp' ]
1153 );
1154 if ( $rc ) {
1155 // Use patrol message specific to files
1156 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1157 }
1158 }
1159 }
1160
1161 if ( !$recentPageCreation && !$recentFileUpload ) {
1162 // Page creation and latest upload (for files) is too old to be in RC
1163
1164 // We definitely can't patrol so cache the information
1165 // When a new file version is uploaded, the cache is cleared
1166 $cache->set( $key, '1' );
1167
1168 return false;
1169 }
1170
1171 if ( !$rc ) {
1172 // Don't cache: This can be hit if the page gets accessed very fast after
1173 // its creation / latest upload or in case we have high slave lag. In case
1174 // the revision is too old, we will already return above.
1175 return false;
1176 }
1177
1178 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1179 // Patrolled RC entry around
1180
1181 // Cache the information we gathered above in case we can't patrol
1182 // Don't cache in case we can patrol as this could change
1183 $cache->set( $key, '1' );
1184
1185 return false;
1186 }
1187
1188 if ( $rc->getPerformer()->equals( $user ) ) {
1189 // Don't show a patrol link for own creations/uploads. If the user could
1190 // patrol them, they already would be patrolled
1191 return false;
1192 }
1193
1194 $rcid = $rc->getAttribute( 'rc_id' );
1195
1196 $token = $user->getEditToken( $rcid );
1197
1198 $outputPage->preventClickjacking();
1199 if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
1200 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1201 }
1202
1203 $link = Linker::linkKnown(
1204 $title,
1205 $markPatrolledMsg->escaped(),
1206 [],
1207 [
1208 'action' => 'markpatrolled',
1209 'rcid' => $rcid,
1210 'token' => $token,
1211 ]
1212 );
1213
1214 $outputPage->addHTML(
1215 "<div class='patrollink' data-mw='interface'>" .
1216 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1217 '</div>'
1218 );
1219
1220 return true;
1221 }
1222
1223 /**
1224 * Purge the cache used to check if it is worth showing the patrol footer
1225 * For example, it is done during re-uploads when file patrol is used.
1226 * @param int $articleID ID of the article to purge
1227 * @since 1.27
1228 */
1229 public static function purgePatrolFooterCache( $articleID ) {
1230 $cache = ObjectCache::getMainWANInstance();
1231 $cache->delete( wfMemcKey( 'unpatrollable-page', $articleID ) );
1232 }
1233
1234 /**
1235 * Show the error text for a missing article. For articles in the MediaWiki
1236 * namespace, show the default message text. To be called from Article::view().
1237 */
1238 public function showMissingArticle() {
1239 global $wgSend404Code;
1240
1241 $outputPage = $this->getContext()->getOutput();
1242 // Whether the page is a root user page of an existing user (but not a subpage)
1243 $validUserPage = false;
1244
1245 $title = $this->getTitle();
1246
1247 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1248 if ( $title->getNamespace() == NS_USER
1249 || $title->getNamespace() == NS_USER_TALK
1250 ) {
1251 $rootPart = explode( '/', $title->getText() )[0];
1252 $user = User::newFromName( $rootPart, false /* allow IP users*/ );
1253 $ip = User::isIP( $rootPart );
1254 $block = Block::newFromTarget( $user, $user );
1255
1256 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1257 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1258 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1259 } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
1260 # Show log extract if the user is currently blocked
1261 LogEventsList::showLogExtract(
1262 $outputPage,
1263 'block',
1264 MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
1265 '',
1266 [
1267 'lim' => 1,
1268 'showIfEmpty' => false,
1269 'msgKey' => [
1270 'blocked-notice-logextract',
1271 $user->getName() # Support GENDER in notice
1272 ]
1273 ]
1274 );
1275 $validUserPage = !$title->isSubpage();
1276 } else {
1277 $validUserPage = !$title->isSubpage();
1278 }
1279 }
1280
1281 Hooks::run( 'ShowMissingArticle', [ $this ] );
1282
1283 # Show delete and move logs if there were any such events.
1284 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1285 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1286 $cache = ObjectCache::getMainStashInstance();
1287 $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1288 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1289 if ( $loggedIn || $cache->get( $key ) ) {
1290 $logTypes = [ 'delete', 'move' ];
1291 $conds = [ "log_action != 'revision'" ];
1292 // Give extensions a chance to hide their (unrelated) log entries
1293 Hooks::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1294 LogEventsList::showLogExtract(
1295 $outputPage,
1296 $logTypes,
1297 $title,
1298 '',
1299 [
1300 'lim' => 10,
1301 'conds' => $conds,
1302 'showIfEmpty' => false,
1303 'msgKey' => [ $loggedIn
1304 ? 'moveddeleted-notice'
1305 : 'moveddeleted-notice-recent'
1306 ]
1307 ]
1308 );
1309 }
1310
1311 if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1312 // If there's no backing content, send a 404 Not Found
1313 // for better machine handling of broken links.
1314 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1315 }
1316
1317 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1318 $policy = $this->getRobotPolicy( 'view' );
1319 $outputPage->setIndexPolicy( $policy['index'] );
1320 $outputPage->setFollowPolicy( $policy['follow'] );
1321
1322 $hookResult = Hooks::run( 'BeforeDisplayNoArticleText', [ $this ] );
1323
1324 if ( !$hookResult ) {
1325 return;
1326 }
1327
1328 # Show error message
1329 $oldid = $this->getOldID();
1330 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI && $title->hasSourceText() ) {
1331 $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
1332 } else {
1333 if ( $oldid ) {
1334 $text = wfMessage( 'missing-revision', $oldid )->plain();
1335 } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1336 && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1337 ) {
1338 $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
1339 $text = wfMessage( $message )->plain();
1340 } else {
1341 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1342 }
1343
1344 $dir = $this->getContext()->getLanguage()->getDir();
1345 $lang = $this->getContext()->getLanguage()->getCode();
1346 $outputPage->addWikiText( Xml::openElement( 'div', [
1347 'class' => "noarticletext mw-content-$dir",
1348 'dir' => $dir,
1349 'lang' => $lang,
1350 ] ) . "\n$text\n</div>" );
1351 }
1352 }
1353
1354 /**
1355 * If the revision requested for view is deleted, check permissions.
1356 * Send either an error message or a warning header to the output.
1357 *
1358 * @return bool True if the view is allowed, false if not.
1359 */
1360 public function showDeletedRevisionHeader() {
1361 if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
1362 // Not deleted
1363 return true;
1364 }
1365
1366 $outputPage = $this->getContext()->getOutput();
1367 $user = $this->getContext()->getUser();
1368 // If the user is not allowed to see it...
1369 if ( !$this->mRevision->userCan( Revision::DELETED_TEXT, $user ) ) {
1370 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1371 'rev-deleted-text-permission' );
1372
1373 return false;
1374 // If the user needs to confirm that they want to see it...
1375 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1376 # Give explanation and add a link to view the revision...
1377 $oldid = intval( $this->getOldID() );
1378 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1379 $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
1380 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1381 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1382 [ $msg, $link ] );
1383
1384 return false;
1385 // We are allowed to see...
1386 } else {
1387 $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
1388 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1389 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1390
1391 return true;
1392 }
1393 }
1394
1395 /**
1396 * Generate the navigation links when browsing through an article revisions
1397 * It shows the information as:
1398 * Revision as of \<date\>; view current revision
1399 * \<- Previous version | Next Version -\>
1400 *
1401 * @param int $oldid Revision ID of this article revision
1402 */
1403 public function setOldSubtitle( $oldid = 0 ) {
1404 if ( !Hooks::run( 'DisplayOldSubtitle', [ &$this, &$oldid ] ) ) {
1405 return;
1406 }
1407
1408 $context = $this->getContext();
1409 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1410
1411 # Cascade unhide param in links for easy deletion browsing
1412 $extraParams = [];
1413 if ( $unhide ) {
1414 $extraParams['unhide'] = 1;
1415 }
1416
1417 if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
1418 $revision = $this->mRevision;
1419 } else {
1420 $revision = Revision::newFromId( $oldid );
1421 }
1422
1423 $timestamp = $revision->getTimestamp();
1424
1425 $current = ( $oldid == $this->mPage->getLatest() );
1426 $language = $context->getLanguage();
1427 $user = $context->getUser();
1428
1429 $td = $language->userTimeAndDate( $timestamp, $user );
1430 $tddate = $language->userDate( $timestamp, $user );
1431 $tdtime = $language->userTime( $timestamp, $user );
1432
1433 # Show user links if allowed to see them. If hidden, then show them only if requested...
1434 $userlinks = Linker::revUserTools( $revision, !$unhide );
1435
1436 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1437 ? 'revision-info-current'
1438 : 'revision-info';
1439
1440 $outputPage = $context->getOutput();
1441 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1442 $context->msg( $infomsg, $td )
1443 ->rawParams( $userlinks )
1444 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1445 ->rawParams( Linker::revComment( $revision, true, true ) )
1446 ->parse() .
1447 "</div>";
1448
1449 $lnk = $current
1450 ? $context->msg( 'currentrevisionlink' )->escaped()
1451 : Linker::linkKnown(
1452 $this->getTitle(),
1453 $context->msg( 'currentrevisionlink' )->escaped(),
1454 [],
1455 $extraParams
1456 );
1457 $curdiff = $current
1458 ? $context->msg( 'diff' )->escaped()
1459 : Linker::linkKnown(
1460 $this->getTitle(),
1461 $context->msg( 'diff' )->escaped(),
1462 [],
1463 [
1464 'diff' => 'cur',
1465 'oldid' => $oldid
1466 ] + $extraParams
1467 );
1468 $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1469 $prevlink = $prev
1470 ? Linker::linkKnown(
1471 $this->getTitle(),
1472 $context->msg( 'previousrevision' )->escaped(),
1473 [],
1474 [
1475 'direction' => 'prev',
1476 'oldid' => $oldid
1477 ] + $extraParams
1478 )
1479 : $context->msg( 'previousrevision' )->escaped();
1480 $prevdiff = $prev
1481 ? Linker::linkKnown(
1482 $this->getTitle(),
1483 $context->msg( 'diff' )->escaped(),
1484 [],
1485 [
1486 'diff' => 'prev',
1487 'oldid' => $oldid
1488 ] + $extraParams
1489 )
1490 : $context->msg( 'diff' )->escaped();
1491 $nextlink = $current
1492 ? $context->msg( 'nextrevision' )->escaped()
1493 : Linker::linkKnown(
1494 $this->getTitle(),
1495 $context->msg( 'nextrevision' )->escaped(),
1496 [],
1497 [
1498 'direction' => 'next',
1499 'oldid' => $oldid
1500 ] + $extraParams
1501 );
1502 $nextdiff = $current
1503 ? $context->msg( 'diff' )->escaped()
1504 : Linker::linkKnown(
1505 $this->getTitle(),
1506 $context->msg( 'diff' )->escaped(),
1507 [],
1508 [
1509 'diff' => 'next',
1510 'oldid' => $oldid
1511 ] + $extraParams
1512 );
1513
1514 $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
1515 if ( $cdel !== '' ) {
1516 $cdel .= ' ';
1517 }
1518
1519 // the outer div is need for styling the revision info and nav in MobileFrontend
1520 $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1521 "<div id=\"mw-revision-nav\">" . $cdel .
1522 $context->msg( 'revision-nav' )->rawParams(
1523 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1524 )->escaped() . "</div></div>" );
1525 }
1526
1527 /**
1528 * Return the HTML for the top of a redirect page
1529 *
1530 * Chances are you should just be using the ParserOutput from
1531 * WikitextContent::getParserOutput instead of calling this for redirects.
1532 *
1533 * @param Title|array $target Destination(s) to redirect
1534 * @param bool $appendSubtitle [optional]
1535 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1536 * @return string Containing HTML with redirect link
1537 */
1538 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1539 $lang = $this->getTitle()->getPageLanguage();
1540 $out = $this->getContext()->getOutput();
1541 if ( $appendSubtitle ) {
1542 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1543 }
1544 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1545 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1546 }
1547
1548 /**
1549 * Return the HTML for the top of a redirect page
1550 *
1551 * Chances are you should just be using the ParserOutput from
1552 * WikitextContent::getParserOutput instead of calling this for redirects.
1553 *
1554 * @since 1.23
1555 * @param Language $lang
1556 * @param Title|array $target Destination(s) to redirect
1557 * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
1558 * @return string Containing HTML with redirect link
1559 */
1560 public static function getRedirectHeaderHtml( Language $lang, $target, $forceKnown = false ) {
1561 if ( !is_array( $target ) ) {
1562 $target = [ $target ];
1563 }
1564
1565 $html = '<ul class="redirectText">';
1566 /** @var Title $title */
1567 foreach ( $target as $title ) {
1568 $html .= '<li>' . Linker::link(
1569 $title,
1570 htmlspecialchars( $title->getFullText() ),
1571 [],
1572 // Make sure wiki page redirects are not followed
1573 $title->isRedirect() ? [ 'redirect' => 'no' ] : [],
1574 ( $forceKnown ? [ 'known', 'noclasses' ] : [] )
1575 ) . '</li>';
1576 }
1577 $html .= '</ul>';
1578
1579 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1580
1581 return '<div class="redirectMsg">' .
1582 '<p>' . $redirectToText . '</p>' .
1583 $html .
1584 '</div>';
1585 }
1586
1587 /**
1588 * Adds help link with an icon via page indicators.
1589 * Link target can be overridden by a local message containing a wikilink:
1590 * the message key is: 'namespace-' + namespace number + '-helppage'.
1591 * @param string $to Target MediaWiki.org page title or encoded URL.
1592 * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
1593 * @since 1.25
1594 */
1595 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1596 $msg = wfMessage(
1597 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1598 );
1599
1600 $out = $this->getContext()->getOutput();
1601 if ( !$msg->isDisabled() ) {
1602 $helpUrl = Skin::makeUrl( $msg->plain() );
1603 $out->addHelpLink( $helpUrl, true );
1604 } else {
1605 $out->addHelpLink( $to, $overrideBaseUrl );
1606 }
1607 }
1608
1609 /**
1610 * Handle action=render
1611 */
1612 public function render() {
1613 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1614 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1615 $this->getContext()->getOutput()->enableSectionEditLinks( false );
1616 $this->view();
1617 }
1618
1619 /**
1620 * action=protect handler
1621 */
1622 public function protect() {
1623 $form = new ProtectionForm( $this );
1624 $form->execute();
1625 }
1626
1627 /**
1628 * action=unprotect handler (alias)
1629 */
1630 public function unprotect() {
1631 $this->protect();
1632 }
1633
1634 /**
1635 * UI entry point for page deletion
1636 */
1637 public function delete() {
1638 # This code desperately needs to be totally rewritten
1639
1640 $title = $this->getTitle();
1641 $context = $this->getContext();
1642 $user = $context->getUser();
1643 $request = $context->getRequest();
1644
1645 # Check permissions
1646 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1647 if ( count( $permissionErrors ) ) {
1648 throw new PermissionsError( 'delete', $permissionErrors );
1649 }
1650
1651 # Read-only check...
1652 if ( wfReadOnly() ) {
1653 throw new ReadOnlyError;
1654 }
1655
1656 # Better double-check that it hasn't been deleted yet!
1657 $this->mPage->loadPageData(
1658 $request->wasPosted() ? WikiPage::READ_LATEST : WikiPage::READ_NORMAL
1659 );
1660 if ( !$this->mPage->exists() ) {
1661 $deleteLogPage = new LogPage( 'delete' );
1662 $outputPage = $context->getOutput();
1663 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1664 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1665 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1666 );
1667 $outputPage->addHTML(
1668 Xml::element( 'h2', null, $deleteLogPage->getName()->text() )
1669 );
1670 LogEventsList::showLogExtract(
1671 $outputPage,
1672 'delete',
1673 $title
1674 );
1675
1676 return;
1677 }
1678
1679 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1680 $deleteReason = $request->getText( 'wpReason' );
1681
1682 if ( $deleteReasonList == 'other' ) {
1683 $reason = $deleteReason;
1684 } elseif ( $deleteReason != '' ) {
1685 // Entry from drop down menu + additional comment
1686 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1687 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1688 } else {
1689 $reason = $deleteReasonList;
1690 }
1691
1692 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1693 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1694 ) {
1695 # Flag to hide all contents of the archived revisions
1696 $suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1697
1698 $this->doDelete( $reason, $suppress );
1699
1700 WatchAction::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1701
1702 return;
1703 }
1704
1705 // Generate deletion reason
1706 $hasHistory = false;
1707 if ( !$reason ) {
1708 try {
1709 $reason = $this->generateReason( $hasHistory );
1710 } catch ( Exception $e ) {
1711 # if a page is horribly broken, we still want to be able to
1712 # delete it. So be lenient about errors here.
1713 wfDebug( "Error while building auto delete summary: $e" );
1714 $reason = '';
1715 }
1716 }
1717
1718 // If the page has a history, insert a warning
1719 if ( $hasHistory ) {
1720 $title = $this->getTitle();
1721
1722 // The following can use the real revision count as this is only being shown for users
1723 // that can delete this page.
1724 // This, as a side-effect, also makes sure that the following query isn't being run for
1725 // pages with a larger history, unless the user has the 'bigdelete' right
1726 // (and is about to delete this page).
1727 $dbr = wfGetDB( DB_SLAVE );
1728 $revisions = $edits = (int)$dbr->selectField(
1729 'revision',
1730 'COUNT(rev_page)',
1731 [ 'rev_page' => $title->getArticleID() ],
1732 __METHOD__
1733 );
1734
1735 // @todo FIXME: i18n issue/patchwork message
1736 $context->getOutput()->addHTML(
1737 '<strong class="mw-delete-warning-revisions">' .
1738 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1739 $context->msg( 'word-separator' )->escaped() . Linker::linkKnown( $title,
1740 $context->msg( 'history' )->escaped(),
1741 [],
1742 [ 'action' => 'history' ] ) .
1743 '</strong>'
1744 );
1745
1746 if ( $title->isBigDeletion() ) {
1747 global $wgDeleteRevisionsLimit;
1748 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1749 [
1750 'delete-warning-toobig',
1751 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1752 ]
1753 );
1754 }
1755 }
1756
1757 $this->confirmDelete( $reason );
1758 }
1759
1760 /**
1761 * Output deletion confirmation dialog
1762 * @todo FIXME: Move to another file?
1763 * @param string $reason Prefilled reason
1764 */
1765 public function confirmDelete( $reason ) {
1766 wfDebug( "Article::confirmDelete\n" );
1767
1768 $title = $this->getTitle();
1769 $ctx = $this->getContext();
1770 $outputPage = $ctx->getOutput();
1771 $useMediaWikiUIEverywhere = $ctx->getConfig()->get( 'UseMediaWikiUIEverywhere' );
1772 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1773 $outputPage->addBacklinkSubtitle( $title );
1774 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1775 $backlinkCache = $title->getBacklinkCache();
1776 if ( $backlinkCache->hasLinks( 'pagelinks' ) || $backlinkCache->hasLinks( 'templatelinks' ) ) {
1777 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1778 'deleting-backlinks-warning' );
1779 }
1780 $outputPage->addWikiMsg( 'confirmdeletetext' );
1781
1782 Hooks::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1783
1784 $user = $this->getContext()->getUser();
1785
1786 if ( $user->isAllowed( 'suppressrevision' ) ) {
1787 $suppress = Html::openElement( 'div', [ 'id' => 'wpDeleteSuppressRow' ] ) .
1788 Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
1789 'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '4' ] ) .
1790 Html::closeElement( 'div' );
1791 } else {
1792 $suppress = '';
1793 }
1794 $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $title );
1795
1796 $form = Html::openElement( 'form', [ 'method' => 'post',
1797 'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ] ) .
1798 Html::openElement( 'fieldset', [ 'id' => 'mw-delete-table' ] ) .
1799 Html::element( 'legend', null, wfMessage( 'delete-legend' )->text() ) .
1800 Html::openElement( 'div', [ 'id' => 'mw-deleteconfirm-table' ] ) .
1801 Html::openElement( 'div', [ 'id' => 'wpDeleteReasonListRow' ] ) .
1802 Html::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
1803 '&nbsp;' .
1804 Xml::listDropDown(
1805 'wpDeleteReasonList',
1806 wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
1807 wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(),
1808 '',
1809 'wpReasonDropDown',
1810 1
1811 ) .
1812 Html::closeElement( 'div' ) .
1813 Html::openElement( 'div', [ 'id' => 'wpDeleteReasonRow' ] ) .
1814 Html::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) .
1815 '&nbsp;' .
1816 Html::input( 'wpReason', $reason, 'text', [
1817 'size' => '60',
1818 'maxlength' => '255',
1819 'tabindex' => '2',
1820 'id' => 'wpReason',
1821 'class' => 'mw-ui-input-inline',
1822 'autofocus'
1823 ] ) .
1824 Html::closeElement( 'div' );
1825
1826 # Disallow watching if user is not logged in
1827 if ( $user->isLoggedIn() ) {
1828 $form .=
1829 Xml::checkLabel( wfMessage( 'watchthis' )->text(),
1830 'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] );
1831 }
1832
1833 $form .=
1834 Html::openElement( 'div' ) .
1835 $suppress .
1836 Xml::submitButton( wfMessage( 'deletepage' )->text(),
1837 [
1838 'name' => 'wpConfirmB',
1839 'id' => 'wpConfirmB',
1840 'tabindex' => '5',
1841 'class' => $useMediaWikiUIEverywhere ? 'mw-ui-button mw-ui-destructive' : '',
1842 ]
1843 ) .
1844 Html::closeElement( 'div' ) .
1845 Html::closeElement( 'div' ) .
1846 Xml::closeElement( 'fieldset' ) .
1847 Html::hidden(
1848 'wpEditToken',
1849 $user->getEditToken( [ 'delete', $title->getPrefixedText() ] )
1850 ) .
1851 Xml::closeElement( 'form' );
1852
1853 if ( $user->isAllowed( 'editinterface' ) ) {
1854 $link = Linker::linkKnown(
1855 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1856 wfMessage( 'delete-edit-reasonlist' )->escaped(),
1857 [],
1858 [ 'action' => 'edit' ]
1859 );
1860 $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
1861 }
1862
1863 $outputPage->addHTML( $form );
1864
1865 $deleteLogPage = new LogPage( 'delete' );
1866 $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1867 LogEventsList::showLogExtract( $outputPage, 'delete', $title );
1868 }
1869
1870 /**
1871 * Perform a deletion and output success or failure messages
1872 * @param string $reason
1873 * @param bool $suppress
1874 */
1875 public function doDelete( $reason, $suppress = false ) {
1876 $error = '';
1877 $context = $this->getContext();
1878 $outputPage = $context->getOutput();
1879 $user = $context->getUser();
1880 $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
1881
1882 if ( $status->isGood() ) {
1883 $deleted = $this->getTitle()->getPrefixedText();
1884
1885 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1886 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1887
1888 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1889
1890 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1891
1892 Hooks::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
1893
1894 $outputPage->returnToMain( false );
1895 } else {
1896 $outputPage->setPageTitle(
1897 wfMessage( 'cannotdelete-title',
1898 $this->getTitle()->getPrefixedText() )
1899 );
1900
1901 if ( $error == '' ) {
1902 $outputPage->addWikiText(
1903 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1904 );
1905 $deleteLogPage = new LogPage( 'delete' );
1906 $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1907
1908 LogEventsList::showLogExtract(
1909 $outputPage,
1910 'delete',
1911 $this->getTitle()
1912 );
1913 } else {
1914 $outputPage->addHTML( $error );
1915 }
1916 }
1917 }
1918
1919 /* Caching functions */
1920
1921 /**
1922 * checkLastModified returns true if it has taken care of all
1923 * output to the client that is necessary for this request.
1924 * (that is, it has sent a cached version of the page)
1925 *
1926 * @return bool True if cached version send, false otherwise
1927 */
1928 protected function tryFileCache() {
1929 static $called = false;
1930
1931 if ( $called ) {
1932 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1933 return false;
1934 }
1935
1936 $called = true;
1937 if ( $this->isFileCacheable() ) {
1938 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
1939 if ( $cache->isCacheGood( $this->mPage->getTouched() ) ) {
1940 wfDebug( "Article::tryFileCache(): about to load file\n" );
1941 $cache->loadFromFileCache( $this->getContext() );
1942 return true;
1943 } else {
1944 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1945 ob_start( [ &$cache, 'saveToFileCache' ] );
1946 }
1947 } else {
1948 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1949 }
1950
1951 return false;
1952 }
1953
1954 /**
1955 * Check if the page can be cached
1956 * @return bool
1957 */
1958 public function isFileCacheable() {
1959 $cacheable = false;
1960
1961 if ( HTMLFileCache::useFileCache( $this->getContext() ) ) {
1962 $cacheable = $this->mPage->getId()
1963 && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
1964 // Extension may have reason to disable file caching on some pages.
1965 if ( $cacheable ) {
1966 $cacheable = Hooks::run( 'IsFileCacheable', [ &$this ] );
1967 }
1968 }
1969
1970 return $cacheable;
1971 }
1972
1973 /**#@-*/
1974
1975 /**
1976 * Lightweight method to get the parser output for a page, checking the parser cache
1977 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1978 * consider, so it's not appropriate to use there.
1979 *
1980 * @since 1.16 (r52326) for LiquidThreads
1981 *
1982 * @param int|null $oldid Revision ID or null
1983 * @param User $user The relevant user
1984 * @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
1985 */
1986 public function getParserOutput( $oldid = null, User $user = null ) {
1987 // XXX: bypasses mParserOptions and thus setParserOptions()
1988
1989 if ( $user === null ) {
1990 $parserOptions = $this->getParserOptions();
1991 } else {
1992 $parserOptions = $this->mPage->makeParserOptions( $user );
1993 }
1994
1995 return $this->mPage->getParserOutput( $parserOptions, $oldid );
1996 }
1997
1998 /**
1999 * Override the ParserOptions used to render the primary article wikitext.
2000 *
2001 * @param ParserOptions $options
2002 * @throws MWException If the parser options where already initialized.
2003 */
2004 public function setParserOptions( ParserOptions $options ) {
2005 if ( $this->mParserOptions ) {
2006 throw new MWException( "can't change parser options after they have already been set" );
2007 }
2008
2009 // clone, so if $options is modified later, it doesn't confuse the parser cache.
2010 $this->mParserOptions = clone $options;
2011 }
2012
2013 /**
2014 * Get parser options suitable for rendering the primary article wikitext
2015 * @return ParserOptions
2016 */
2017 public function getParserOptions() {
2018 if ( !$this->mParserOptions ) {
2019 $this->mParserOptions = $this->mPage->makeParserOptions( $this->getContext() );
2020 }
2021 // Clone to allow modifications of the return value without affecting cache
2022 return clone $this->mParserOptions;
2023 }
2024
2025 /**
2026 * Sets the context this Article is executed in
2027 *
2028 * @param IContextSource $context
2029 * @since 1.18
2030 */
2031 public function setContext( $context ) {
2032 $this->mContext = $context;
2033 }
2034
2035 /**
2036 * Gets the context this Article is executed in
2037 *
2038 * @return IContextSource
2039 * @since 1.18
2040 */
2041 public function getContext() {
2042 if ( $this->mContext instanceof IContextSource ) {
2043 return $this->mContext;
2044 } else {
2045 wfDebug( __METHOD__ . " called and \$mContext is null. " .
2046 "Return RequestContext::getMain(); for sanity\n" );
2047 return RequestContext::getMain();
2048 }
2049 }
2050
2051 /**
2052 * Use PHP's magic __get handler to handle accessing of
2053 * raw WikiPage fields for backwards compatibility.
2054 *
2055 * @param string $fname Field name
2056 * @return mixed
2057 */
2058 public function __get( $fname ) {
2059 if ( property_exists( $this->mPage, $fname ) ) {
2060 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2061 return $this->mPage->$fname;
2062 }
2063 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE );
2064 }
2065
2066 /**
2067 * Use PHP's magic __set handler to handle setting of
2068 * raw WikiPage fields for backwards compatibility.
2069 *
2070 * @param string $fname Field name
2071 * @param mixed $fvalue New value
2072 */
2073 public function __set( $fname, $fvalue ) {
2074 if ( property_exists( $this->mPage, $fname ) ) {
2075 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2076 $this->mPage->$fname = $fvalue;
2077 // Note: extensions may want to toss on new fields
2078 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
2079 $this->mPage->$fname = $fvalue;
2080 } else {
2081 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE );
2082 }
2083 }
2084
2085 /**
2086 * Call to WikiPage function for backwards compatibility.
2087 * @see WikiPage::checkFlags
2088 */
2089 public function checkFlags( $flags ) {
2090 return $this->mPage->checkFlags( $flags );
2091 }
2092
2093 /**
2094 * Call to WikiPage function for backwards compatibility.
2095 * @see WikiPage::checkTouched
2096 */
2097 public function checkTouched() {
2098 return $this->mPage->checkTouched();
2099 }
2100
2101 /**
2102 * Call to WikiPage function for backwards compatibility.
2103 * @see WikiPage::clearPreparedEdit
2104 */
2105 public function clearPreparedEdit() {
2106 $this->mPage->clearPreparedEdit();
2107 }
2108
2109 /**
2110 * Call to WikiPage function for backwards compatibility.
2111 * @see WikiPage::doDeleteArticleReal
2112 */
2113 public function doDeleteArticleReal(
2114 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User $user = null
2115 ) {
2116 return $this->mPage->doDeleteArticleReal(
2117 $reason, $suppress, $u1, $u2, $error, $user
2118 );
2119 }
2120
2121 /**
2122 * Call to WikiPage function for backwards compatibility.
2123 * @see WikiPage::doDeleteUpdates
2124 */
2125 public function doDeleteUpdates( $id, Content $content = null ) {
2126 return $this->mPage->doDeleteUpdates( $id, $content );
2127 }
2128
2129 /**
2130 * Call to WikiPage function for backwards compatibility.
2131 * @see WikiPage::doEdit
2132 */
2133 public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
2134 ContentHandler::deprecated( __METHOD__, '1.21' );
2135 return $this->mPage->doEdit( $text, $summary, $flags, $baseRevId, $user );
2136 }
2137
2138 /**
2139 * Call to WikiPage function for backwards compatibility.
2140 * @see WikiPage::doEditContent
2141 */
2142 public function doEditContent( Content $content, $summary, $flags = 0, $baseRevId = false,
2143 User $user = null, $serialFormat = null
2144 ) {
2145 return $this->mPage->doEditContent( $content, $summary, $flags, $baseRevId,
2146 $user, $serialFormat
2147 );
2148 }
2149
2150 /**
2151 * Call to WikiPage function for backwards compatibility.
2152 * @see WikiPage::doEditUpdates
2153 */
2154 public function doEditUpdates( Revision $revision, User $user, array $options = [] ) {
2155 return $this->mPage->doEditUpdates( $revision, $user, $options );
2156 }
2157
2158 /**
2159 * Call to WikiPage function for backwards compatibility.
2160 * @see WikiPage::doPurge
2161 */
2162 public function doPurge() {
2163 return $this->mPage->doPurge();
2164 }
2165
2166 /**
2167 * Call to WikiPage function for backwards compatibility.
2168 * @see WikiPage::doQuickEditContent
2169 */
2170 public function doQuickEditContent(
2171 Content $content, User $user, $comment = '', $minor = false, $serialFormat = null
2172 ) {
2173 return $this->mPage->doQuickEditContent(
2174 $content, $user, $comment, $minor, $serialFormat
2175 );
2176 }
2177
2178 /**
2179 * Call to WikiPage function for backwards compatibility.
2180 * @see WikiPage::doViewUpdates
2181 */
2182 public function doViewUpdates( User $user, $oldid = 0 ) {
2183 $this->mPage->doViewUpdates( $user, $oldid );
2184 }
2185
2186 /**
2187 * Call to WikiPage function for backwards compatibility.
2188 * @see WikiPage::exists
2189 */
2190 public function exists() {
2191 return $this->mPage->exists();
2192 }
2193
2194 /**
2195 * Call to WikiPage function for backwards compatibility.
2196 * @see WikiPage::followRedirect
2197 */
2198 public function followRedirect() {
2199 return $this->mPage->followRedirect();
2200 }
2201
2202 /**
2203 * Call to WikiPage function for backwards compatibility.
2204 * @see ContentHandler::getActionOverrides
2205 */
2206 public function getActionOverrides() {
2207 return $this->mPage->getActionOverrides();
2208 }
2209
2210 /**
2211 * Call to WikiPage function for backwards compatibility.
2212 * @see WikiPage::getAutoDeleteReason
2213 */
2214 public function getAutoDeleteReason( &$hasHistory ) {
2215 return $this->mPage->getAutoDeleteReason( $hasHistory );
2216 }
2217
2218 /**
2219 * Call to WikiPage function for backwards compatibility.
2220 * @see WikiPage::getCategories
2221 */
2222 public function getCategories() {
2223 return $this->mPage->getCategories();
2224 }
2225
2226 /**
2227 * Call to WikiPage function for backwards compatibility.
2228 * @see WikiPage::getComment
2229 */
2230 public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2231 return $this->mPage->getComment( $audience, $user );
2232 }
2233
2234 /**
2235 * Call to WikiPage function for backwards compatibility.
2236 * @see WikiPage::getContentHandler
2237 */
2238 public function getContentHandler() {
2239 return $this->mPage->getContentHandler();
2240 }
2241
2242 /**
2243 * Call to WikiPage function for backwards compatibility.
2244 * @see WikiPage::getContentModel
2245 */
2246 public function getContentModel() {
2247 return $this->mPage->getContentModel();
2248 }
2249
2250 /**
2251 * Call to WikiPage function for backwards compatibility.
2252 * @see WikiPage::getContributors
2253 */
2254 public function getContributors() {
2255 return $this->mPage->getContributors();
2256 }
2257
2258 /**
2259 * Call to WikiPage function for backwards compatibility.
2260 * @see WikiPage::getCreator
2261 */
2262 public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2263 return $this->mPage->getCreator( $audience, $user );
2264 }
2265
2266 /**
2267 * Call to WikiPage function for backwards compatibility.
2268 * @see WikiPage::getDeletionUpdates
2269 */
2270 public function getDeletionUpdates( Content $content = null ) {
2271 return $this->mPage->getDeletionUpdates( $content );
2272 }
2273
2274 /**
2275 * Call to WikiPage function for backwards compatibility.
2276 * @see WikiPage::getHiddenCategories
2277 */
2278 public function getHiddenCategories() {
2279 return $this->mPage->getHiddenCategories();
2280 }
2281
2282 /**
2283 * Call to WikiPage function for backwards compatibility.
2284 * @see WikiPage::getId
2285 */
2286 public function getId() {
2287 return $this->mPage->getId();
2288 }
2289
2290 /**
2291 * Call to WikiPage function for backwards compatibility.
2292 * @see WikiPage::getLatest
2293 */
2294 public function getLatest() {
2295 return $this->mPage->getLatest();
2296 }
2297
2298 /**
2299 * Call to WikiPage function for backwards compatibility.
2300 * @see WikiPage::getLinksTimestamp
2301 */
2302 public function getLinksTimestamp() {
2303 return $this->mPage->getLinksTimestamp();
2304 }
2305
2306 /**
2307 * Call to WikiPage function for backwards compatibility.
2308 * @see WikiPage::getMinorEdit
2309 */
2310 public function getMinorEdit() {
2311 return $this->mPage->getMinorEdit();
2312 }
2313
2314 /**
2315 * Call to WikiPage function for backwards compatibility.
2316 * @see WikiPage::getOldestRevision
2317 */
2318 public function getOldestRevision() {
2319 return $this->mPage->getOldestRevision();
2320 }
2321
2322 /**
2323 * Call to WikiPage function for backwards compatibility.
2324 * @see WikiPage::getRedirectTarget
2325 */
2326 public function getRedirectTarget() {
2327 return $this->mPage->getRedirectTarget();
2328 }
2329
2330 /**
2331 * Call to WikiPage function for backwards compatibility.
2332 * @see WikiPage::getRedirectURL
2333 */
2334 public function getRedirectURL( $rt ) {
2335 return $this->mPage->getRedirectURL( $rt );
2336 }
2337
2338 /**
2339 * Call to WikiPage function for backwards compatibility.
2340 * @see WikiPage::getRevision
2341 */
2342 public function getRevision() {
2343 return $this->mPage->getRevision();
2344 }
2345
2346 /**
2347 * Call to WikiPage function for backwards compatibility.
2348 * @see WikiPage::getText
2349 */
2350 public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2351 ContentHandler::deprecated( __METHOD__, '1.21' );
2352 return $this->mPage->getText( $audience, $user );
2353 }
2354
2355 /**
2356 * Call to WikiPage function for backwards compatibility.
2357 * @see WikiPage::getTimestamp
2358 */
2359 public function getTimestamp() {
2360 return $this->mPage->getTimestamp();
2361 }
2362
2363 /**
2364 * Call to WikiPage function for backwards compatibility.
2365 * @see WikiPage::getTouched
2366 */
2367 public function getTouched() {
2368 return $this->mPage->getTouched();
2369 }
2370
2371 /**
2372 * Call to WikiPage function for backwards compatibility.
2373 * @see WikiPage::getUndoContent
2374 */
2375 public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
2376 return $this->mPage->getUndoContent( $undo, $undoafter );
2377 }
2378
2379 /**
2380 * Call to WikiPage function for backwards compatibility.
2381 * @see WikiPage::getUser
2382 */
2383 public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2384 return $this->mPage->getUser( $audience, $user );
2385 }
2386
2387 /**
2388 * Call to WikiPage function for backwards compatibility.
2389 * @see WikiPage::getUserText
2390 */
2391 public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2392 return $this->mPage->getUserText( $audience, $user );
2393 }
2394
2395 /**
2396 * Call to WikiPage function for backwards compatibility.
2397 * @see WikiPage::hasViewableContent
2398 */
2399 public function hasViewableContent() {
2400 return $this->mPage->hasViewableContent();
2401 }
2402
2403 /**
2404 * Call to WikiPage function for backwards compatibility.
2405 * @see WikiPage::insertOn
2406 */
2407 public function insertOn( $dbw, $pageId = null ) {
2408 return $this->mPage->insertOn( $dbw, $pageId );
2409 }
2410
2411 /**
2412 * Call to WikiPage function for backwards compatibility.
2413 * @see WikiPage::insertProtectNullRevision
2414 */
2415 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2416 array $expiry, $cascade, $reason, $user = null
2417 ) {
2418 return $this->mPage->insertProtectNullRevision( $revCommentMsg, $limit,
2419 $expiry, $cascade, $reason, $user
2420 );
2421 }
2422
2423 /**
2424 * Call to WikiPage function for backwards compatibility.
2425 * @see WikiPage::insertRedirect
2426 */
2427 public function insertRedirect() {
2428 return $this->mPage->insertRedirect();
2429 }
2430
2431 /**
2432 * Call to WikiPage function for backwards compatibility.
2433 * @see WikiPage::insertRedirectEntry
2434 */
2435 public function insertRedirectEntry( Title $rt, $oldLatest = null ) {
2436 return $this->mPage->insertRedirectEntry( $rt, $oldLatest );
2437 }
2438
2439 /**
2440 * Call to WikiPage function for backwards compatibility.
2441 * @see WikiPage::isCountable
2442 */
2443 public function isCountable( $editInfo = false ) {
2444 return $this->mPage->isCountable( $editInfo );
2445 }
2446
2447 /**
2448 * Call to WikiPage function for backwards compatibility.
2449 * @see WikiPage::isRedirect
2450 */
2451 public function isRedirect() {
2452 return $this->mPage->isRedirect();
2453 }
2454
2455 /**
2456 * Call to WikiPage function for backwards compatibility.
2457 * @see WikiPage::loadFromRow
2458 */
2459 public function loadFromRow( $data, $from ) {
2460 return $this->mPage->loadFromRow( $data, $from );
2461 }
2462
2463 /**
2464 * Call to WikiPage function for backwards compatibility.
2465 * @see WikiPage::loadPageData
2466 */
2467 public function loadPageData( $from = 'fromdb' ) {
2468 $this->mPage->loadPageData( $from );
2469 }
2470
2471 /**
2472 * Call to WikiPage function for backwards compatibility.
2473 * @see WikiPage::lockAndGetLatest
2474 */
2475 public function lockAndGetLatest() {
2476 return $this->mPage->lockAndGetLatest();
2477 }
2478
2479 /**
2480 * Call to WikiPage function for backwards compatibility.
2481 * @see WikiPage::makeParserOptions
2482 */
2483 public function makeParserOptions( $context ) {
2484 return $this->mPage->makeParserOptions( $context );
2485 }
2486
2487 /**
2488 * Call to WikiPage function for backwards compatibility.
2489 * @see WikiPage::pageDataFromId
2490 */
2491 public function pageDataFromId( $dbr, $id, $options = [] ) {
2492 return $this->mPage->pageDataFromId( $dbr, $id, $options );
2493 }
2494
2495 /**
2496 * Call to WikiPage function for backwards compatibility.
2497 * @see WikiPage::pageDataFromTitle
2498 */
2499 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2500 return $this->mPage->pageDataFromTitle( $dbr, $title, $options );
2501 }
2502
2503 /**
2504 * Call to WikiPage function for backwards compatibility.
2505 * @see WikiPage::prepareContentForEdit
2506 */
2507 public function prepareContentForEdit(
2508 Content $content, $revision = null, User $user = null,
2509 $serialFormat = null, $useCache = true
2510 ) {
2511 return $this->mPage->prepareContentForEdit(
2512 $content, $revision, $user,
2513 $serialFormat, $useCache
2514 );
2515 }
2516
2517 /**
2518 * Call to WikiPage function for backwards compatibility.
2519 * @see WikiPage::prepareTextForEdit
2520 */
2521 public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
2522 return $this->mPage->prepareTextForEdit( $text, $revid, $user );
2523 }
2524
2525 /**
2526 * Call to WikiPage function for backwards compatibility.
2527 * @see WikiPage::protectDescription
2528 */
2529 public function protectDescription( array $limit, array $expiry ) {
2530 return $this->mPage->protectDescription( $limit, $expiry );
2531 }
2532
2533 /**
2534 * Call to WikiPage function for backwards compatibility.
2535 * @see WikiPage::protectDescriptionLog
2536 */
2537 public function protectDescriptionLog( array $limit, array $expiry ) {
2538 return $this->mPage->protectDescriptionLog( $limit, $expiry );
2539 }
2540
2541 /**
2542 * Call to WikiPage function for backwards compatibility.
2543 * @see WikiPage::replaceSectionAtRev
2544 */
2545 public function replaceSectionAtRev( $sectionId, Content $sectionContent,
2546 $sectionTitle = '', $baseRevId = null
2547 ) {
2548 return $this->mPage->replaceSectionAtRev( $sectionId, $sectionContent,
2549 $sectionTitle, $baseRevId
2550 );
2551 }
2552
2553 /**
2554 * Call to WikiPage function for backwards compatibility.
2555 * @see WikiPage::replaceSectionContent
2556 */
2557 public function replaceSectionContent(
2558 $sectionId, Content $sectionContent, $sectionTitle = '', $edittime = null
2559 ) {
2560 return $this->mPage->replaceSectionContent(
2561 $sectionId, $sectionContent, $sectionTitle, $edittime
2562 );
2563 }
2564
2565 /**
2566 * Call to WikiPage function for backwards compatibility.
2567 * @see WikiPage::setTimestamp
2568 */
2569 public function setTimestamp( $ts ) {
2570 return $this->mPage->setTimestamp( $ts );
2571 }
2572
2573 /**
2574 * Call to WikiPage function for backwards compatibility.
2575 * @see WikiPage::shouldCheckParserCache
2576 */
2577 public function shouldCheckParserCache( ParserOptions $parserOptions, $oldId ) {
2578 return $this->mPage->shouldCheckParserCache( $parserOptions, $oldId );
2579 }
2580
2581 /**
2582 * Call to WikiPage function for backwards compatibility.
2583 * @see WikiPage::supportsSections
2584 */
2585 public function supportsSections() {
2586 return $this->mPage->supportsSections();
2587 }
2588
2589 /**
2590 * Call to WikiPage function for backwards compatibility.
2591 * @see WikiPage::triggerOpportunisticLinksUpdate
2592 */
2593 public function triggerOpportunisticLinksUpdate( ParserOutput $parserOutput ) {
2594 return $this->mPage->triggerOpportunisticLinksUpdate( $parserOutput );
2595 }
2596
2597 /**
2598 * Call to WikiPage function for backwards compatibility.
2599 * @see WikiPage::updateCategoryCounts
2600 */
2601 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2602 return $this->mPage->updateCategoryCounts( $added, $deleted, $id );
2603 }
2604
2605 /**
2606 * Call to WikiPage function for backwards compatibility.
2607 * @see WikiPage::updateIfNewerOn
2608 */
2609 public function updateIfNewerOn( $dbw, $revision ) {
2610 return $this->mPage->updateIfNewerOn( $dbw, $revision );
2611 }
2612
2613 /**
2614 * Call to WikiPage function for backwards compatibility.
2615 * @see WikiPage::updateRedirectOn
2616 */
2617 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2618 return $this->mPage->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null );
2619 }
2620
2621 /**
2622 * Call to WikiPage function for backwards compatibility.
2623 * @see WikiPage::updateRevisionOn
2624 */
2625 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2626 $lastRevIsRedirect = null
2627 ) {
2628 return $this->mPage->updateRevisionOn( $dbw, $revision, $lastRevision,
2629 $lastRevIsRedirect
2630 );
2631 }
2632
2633 /**
2634 * @param array $limit
2635 * @param array $expiry
2636 * @param bool $cascade
2637 * @param string $reason
2638 * @param User $user
2639 * @return Status
2640 */
2641 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2642 $reason, User $user
2643 ) {
2644 return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2645 }
2646
2647 /**
2648 * @param array $limit
2649 * @param string $reason
2650 * @param int $cascade
2651 * @param array $expiry
2652 * @return bool
2653 */
2654 public function updateRestrictions( $limit = [], $reason = '',
2655 &$cascade = 0, $expiry = []
2656 ) {
2657 return $this->mPage->doUpdateRestrictions(
2658 $limit,
2659 $expiry,
2660 $cascade,
2661 $reason,
2662 $this->getContext()->getUser()
2663 );
2664 }
2665
2666 /**
2667 * @param string $reason
2668 * @param bool $suppress
2669 * @param int $u1 Unused
2670 * @param bool $u2 Unused
2671 * @param string $error
2672 * @return bool
2673 */
2674 public function doDeleteArticle(
2675 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2676 ) {
2677 return $this->mPage->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2678 }
2679
2680 /**
2681 * @param string $fromP
2682 * @param string $summary
2683 * @param string $token
2684 * @param bool $bot
2685 * @param array $resultDetails
2686 * @param User|null $user
2687 * @return array
2688 */
2689 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
2690 $user = is_null( $user ) ? $this->getContext()->getUser() : $user;
2691 return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2692 }
2693
2694 /**
2695 * @param string $fromP
2696 * @param string $summary
2697 * @param bool $bot
2698 * @param array $resultDetails
2699 * @param User|null $guser
2700 * @return array
2701 */
2702 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
2703 $guser = is_null( $guser ) ? $this->getContext()->getUser() : $guser;
2704 return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2705 }
2706
2707 /**
2708 * @param bool $hasHistory
2709 * @return mixed
2710 */
2711 public function generateReason( &$hasHistory ) {
2712 $title = $this->mPage->getTitle();
2713 $handler = ContentHandler::getForTitle( $title );
2714 return $handler->getAutoDeleteReason( $title, $hasHistory );
2715 }
2716
2717 /**
2718 * @return array
2719 *
2720 * @deprecated since 1.24, use WikiPage::selectFields() instead
2721 */
2722 public static function selectFields() {
2723 wfDeprecated( __METHOD__, '1.24' );
2724 return WikiPage::selectFields();
2725 }
2726
2727 /**
2728 * @param Title $title
2729 *
2730 * @deprecated since 1.24, use WikiPage::onArticleCreate() instead
2731 */
2732 public static function onArticleCreate( $title ) {
2733 wfDeprecated( __METHOD__, '1.24' );
2734 WikiPage::onArticleCreate( $title );
2735 }
2736
2737 /**
2738 * @param Title $title
2739 *
2740 * @deprecated since 1.24, use WikiPage::onArticleDelete() instead
2741 */
2742 public static function onArticleDelete( $title ) {
2743 wfDeprecated( __METHOD__, '1.24' );
2744 WikiPage::onArticleDelete( $title );
2745 }
2746
2747 /**
2748 * @param Title $title
2749 *
2750 * @deprecated since 1.24, use WikiPage::onArticleEdit() instead
2751 */
2752 public static function onArticleEdit( $title ) {
2753 wfDeprecated( __METHOD__, '1.24' );
2754 WikiPage::onArticleEdit( $title );
2755 }
2756
2757 /**
2758 * @param string $oldtext
2759 * @param string $newtext
2760 * @param int $flags
2761 * @return string
2762 * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
2763 */
2764 public static function getAutosummary( $oldtext, $newtext, $flags ) {
2765 return WikiPage::getAutosummary( $oldtext, $newtext, $flags );
2766 }
2767 // ******
2768 }