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