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