MediaWiki REL1_34
Article.php
Go to the documentation of this file.
1<?php
27
38class Article implements Page {
43 protected $mContext;
44
46 protected $mPage;
47
53
63
70 public $mContentLoaded = false;
71
77 public $mOldId;
78
80 public $mRedirectedFrom = null;
81
83 public $mRedirectUrl = false;
84
90 public $mRevIdFetched = 0;
91
100 private $fetchResult = null;
101
109 public $mRevision = null;
110
116 public $mParserOutput = null;
117
123 protected $viewIsRenderAction = false;
124
130 public function __construct( Title $title, $oldId = null ) {
131 $this->mOldId = $oldId;
132 $this->mPage = $this->newPage( $title );
133 }
134
139 protected function newPage( Title $title ) {
140 return new WikiPage( $title );
141 }
142
148 public static function newFromID( $id ) {
149 $t = Title::newFromID( $id );
150 return $t == null ? null : new static( $t );
151 }
152
160 public static function newFromTitle( $title, IContextSource $context ) {
161 if ( NS_MEDIA == $title->getNamespace() ) {
162 // XXX: This should not be here, but where should it go?
163 $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
164 }
165
166 $page = null;
167 Hooks::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
168 if ( !$page ) {
169 switch ( $title->getNamespace() ) {
170 case NS_FILE:
171 $page = new ImagePage( $title );
172 break;
173 case NS_CATEGORY:
174 $page = new CategoryPage( $title );
175 break;
176 default:
177 $page = new Article( $title );
178 }
179 }
180 $page->setContext( $context );
181
182 return $page;
183 }
184
192 public static function newFromWikiPage( WikiPage $page, IContextSource $context ) {
193 $article = self::newFromTitle( $page->getTitle(), $context );
194 $article->mPage = $page; // override to keep process cached vars
195 return $article;
196 }
197
203 public function getRedirectedFrom() {
205 }
206
212 public function setRedirectedFrom( Title $from ) {
213 $this->mRedirectedFrom = $from;
214 }
215
221 public function getTitle() {
222 return $this->mPage->getTitle();
223 }
224
231 public function getPage() {
232 return $this->mPage;
233 }
234
238 public function clear() {
239 $this->mContentLoaded = false;
240
241 $this->mRedirectedFrom = null; # Title object if set
242 $this->mRevIdFetched = 0;
243 $this->mRedirectUrl = false;
244 $this->mRevision = null;
245 $this->mContentObject = null;
246 $this->fetchResult = null;
247
248 // TODO hard-deprecate direct access to public fields
249
250 $this->mPage->clear();
251 }
252
270 protected function getContentObject() {
271 if ( $this->mPage->getId() === 0 ) {
273 } else {
274 $this->fetchContentObject();
276 }
277
278 return $content;
279 }
280
286 private function getSubstituteContent() {
287 # If this is a MediaWiki:x message, then load the messages
288 # and return the message value for x.
289 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) {
290 $text = $this->getTitle()->getDefaultMessageText();
291 if ( $text === false ) {
292 $text = '';
293 }
294
295 $content = ContentHandler::makeContent( $text, $this->getTitle() );
296 } else {
297 $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
298 $content = new MessageContent( $message, null );
299 }
300
301 return $content;
302 }
303
313 protected function getEmptyPageParserOutput( ParserOptions $options ) {
315
316 return $content->getParserOutput( $this->getTitle(), 0, $options );
317 }
318
326 public function getOldID() {
327 if ( is_null( $this->mOldId ) ) {
328 $this->mOldId = $this->getOldIDFromRequest();
329 }
330
331 return $this->mOldId;
332 }
333
339 public function getOldIDFromRequest() {
340 $this->mRedirectUrl = false;
341
342 $request = $this->getContext()->getRequest();
343 $oldid = $request->getIntOrNull( 'oldid' );
344
345 if ( $oldid === null ) {
346 return 0;
347 }
348
349 if ( $oldid !== 0 ) {
350 # Load the given revision and check whether the page is another one.
351 # In that case, update this instance to reflect the change.
352 if ( $oldid === $this->mPage->getLatest() ) {
353 $this->mRevision = $this->mPage->getRevision();
354 } else {
355 $this->mRevision = Revision::newFromId( $oldid );
356 if ( $this->mRevision !== null ) {
357 // Revision title doesn't match the page title given?
358 if ( $this->mPage->getId() != $this->mRevision->getPage() ) {
359 $function = get_class( $this->mPage ) . '::newFromID';
360 $this->mPage = $function( $this->mRevision->getPage() );
361 }
362 }
363 }
364 }
365
366 $rl = MediaWikiServices::getInstance()->getRevisionLookup();
367 $oldRev = $this->mRevision ? $this->mRevision->getRevisionRecord() : null;
368 if ( $request->getVal( 'direction' ) == 'next' ) {
369 $nextid = 0;
370 if ( $oldRev ) {
371 $nextRev = $rl->getNextRevision( $oldRev );
372 if ( $nextRev ) {
373 $nextid = $nextRev->getId();
374 }
375 }
376 if ( $nextid ) {
377 $oldid = $nextid;
378 $this->mRevision = null;
379 } else {
380 $this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
381 }
382 } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
383 $previd = 0;
384 if ( $oldRev ) {
385 $prevRev = $rl->getPreviousRevision( $oldRev );
386 if ( $prevRev ) {
387 $previd = $prevRev->getId();
388 }
389 }
390 if ( $previd ) {
391 $oldid = $previd;
392 $this->mRevision = null;
393 }
394 }
395
396 $this->mRevIdFetched = $this->mRevision ? $this->mRevision->getId() : 0;
397
398 return $oldid;
399 }
400
414 protected function fetchContentObject() {
415 if ( !$this->mContentLoaded ) {
416 $this->fetchRevisionRecord();
417 }
418
420 }
421
431 protected function fetchRevisionRecord() {
432 if ( $this->fetchResult ) {
433 return $this->mRevision ? $this->mRevision->getRevisionRecord() : null;
434 }
435
436 $this->mContentLoaded = true;
437 $this->mContentObject = null;
438
439 $oldid = $this->getOldID();
440
441 // $this->mRevision might already be fetched by getOldIDFromRequest()
442 if ( !$this->mRevision ) {
443 if ( !$oldid ) {
444 $this->mRevision = $this->mPage->getRevision();
445
446 if ( !$this->mRevision ) {
447 wfDebug( __METHOD__ . " failed to find page data for title " .
448 $this->getTitle()->getPrefixedText() . "\n" );
449
450 // Just for sanity, output for this case is done by showMissingArticle().
451 $this->fetchResult = Status::newFatal( 'noarticletext' );
453 return null;
454 }
455 } else {
456 $this->mRevision = Revision::newFromId( $oldid );
457
458 if ( !$this->mRevision ) {
459 wfDebug( __METHOD__ . " failed to load revision, rev_id $oldid\n" );
460
461 $this->fetchResult = Status::newFatal( 'missing-revision', $oldid );
463 return null;
464 }
465 }
466 }
467
468 $this->mRevIdFetched = $this->mRevision->getId();
469 $this->fetchResult = Status::newGood( $this->mRevision );
470
471 if (
472 !$this->mRevision->userCan( RevisionRecord::DELETED_TEXT, $this->getContext()->getUser() )
473 ) {
474 wfDebug( __METHOD__ . " failed to retrieve content of revision " .
475 $this->mRevision->getId() . "\n" );
476
477 // Just for sanity, output for this case is done by showDeletedRevisionHeader().
478 $this->fetchResult = Status::newFatal( 'rev-deleted-text-permission' );
480 return null;
481 }
482
483 if ( Hooks::isRegistered( 'ArticleAfterFetchContentObject' ) ) {
484 $contentObject = $this->mRevision->getContent(
485 RevisionRecord::FOR_THIS_USER,
486 $this->getContext()->getUser()
487 );
488
489 $hookContentObject = $contentObject;
490
491 // Avoid PHP 7.1 warning of passing $this by reference
492 $articlePage = $this;
493
494 Hooks::run(
495 'ArticleAfterFetchContentObject',
496 [ &$articlePage, &$hookContentObject ],
497 '1.32'
498 );
499
500 if ( $hookContentObject !== $contentObject ) {
501 // A hook handler is trying to override the content
502 $this->applyContentOverride( $hookContentObject );
503 }
504 }
505
506 // For B/C only
507 $this->mContentObject = $this->mRevision->getContent(
508 RevisionRecord::FOR_THIS_USER,
509 $this->getContext()->getUser()
510 );
511
512 return $this->mRevision->getRevisionRecord();
513 }
514
521 private function makeFetchErrorContent() {
522 if ( !$this->fetchResult || $this->fetchResult->isOK() ) {
523 return null;
524 }
525
526 return new MessageContent( $this->fetchResult->getMessage() );
527 }
528
541 private function applyContentOverride( Content $override ) {
542 // Construct a fake revision
543 $rev = new MutableRevisionRecord( $this->getTitle() );
544 $rev->setContent( SlotRecord::MAIN, $override );
545
546 $this->mRevision = new Revision( $rev );
547
548 // For B/C only
549 $this->mContentObject = $override;
550 }
551
557 public function isCurrent() {
558 # If no oldid, this is the current version.
559 if ( $this->getOldID() == 0 ) {
560 return true;
561 }
562
563 return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent();
564 }
565
575 public function getRevisionFetched() {
576 $this->fetchRevisionRecord();
577
578 if ( $this->fetchResult->isOK() ) {
579 return $this->mRevision;
580 }
581 }
582
591 public function getRevIdFetched() {
592 if ( $this->fetchResult && $this->fetchResult->isOK() ) {
593 return $this->fetchResult->value->getId();
594 } else {
595 return $this->mPage->getLatest();
596 }
597 }
598
603 public function view() {
604 global $wgUseFileCache;
605
606 # Get variables from query string
607 # As side effect this will load the revision and update the title
608 # in a revision ID is passed in the request, so this should remain
609 # the first call of this method even if $oldid is used way below.
610 $oldid = $this->getOldID();
611
612 $user = $this->getContext()->getUser();
613 # Another whitelist check in case getOldID() is altering the title
614 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
615 if ( count( $permErrors ) ) {
616 wfDebug( __METHOD__ . ": denied on secondary read check\n" );
617 throw new PermissionsError( 'read', $permErrors );
618 }
619
620 $outputPage = $this->getContext()->getOutput();
621 # getOldID() may as well want us to redirect somewhere else
622 if ( $this->mRedirectUrl ) {
623 $outputPage->redirect( $this->mRedirectUrl );
624 wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
625
626 return;
627 }
628
629 # If we got diff in the query, we want to see a diff page instead of the article.
630 if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
631 wfDebug( __METHOD__ . ": showing diff page\n" );
632 $this->showDiffPage();
633
634 return;
635 }
636
637 # Set page title (may be overridden by DISPLAYTITLE)
638 $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
639
640 $outputPage->setArticleFlag( true );
641 # Allow frames by default
642 $outputPage->allowClickjacking();
643
644 $parserCache = MediaWikiServices::getInstance()->getParserCache();
645
646 $parserOptions = $this->getParserOptions();
647 $poOptions = [];
648 # Render printable version, use printable version cache
649 if ( $outputPage->isPrintable() ) {
650 $parserOptions->setIsPrintable( true );
651 $poOptions['enableSectionEditLinks'] = false;
652 } elseif ( $this->viewIsRenderAction || !$this->isCurrent() ||
653 !MediaWikiServices::getInstance()->getPermissionManager()
654 ->quickUserCan( 'edit', $user, $this->getTitle() )
655 ) {
656 $poOptions['enableSectionEditLinks'] = false;
657 }
658
659 # Try client and file cache
660 if ( $oldid === 0 && $this->mPage->checkTouched() ) {
661 # Try to stream the output from file cache
662 if ( $wgUseFileCache && $this->tryFileCache() ) {
663 wfDebug( __METHOD__ . ": done file cache\n" );
664 # tell wgOut that output is taken care of
665 $outputPage->disable();
666 $this->mPage->doViewUpdates( $user, $oldid );
667
668 return;
669 }
670 }
671
672 # Should the parser cache be used?
673 $useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid );
674 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
675 if ( $user->getStubThreshold() ) {
676 MediaWikiServices::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
677 }
678
680 $this->showNamespaceHeader();
681
682 # Iterate through the possible ways of constructing the output text.
683 # Keep going until $outputDone is set, or we run out of things to do.
684 $pass = 0;
685 $outputDone = false;
686 $this->mParserOutput = false;
687
688 while ( !$outputDone && ++$pass ) {
689 switch ( $pass ) {
690 case 1:
691 // Avoid PHP 7.1 warning of passing $this by reference
692 $articlePage = $this;
693 Hooks::run( 'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
694 break;
695 case 2:
696 # Early abort if the page doesn't exist
697 if ( !$this->mPage->exists() ) {
698 wfDebug( __METHOD__ . ": showing missing article\n" );
699 $this->showMissingArticle();
700 $this->mPage->doViewUpdates( $user );
701 return;
702 }
703
704 # Try the parser cache
705 if ( $useParserCache ) {
706 $this->mParserOutput = $parserCache->get( $this->mPage, $parserOptions );
707
708 if ( $this->mParserOutput !== false ) {
709 if ( $oldid ) {
710 wfDebug( __METHOD__ . ": showing parser cache contents for current rev permalink\n" );
711 $this->setOldSubtitle( $oldid );
712 } else {
713 wfDebug( __METHOD__ . ": showing parser cache contents\n" );
714 }
715 $outputPage->addParserOutput( $this->mParserOutput, $poOptions );
716 # Ensure that UI elements requiring revision ID have
717 # the correct version information.
718 $outputPage->setRevisionId( $this->mPage->getLatest() );
719 # Preload timestamp to avoid a DB hit
720 $cachedTimestamp = $this->mParserOutput->getTimestamp();
721 if ( $cachedTimestamp !== null ) {
722 $outputPage->setRevisionTimestamp( $cachedTimestamp );
723 $this->mPage->setTimestamp( $cachedTimestamp );
724 }
725 $outputDone = true;
726 }
727 }
728 break;
729 case 3:
730 # Are we looking at an old revision
731 $rev = $this->fetchRevisionRecord();
732 if ( $oldid && $this->fetchResult->isOK() ) {
733 $this->setOldSubtitle( $oldid );
734
735 if ( !$this->showDeletedRevisionHeader() ) {
736 wfDebug( __METHOD__ . ": cannot view deleted revision\n" );
737 return;
738 }
739 }
740
741 # Ensure that UI elements requiring revision ID have
742 # the correct version information.
743 $outputPage->setRevisionId( $this->getRevIdFetched() );
744 # Preload timestamp to avoid a DB hit
745 $outputPage->setRevisionTimestamp( $this->mPage->getTimestamp() );
746
747 # Pages containing custom CSS or JavaScript get special treatment
748 if ( $this->getTitle()->isSiteConfigPage() || $this->getTitle()->isUserConfigPage() ) {
749 $dir = $this->getContext()->getLanguage()->getDir();
750 $lang = $this->getContext()->getLanguage()->getHtmlCode();
751
752 $outputPage->wrapWikiMsg(
753 "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
754 'clearyourcache'
755 );
756 } elseif ( !Hooks::run( 'ArticleRevisionViewCustom', [
757 $rev,
758 $this->getTitle(),
759 $oldid,
760 $outputPage,
761 ] )
762 ) {
763 // NOTE: sync with hooks called in DifferenceEngine::renderNewRevision()
764 // Allow extensions do their own custom view for certain pages
765 $outputDone = true;
766 } elseif ( !Hooks::run( 'ArticleContentViewCustom',
767 [ $this->fetchContentObject(), $this->getTitle(), $outputPage ], '1.32' )
768 ) {
769 // NOTE: sync with hooks called in DifferenceEngine::renderNewRevision()
770 // Allow extensions do their own custom view for certain pages
771 $outputDone = true;
772 }
773 break;
774 case 4:
775 # Run the parse, protected by a pool counter
776 wfDebug( __METHOD__ . ": doing uncached parse\n" );
777
778 $rev = $this->fetchRevisionRecord();
779 $error = null;
780
781 if ( $rev ) {
782 $poolArticleView = new PoolWorkArticleView(
783 $this->getPage(),
784 $parserOptions,
785 $this->getRevIdFetched(),
786 $useParserCache,
787 $rev,
788 // permission checking was done earlier via showDeletedRevisionHeader()
789 RevisionRecord::RAW
790 );
791 $ok = $poolArticleView->execute();
792 $error = $poolArticleView->getError();
793 $this->mParserOutput = $poolArticleView->getParserOutput() ?: null;
794
795 # Don't cache a dirty ParserOutput object
796 if ( $poolArticleView->getIsDirty() ) {
797 $outputPage->setCdnMaxage( 0 );
798 $outputPage->addHTML( "<!-- parser cache is expired, " .
799 "sending anyway due to pool overload-->\n" );
800 }
801 } else {
802 $ok = false;
803 }
804
805 if ( !$ok ) {
806 if ( $error ) {
807 $outputPage->clearHTML(); // for release() errors
808 $outputPage->enableClientCache( false );
809 $outputPage->setRobotPolicy( 'noindex,nofollow' );
810
811 $errortext = $error->getWikiText(
812 false, 'view-pool-error', $this->getContext()->getLanguage()
813 );
814 $outputPage->wrapWikiTextAsInterface( 'errorbox', $errortext );
815 }
816 # Connection or timeout error
817 return;
818 }
819
820 if ( $this->mParserOutput ) {
821 $outputPage->addParserOutput( $this->mParserOutput, $poOptions );
822 }
823
824 if ( $rev && $this->getRevisionRedirectTarget( $rev ) ) {
825 $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
826 $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
827 }
828
829 $outputDone = true;
830 break;
831 # Should be unreachable, but just in case...
832 default:
833 break 2;
834 }
835 }
836
837 // Get the ParserOutput actually *displayed* here.
838 // Note that $this->mParserOutput is the *current*/oldid version output.
839 // Note that the ArticleViewHeader hook is allowed to set $outputDone to a
840 // ParserOutput instance.
841 $pOutput = ( $outputDone instanceof ParserOutput )
842 ? $outputDone // object fetched by hook
843 : ( $this->mParserOutput ?: null ); // ParserOutput or null, avoid false
844
845 # Adjust title for main page & pages with displaytitle
846 if ( $pOutput ) {
847 $this->adjustDisplayTitle( $pOutput );
848 }
849
850 # For the main page, overwrite the <title> element with the con-
851 # tents of 'pagetitle-view-mainpage' instead of the default (if
852 # that's not empty).
853 # This message always exists because it is in the i18n files
854 if ( $this->getTitle()->isMainPage() ) {
855 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
856 if ( !$msg->isDisabled() ) {
857 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
858 }
859 }
860
861 # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
862 # This could use getTouched(), but that could be scary for major template edits.
863 $outputPage->adaptCdnTTL( $this->mPage->getTimestamp(), IExpiringStore::TTL_DAY );
864
865 # Check for any __NOINDEX__ tags on the page using $pOutput
866 $policy = $this->getRobotPolicy( 'view', $pOutput ?: null );
867 $outputPage->setIndexPolicy( $policy['index'] );
868 $outputPage->setFollowPolicy( $policy['follow'] ); // FIXME: test this
869
870 $this->showViewFooter();
871 $this->mPage->doViewUpdates( $user, $oldid ); // FIXME: test this
872
873 # Load the postEdit module if the user just saved this revision
874 # See also EditPage::setPostEditCookie
875 $request = $this->getContext()->getRequest();
877 $postEdit = $request->getCookie( $cookieKey );
878 if ( $postEdit ) {
879 # Clear the cookie. This also prevents caching of the response.
880 $request->response()->clearCookie( $cookieKey );
881 $outputPage->addJsConfigVars( 'wgPostEdit', $postEdit );
882 $outputPage->addModules( 'mediawiki.action.view.postEdit' ); // FIXME: test this
883 }
884 }
885
890 private function getRevisionRedirectTarget( RevisionRecord $revision ) {
891 // TODO: find a *good* place for the code that determines the redirect target for
892 // a given revision!
893 // NOTE: Use main slot content. Compare code in DerivedPageDataUpdater::revisionIsRedirect.
894 $content = $revision->getContent( SlotRecord::MAIN );
895 return $content ? $content->getRedirectTarget() : null;
896 }
897
902 public function adjustDisplayTitle( ParserOutput $pOutput ) {
903 $out = $this->getContext()->getOutput();
904
905 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
906 $titleText = $pOutput->getTitleText();
907 if ( strval( $titleText ) !== '' ) {
908 $out->setPageTitle( $titleText );
909 $out->setDisplayTitle( $titleText );
910 }
911 }
912
917 protected function showDiffPage() {
918 $request = $this->getContext()->getRequest();
919 $user = $this->getContext()->getUser();
920 $diff = $request->getVal( 'diff' );
921 $rcid = $request->getVal( 'rcid' );
922 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
923 $purge = $request->getVal( 'action' ) == 'purge';
924 $unhide = $request->getInt( 'unhide' ) == 1;
925 $oldid = $this->getOldID();
926
927 $rev = $this->getRevisionFetched();
928
929 if ( !$rev ) {
930 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
931 $msg = $this->getContext()->msg( 'difference-missing-revision' )
932 ->params( $oldid )
933 ->numParams( 1 )
934 ->parseAsBlock();
935 $this->getContext()->getOutput()->addHTML( $msg );
936 return;
937 }
938
939 $contentHandler = $rev->getContentHandler();
940 $de = $contentHandler->createDifferenceEngine(
941 $this->getContext(),
942 $oldid,
943 $diff,
944 $rcid,
945 $purge,
946 $unhide
947 );
948
949 // DifferenceEngine directly fetched the revision:
950 $this->mRevIdFetched = $de->getNewid();
951 $de->showDiffPage( $diffOnly );
952
953 // Run view updates for the newer revision being diffed (and shown
954 // below the diff if not $diffOnly).
955 list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
956 // New can be false, convert it to 0 - this conveniently means the latest revision
957 $this->mPage->doViewUpdates( $user, (int)$new );
958 }
959
967 public function getRobotPolicy( $action, ParserOutput $pOutput = null ) {
969
970 $ns = $this->getTitle()->getNamespace();
971
972 # Don't index user and user talk pages for blocked users (T13443)
973 if ( ( $ns == NS_USER || $ns == NS_USER_TALK ) && !$this->getTitle()->isSubpage() ) {
974 $specificTarget = null;
975 $vagueTarget = null;
976 $titleText = $this->getTitle()->getText();
977 if ( IP::isValid( $titleText ) ) {
978 $vagueTarget = $titleText;
979 } else {
980 $specificTarget = $titleText;
981 }
982 if ( DatabaseBlock::newFromTarget( $specificTarget, $vagueTarget ) instanceof DatabaseBlock ) {
983 return [
984 'index' => 'noindex',
985 'follow' => 'nofollow'
986 ];
987 }
988 }
989
990 if ( $this->mPage->getId() === 0 || $this->getOldID() ) {
991 # Non-articles (special pages etc), and old revisions
992 return [
993 'index' => 'noindex',
994 'follow' => 'nofollow'
995 ];
996 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
997 # Discourage indexing of printable versions, but encourage following
998 return [
999 'index' => 'noindex',
1000 'follow' => 'follow'
1001 ];
1002 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
1003 # For ?curid=x urls, disallow indexing
1004 return [
1005 'index' => 'noindex',
1006 'follow' => 'follow'
1007 ];
1008 }
1009
1010 # Otherwise, construct the policy based on the various config variables.
1012
1013 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
1014 # Honour customised robot policies for this namespace
1015 $policy = array_merge(
1016 $policy,
1017 self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
1018 );
1019 }
1020 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
1021 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
1022 # a final sanity check that we have really got the parser output.
1023 $policy = array_merge(
1024 $policy,
1025 [ 'index' => $pOutput->getIndexPolicy() ]
1026 );
1027 }
1028
1029 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
1030 # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
1031 $policy = array_merge(
1032 $policy,
1033 self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
1034 );
1035 }
1036
1037 return $policy;
1038 }
1039
1047 public static function formatRobotPolicy( $policy ) {
1048 if ( is_array( $policy ) ) {
1049 return $policy;
1050 } elseif ( !$policy ) {
1051 return [];
1052 }
1053
1054 $policy = explode( ',', $policy );
1055 $policy = array_map( 'trim', $policy );
1056
1057 $arr = [];
1058 foreach ( $policy as $var ) {
1059 if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
1060 $arr['index'] = $var;
1061 } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
1062 $arr['follow'] = $var;
1063 }
1064 }
1065
1066 return $arr;
1067 }
1068
1076 public function showRedirectedFromHeader() {
1077 global $wgRedirectSources;
1078
1079 $context = $this->getContext();
1080 $outputPage = $context->getOutput();
1081 $request = $context->getRequest();
1082 $rdfrom = $request->getVal( 'rdfrom' );
1083
1084 // Construct a URL for the current page view, but with the target title
1085 $query = $request->getValues();
1086 unset( $query['rdfrom'] );
1087 unset( $query['title'] );
1088 if ( $this->getTitle()->isRedirect() ) {
1089 // Prevent double redirects
1090 $query['redirect'] = 'no';
1091 }
1092 $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
1093
1094 if ( isset( $this->mRedirectedFrom ) ) {
1095 // Avoid PHP 7.1 warning of passing $this by reference
1096 $articlePage = $this;
1097
1098 // This is an internally redirected page view.
1099 // We'll need a backlink to the source page for navigation.
1100 if ( Hooks::run( 'ArticleViewRedirect', [ &$articlePage ] ) ) {
1101 $redir = Linker::linkKnown(
1102 $this->mRedirectedFrom,
1103 null,
1104 [],
1105 [ 'redirect' => 'no' ]
1106 );
1107
1108 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
1109 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
1110 . "</span>" );
1111
1112 // Add the script to update the displayed URL and
1113 // set the fragment if one was specified in the redirect
1114 $outputPage->addJsConfigVars( [
1115 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
1116 ] );
1117 $outputPage->addModules( 'mediawiki.action.view.redirect' );
1118
1119 // Add a <link rel="canonical"> tag
1120 $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
1121
1122 // Tell the output object that the user arrived at this article through a redirect
1123 $outputPage->setRedirectedFrom( $this->mRedirectedFrom );
1124
1125 return true;
1126 }
1127 } elseif ( $rdfrom ) {
1128 // This is an externally redirected view, from some other wiki.
1129 // If it was reported from a trusted site, supply a backlink.
1130 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
1131 $redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
1132 $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
1133 $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
1134 . "</span>" );
1135
1136 // Add the script to update the displayed URL
1137 $outputPage->addJsConfigVars( [
1138 'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
1139 ] );
1140 $outputPage->addModules( 'mediawiki.action.view.redirect' );
1141
1142 return true;
1143 }
1144 }
1145
1146 return false;
1147 }
1148
1153 public function showNamespaceHeader() {
1154 if ( $this->getTitle()->isTalkPage() && !wfMessage( 'talkpageheader' )->isDisabled() ) {
1155 $this->getContext()->getOutput()->wrapWikiMsg(
1156 "<div class=\"mw-talkpageheader\">\n$1\n</div>",
1157 [ 'talkpageheader' ]
1158 );
1159 }
1160 }
1161
1165 public function showViewFooter() {
1166 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
1167 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
1168 && IP::isValid( $this->getTitle()->getText() )
1169 ) {
1170 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
1171 }
1172
1173 // Show a footer allowing the user to patrol the shown revision or page if possible
1174 $patrolFooterShown = $this->showPatrolFooter();
1175
1176 Hooks::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
1177 }
1178
1188 public function showPatrolFooter() {
1190
1191 // Allow hooks to decide whether to not output this at all
1192 if ( !Hooks::run( 'ArticleShowPatrolFooter', [ $this ] ) ) {
1193 return false;
1194 }
1195
1196 $outputPage = $this->getContext()->getOutput();
1197 $user = $this->getContext()->getUser();
1198 $title = $this->getTitle();
1199 $rc = false;
1200
1201 if ( !MediaWikiServices::getInstance()->getPermissionManager()
1202 ->quickUserCan( 'patrol', $user, $title )
1204 || ( $wgUseFilePatrol && $title->inNamespace( NS_FILE ) ) )
1205 ) {
1206 // Patrolling is disabled or the user isn't allowed to
1207 return false;
1208 }
1209
1210 if ( $this->mRevision
1211 && !RecentChange::isInRCLifespan( $this->mRevision->getTimestamp(), 21600 )
1212 ) {
1213 // The current revision is already older than what could be in the RC table
1214 // 6h tolerance because the RC might not be cleaned out regularly
1215 return false;
1216 }
1217
1218 // Check for cached results
1219 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1220 $key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() );
1221 if ( $cache->get( $key ) ) {
1222 return false;
1223 }
1224
1225 $dbr = wfGetDB( DB_REPLICA );
1226 $oldestRevisionTimestamp = $dbr->selectField(
1227 'revision',
1228 'MIN( rev_timestamp )',
1229 [ 'rev_page' => $title->getArticleID() ],
1230 __METHOD__
1231 );
1232
1233 // New page patrol: Get the timestamp of the oldest revison which
1234 // the revision table holds for the given page. Then we look
1235 // whether it's within the RC lifespan and if it is, we try
1236 // to get the recentchanges row belonging to that entry
1237 // (with rc_new = 1).
1238 $recentPageCreation = false;
1239 if ( $oldestRevisionTimestamp
1240 && RecentChange::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
1241 ) {
1242 // 6h tolerance because the RC might not be cleaned out regularly
1243 $recentPageCreation = true;
1244 $rc = RecentChange::newFromConds(
1245 [
1246 'rc_new' => 1,
1247 'rc_timestamp' => $oldestRevisionTimestamp,
1248 'rc_namespace' => $title->getNamespace(),
1249 'rc_cur_id' => $title->getArticleID()
1250 ],
1251 __METHOD__
1252 );
1253 if ( $rc ) {
1254 // Use generic patrol message for new pages
1255 $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1256 }
1257 }
1258
1259 // File patrol: Get the timestamp of the latest upload for this page,
1260 // check whether it is within the RC lifespan and if it is, we try
1261 // to get the recentchanges row belonging to that entry
1262 // (with rc_type = RC_LOG, rc_log_type = upload).
1263 $recentFileUpload = false;
1264 if ( ( !$rc || $rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1265 && $title->getNamespace() === NS_FILE ) {
1266 // Retrieve timestamp of most recent upload
1267 $newestUploadTimestamp = $dbr->selectField(
1268 'image',
1269 'MAX( img_timestamp )',
1270 [ 'img_name' => $title->getDBkey() ],
1271 __METHOD__
1272 );
1273 if ( $newestUploadTimestamp
1274 && RecentChange::isInRCLifespan( $newestUploadTimestamp, 21600 )
1275 ) {
1276 // 6h tolerance because the RC might not be cleaned out regularly
1277 $recentFileUpload = true;
1278 $rc = RecentChange::newFromConds(
1279 [
1280 'rc_type' => RC_LOG,
1281 'rc_log_type' => 'upload',
1282 'rc_timestamp' => $newestUploadTimestamp,
1283 'rc_namespace' => NS_FILE,
1284 'rc_cur_id' => $title->getArticleID()
1285 ],
1286 __METHOD__
1287 );
1288 if ( $rc ) {
1289 // Use patrol message specific to files
1290 $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1291 }
1292 }
1293 }
1294
1295 if ( !$recentPageCreation && !$recentFileUpload ) {
1296 // Page creation and latest upload (for files) is too old to be in RC
1297
1298 // We definitely can't patrol so cache the information
1299 // When a new file version is uploaded, the cache is cleared
1300 $cache->set( $key, '1' );
1301
1302 return false;
1303 }
1304
1305 if ( !$rc ) {
1306 // Don't cache: This can be hit if the page gets accessed very fast after
1307 // its creation / latest upload or in case we have high replica DB lag. In case
1308 // the revision is too old, we will already return above.
1309 return false;
1310 }
1311
1312 if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1313 // Patrolled RC entry around
1314
1315 // Cache the information we gathered above in case we can't patrol
1316 // Don't cache in case we can patrol as this could change
1317 $cache->set( $key, '1' );
1318
1319 return false;
1320 }
1321
1322 if ( $rc->getPerformer()->equals( $user ) ) {
1323 // Don't show a patrol link for own creations/uploads. If the user could
1324 // patrol them, they already would be patrolled
1325 return false;
1326 }
1327
1328 $outputPage->preventClickjacking();
1329 if ( MediaWikiServices::getInstance()
1331 ->userHasRight( $user, 'writeapi' )
1332 ) {
1333 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1334 }
1335
1336 $link = Linker::linkKnown(
1337 $title,
1338 $markPatrolledMsg->escaped(),
1339 [],
1340 [
1341 'action' => 'markpatrolled',
1342 'rcid' => $rc->getAttribute( 'rc_id' ),
1343 ]
1344 );
1345
1346 $outputPage->addHTML(
1347 "<div class='patrollink' data-mw='interface'>" .
1348 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1349 '</div>'
1350 );
1351
1352 return true;
1353 }
1354
1361 public static function purgePatrolFooterCache( $articleID ) {
1362 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
1363 $cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) );
1364 }
1365
1370 public function showMissingArticle() {
1371 global $wgSend404Code;
1372
1373 $outputPage = $this->getContext()->getOutput();
1374 // Whether the page is a root user page of an existing user (but not a subpage)
1375 $validUserPage = false;
1376
1377 $title = $this->getTitle();
1378
1379 $services = MediaWikiServices::getInstance();
1380
1381 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1382 if ( $title->getNamespace() == NS_USER
1383 || $title->getNamespace() == NS_USER_TALK
1384 ) {
1385 $rootPart = explode( '/', $title->getText() )[0];
1386 $user = User::newFromName( $rootPart, false /* allow IP users */ );
1387 $ip = User::isIP( $rootPart );
1388 $block = DatabaseBlock::newFromTarget( $user, $user );
1389
1390 if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1391 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1392 [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1393 } elseif (
1394 !is_null( $block ) &&
1395 $block->getType() != DatabaseBlock::TYPE_AUTO &&
1396 ( $block->isSitewide() || $user->isBlockedFrom( $title ) )
1397 ) {
1398 // Show log extract if the user is sitewide blocked or is partially
1399 // blocked and not allowed to edit their user page or user talk page
1401 $outputPage,
1402 'block',
1403 $services->getNamespaceInfo()->getCanonicalName( NS_USER ) . ':' .
1404 $block->getTarget(),
1405 '',
1406 [
1407 'lim' => 1,
1408 'showIfEmpty' => false,
1409 'msgKey' => [
1410 'blocked-notice-logextract',
1411 $user->getName() # Support GENDER in notice
1412 ]
1413 ]
1414 );
1415 $validUserPage = !$title->isSubpage();
1416 } else {
1417 $validUserPage = !$title->isSubpage();
1418 }
1419 }
1420
1421 Hooks::run( 'ShowMissingArticle', [ $this ] );
1422
1423 # Show delete and move logs if there were any such events.
1424 # The logging query can DOS the site when bots/crawlers cause 404 floods,
1425 # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1426 $dbCache = ObjectCache::getInstance( 'db-replicated' );
1427 $key = $dbCache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1428 $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1429 $sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
1430 if ( $loggedIn || $dbCache->get( $key ) || $sessionExists ) {
1431 $logTypes = [ 'delete', 'move', 'protect' ];
1432
1433 $dbr = wfGetDB( DB_REPLICA );
1434
1435 $conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
1436 // Give extensions a chance to hide their (unrelated) log entries
1437 Hooks::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1439 $outputPage,
1440 $logTypes,
1441 $title,
1442 '',
1443 [
1444 'lim' => 10,
1445 'conds' => $conds,
1446 'showIfEmpty' => false,
1447 'msgKey' => [ $loggedIn || $sessionExists
1448 ? 'moveddeleted-notice'
1449 : 'moveddeleted-notice-recent'
1450 ]
1451 ]
1452 );
1453 }
1454
1455 if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1456 // If there's no backing content, send a 404 Not Found
1457 // for better machine handling of broken links.
1458 $this->getContext()->getRequest()->response()->statusHeader( 404 );
1459 }
1460
1461 // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1462 $policy = $this->getRobotPolicy( 'view' );
1463 $outputPage->setIndexPolicy( $policy['index'] );
1464 $outputPage->setFollowPolicy( $policy['follow'] );
1465
1466 $hookResult = Hooks::run( 'BeforeDisplayNoArticleText', [ $this ] );
1467
1468 if ( !$hookResult ) {
1469 return;
1470 }
1471
1472 # Show error message
1473 $oldid = $this->getOldID();
1474 $pm = MediaWikiServices::getInstance()->getPermissionManager();
1475 if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI && $title->hasSourceText() ) {
1476 // use fake Content object for system message
1477 $parserOptions = ParserOptions::newCanonical( 'canonical' );
1478 $outputPage->addParserOutput( $this->getEmptyPageParserOutput( $parserOptions ) );
1479 } else {
1480 if ( $oldid ) {
1481 $text = wfMessage( 'missing-revision', $oldid )->plain();
1482 } elseif ( $pm->quickUserCan( 'create', $this->getContext()->getUser(), $title ) &&
1483 $pm->quickUserCan( 'edit', $this->getContext()->getUser(), $title )
1484 ) {
1485 $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
1486 $text = wfMessage( $message )->plain();
1487 } else {
1488 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1489 }
1490
1491 $dir = $this->getContext()->getLanguage()->getDir();
1492 $lang = $this->getContext()->getLanguage()->getHtmlCode();
1493 $outputPage->addWikiTextAsInterface( Xml::openElement( 'div', [
1494 'class' => "noarticletext mw-content-$dir",
1495 'dir' => $dir,
1496 'lang' => $lang,
1497 ] ) . "\n$text\n</div>" );
1498 }
1499 }
1500
1507 public function showDeletedRevisionHeader() {
1508 if ( !$this->mRevision->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
1509 // Not deleted
1510 return true;
1511 }
1512
1513 $outputPage = $this->getContext()->getOutput();
1514 $user = $this->getContext()->getUser();
1515 // If the user is not allowed to see it...
1516 if ( !$this->mRevision->userCan( RevisionRecord::DELETED_TEXT, $user ) ) {
1517 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1518 'rev-deleted-text-permission' );
1519
1520 return false;
1521 // If the user needs to confirm that they want to see it...
1522 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1523 # Give explanation and add a link to view the revision...
1524 $oldid = intval( $this->getOldID() );
1525 $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1526 $msg = $this->mRevision->isDeleted( RevisionRecord::DELETED_RESTRICTED ) ?
1527 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1528 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1529 [ $msg, $link ] );
1530
1531 return false;
1532 // We are allowed to see...
1533 } else {
1534 $msg = $this->mRevision->isDeleted( RevisionRecord::DELETED_RESTRICTED ) ?
1535 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1536 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1537
1538 return true;
1539 }
1540 }
1541
1550 public function setOldSubtitle( $oldid = 0 ) {
1551 // Avoid PHP 7.1 warning of passing $this by reference
1552 $articlePage = $this;
1553
1554 if ( !Hooks::run( 'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1555 return;
1556 }
1557
1558 $context = $this->getContext();
1559 $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1560
1561 # Cascade unhide param in links for easy deletion browsing
1562 $extraParams = [];
1563 if ( $unhide ) {
1564 $extraParams['unhide'] = 1;
1565 }
1566
1567 if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
1568 $revision = $this->mRevision;
1569 } else {
1570 $revision = Revision::newFromId( $oldid );
1571 }
1572
1573 $timestamp = $revision->getTimestamp();
1574
1575 $current = ( $oldid == $this->mPage->getLatest() );
1576 $language = $context->getLanguage();
1577 $user = $context->getUser();
1578
1579 $td = $language->userTimeAndDate( $timestamp, $user );
1580 $tddate = $language->userDate( $timestamp, $user );
1581 $tdtime = $language->userTime( $timestamp, $user );
1582
1583 # Show user links if allowed to see them. If hidden, then show them only if requested...
1584 $userlinks = Linker::revUserTools( $revision, !$unhide );
1585
1586 $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1587 ? 'revision-info-current'
1588 : 'revision-info';
1589
1590 $outputPage = $context->getOutput();
1591 $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1592 $context->msg( $infomsg, $td )
1593 ->rawParams( $userlinks )
1594 ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1595 ->rawParams( Linker::revComment( $revision, true, true ) )
1596 ->parse() .
1597 "</div>";
1598
1599 $lnk = $current
1600 ? $context->msg( 'currentrevisionlink' )->escaped()
1602 $this->getTitle(),
1603 $context->msg( 'currentrevisionlink' )->escaped(),
1604 [],
1605 $extraParams
1606 );
1607 $curdiff = $current
1608 ? $context->msg( 'diff' )->escaped()
1610 $this->getTitle(),
1611 $context->msg( 'diff' )->escaped(),
1612 [],
1613 [
1614 'diff' => 'cur',
1615 'oldid' => $oldid
1616 ] + $extraParams
1617 );
1618 $rl = MediaWikiServices::getInstance()->getRevisionLookup();
1619 $prevExist = (bool)$rl->getPreviousRevision( $revision->getRevisionRecord() );
1620 $prevlink = $prevExist
1622 $this->getTitle(),
1623 $context->msg( 'previousrevision' )->escaped(),
1624 [],
1625 [
1626 'direction' => 'prev',
1627 'oldid' => $oldid
1628 ] + $extraParams
1629 )
1630 : $context->msg( 'previousrevision' )->escaped();
1631 $prevdiff = $prevExist
1633 $this->getTitle(),
1634 $context->msg( 'diff' )->escaped(),
1635 [],
1636 [
1637 'diff' => 'prev',
1638 'oldid' => $oldid
1639 ] + $extraParams
1640 )
1641 : $context->msg( 'diff' )->escaped();
1642 $nextlink = $current
1643 ? $context->msg( 'nextrevision' )->escaped()
1645 $this->getTitle(),
1646 $context->msg( 'nextrevision' )->escaped(),
1647 [],
1648 [
1649 'direction' => 'next',
1650 'oldid' => $oldid
1651 ] + $extraParams
1652 );
1653 $nextdiff = $current
1654 ? $context->msg( 'diff' )->escaped()
1656 $this->getTitle(),
1657 $context->msg( 'diff' )->escaped(),
1658 [],
1659 [
1660 'diff' => 'next',
1661 'oldid' => $oldid
1662 ] + $extraParams
1663 );
1664
1665 $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
1666 if ( $cdel !== '' ) {
1667 $cdel .= ' ';
1668 }
1669
1670 // the outer div is need for styling the revision info and nav in MobileFrontend
1671 $outputPage->addSubtitle( "<div class=\"mw-revision warningbox\">" . $revisionInfo .
1672 "<div id=\"mw-revision-nav\">" . $cdel .
1673 $context->msg( 'revision-nav' )->rawParams(
1674 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1675 )->escaped() . "</div></div>" );
1676 }
1677
1691 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1692 $lang = $this->getTitle()->getPageLanguage();
1693 $out = $this->getContext()->getOutput();
1694 if ( $appendSubtitle ) {
1695 $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1696 }
1697 $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1698 return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1699 }
1700
1713 public static function getRedirectHeaderHtml( Language $lang, $target, $forceKnown = false ) {
1714 if ( !is_array( $target ) ) {
1715 $target = [ $target ];
1716 }
1717
1718 $html = '<ul class="redirectText">';
1720 foreach ( $target as $title ) {
1721 $html .= '<li>' . Linker::link(
1722 $title,
1723 htmlspecialchars( $title->getFullText() ),
1724 [],
1725 // Make sure wiki page redirects are not followed
1726 $title->isRedirect() ? [ 'redirect' => 'no' ] : [],
1727 ( $forceKnown ? [ 'known', 'noclasses' ] : [] )
1728 ) . '</li>';
1729 }
1730 $html .= '</ul>';
1731
1732 $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1733
1734 return '<div class="redirectMsg">' .
1735 '<p>' . $redirectToText . '</p>' .
1736 $html .
1737 '</div>';
1738 }
1739
1748 public function addHelpLink( $to, $overrideBaseUrl = false ) {
1749 $msg = wfMessage(
1750 'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1751 );
1752
1753 $out = $this->getContext()->getOutput();
1754 if ( !$msg->isDisabled() ) {
1755 $helpUrl = Skin::makeUrl( $msg->plain() );
1756 $out->addHelpLink( $helpUrl, true );
1757 } else {
1758 $out->addHelpLink( $to, $overrideBaseUrl );
1759 }
1760 }
1761
1765 public function render() {
1766 $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1767 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1768 // We later set 'enableSectionEditLinks=false' based on this; also used by ImagePage
1769 $this->viewIsRenderAction = true;
1770 $this->view();
1771 }
1772
1776 public function protect() {
1777 $form = new ProtectionForm( $this );
1778 $form->execute();
1779 }
1780
1784 public function unprotect() {
1785 $this->protect();
1786 }
1787
1791 public function delete() {
1792 # This code desperately needs to be totally rewritten
1793
1794 $title = $this->getTitle();
1795 $context = $this->getContext();
1796 $user = $context->getUser();
1797 $request = $context->getRequest();
1798
1799 # Check permissions
1800 $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1801 if ( count( $permissionErrors ) ) {
1802 throw new PermissionsError( 'delete', $permissionErrors );
1803 }
1804
1805 # Read-only check...
1806 if ( wfReadOnly() ) {
1807 throw new ReadOnlyError;
1808 }
1809
1810 # Better double-check that it hasn't been deleted yet!
1811 $this->mPage->loadPageData(
1812 $request->wasPosted() ? WikiPage::READ_LATEST : WikiPage::READ_NORMAL
1813 );
1814 if ( !$this->mPage->exists() ) {
1815 $deleteLogPage = new LogPage( 'delete' );
1816 $outputPage = $context->getOutput();
1817 $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1818 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1819 [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1820 );
1821 $outputPage->addHTML(
1822 Xml::element( 'h2', null, $deleteLogPage->getName()->text() )
1823 );
1825 $outputPage,
1826 'delete',
1827 $title
1828 );
1829
1830 return;
1831 }
1832
1833 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1834 $deleteReason = $request->getText( 'wpReason' );
1835
1836 if ( $deleteReasonList == 'other' ) {
1837 $reason = $deleteReason;
1838 } elseif ( $deleteReason != '' ) {
1839 // Entry from drop down menu + additional comment
1840 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1841 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1842 } else {
1843 $reason = $deleteReasonList;
1844 }
1845
1846 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1847 [ 'delete', $this->getTitle()->getPrefixedText() ] )
1848 ) {
1849 # Flag to hide all contents of the archived revisions
1850
1851 $suppress = $request->getCheck( 'wpSuppress' ) && MediaWikiServices::getInstance()
1852 ->getPermissionManager()
1853 ->userHasRight( $user, 'suppressrevision' );
1854
1855 $this->doDelete( $reason, $suppress );
1856
1857 WatchAction::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1858
1859 return;
1860 }
1861
1862 // Generate deletion reason
1863 $hasHistory = false;
1864 if ( !$reason ) {
1865 try {
1866 $reason = $this->generateReason( $hasHistory );
1867 } catch ( Exception $e ) {
1868 # if a page is horribly broken, we still want to be able to
1869 # delete it. So be lenient about errors here.
1870 wfDebug( "Error while building auto delete summary: $e" );
1871 $reason = '';
1872 }
1873 }
1874
1875 // If the page has a history, insert a warning
1876 if ( $hasHistory ) {
1877 $title = $this->getTitle();
1878
1879 // The following can use the real revision count as this is only being shown for users
1880 // that can delete this page.
1881 // This, as a side-effect, also makes sure that the following query isn't being run for
1882 // pages with a larger history, unless the user has the 'bigdelete' right
1883 // (and is about to delete this page).
1884 $dbr = wfGetDB( DB_REPLICA );
1885 $revisions = $edits = (int)$dbr->selectField(
1886 'revision',
1887 'COUNT(rev_page)',
1888 [ 'rev_page' => $title->getArticleID() ],
1889 __METHOD__
1890 );
1891
1892 // @todo i18n issue/patchwork message
1893 $context->getOutput()->addHTML(
1894 '<strong class="mw-delete-warning-revisions">' .
1895 $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1896 $context->msg( 'word-separator' )->escaped() . Linker::linkKnown( $title,
1897 $context->msg( 'history' )->escaped(),
1898 [],
1899 [ 'action' => 'history' ] ) .
1900 '</strong>'
1901 );
1902
1903 if ( $title->isBigDeletion() ) {
1905 $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1906 [
1907 'delete-warning-toobig',
1908 $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1909 ]
1910 );
1911 }
1912 }
1913
1914 $this->confirmDelete( $reason );
1915 }
1916
1922 public function confirmDelete( $reason ) {
1923 wfDebug( "Article::confirmDelete\n" );
1924
1925 $title = $this->getTitle();
1926 $ctx = $this->getContext();
1927 $outputPage = $ctx->getOutput();
1928 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1929 $outputPage->addBacklinkSubtitle( $title );
1930 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1931 $outputPage->addModules( 'mediawiki.action.delete' );
1932
1933 $backlinkCache = $title->getBacklinkCache();
1934 if ( $backlinkCache->hasLinks( 'pagelinks' ) || $backlinkCache->hasLinks( 'templatelinks' ) ) {
1935 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1936 'deleting-backlinks-warning' );
1937 }
1938
1939 $subpageQueryLimit = 51;
1940 $subpages = $title->getSubpages( $subpageQueryLimit );
1941 $subpageCount = count( $subpages );
1942 if ( $subpageCount > 0 ) {
1943 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1944 [ 'deleting-subpages-warning', Message::numParam( $subpageCount ) ] );
1945 }
1946 $outputPage->addWikiMsg( 'confirmdeletetext' );
1947
1948 Hooks::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1949
1950 $user = $this->getContext()->getUser();
1951 $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $title );
1952
1953 $outputPage->enableOOUI();
1954
1955 $fields = [];
1956
1957 $options = Xml::listDropDownOptions(
1958 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->text(),
1959 [ 'other' => $ctx->msg( 'deletereasonotherlist' )->inContentLanguage()->text() ]
1960 );
1961 $options = Xml::listDropDownOptionsOoui( $options );
1962
1963 $fields[] = new OOUI\FieldLayout(
1964 new OOUI\DropdownInputWidget( [
1965 'name' => 'wpDeleteReasonList',
1966 'inputId' => 'wpDeleteReasonList',
1967 'tabIndex' => 1,
1968 'infusable' => true,
1969 'value' => '',
1970 'options' => $options
1971 ] ),
1972 [
1973 'label' => $ctx->msg( 'deletecomment' )->text(),
1974 'align' => 'top',
1975 ]
1976 );
1977
1978 // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
1979 // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
1980 // Unicode codepoints.
1981 $fields[] = new OOUI\FieldLayout(
1982 new OOUI\TextInputWidget( [
1983 'name' => 'wpReason',
1984 'inputId' => 'wpReason',
1985 'tabIndex' => 2,
1986 'maxLength' => CommentStore::COMMENT_CHARACTER_LIMIT,
1987 'infusable' => true,
1988 'value' => $reason,
1989 'autofocus' => true,
1990 ] ),
1991 [
1992 'label' => $ctx->msg( 'deleteotherreason' )->text(),
1993 'align' => 'top',
1994 ]
1995 );
1996
1997 if ( $user->isLoggedIn() ) {
1998 $fields[] = new OOUI\FieldLayout(
1999 new OOUI\CheckboxInputWidget( [
2000 'name' => 'wpWatch',
2001 'inputId' => 'wpWatch',
2002 'tabIndex' => 3,
2003 'selected' => $checkWatch,
2004 ] ),
2005 [
2006 'label' => $ctx->msg( 'watchthis' )->text(),
2007 'align' => 'inline',
2008 'infusable' => true,
2009 ]
2010 );
2011 }
2012 $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
2013 if ( $permissionManager->userHasRight( $user, 'suppressrevision' ) ) {
2014 $fields[] = new OOUI\FieldLayout(
2015 new OOUI\CheckboxInputWidget( [
2016 'name' => 'wpSuppress',
2017 'inputId' => 'wpSuppress',
2018 'tabIndex' => 4,
2019 ] ),
2020 [
2021 'label' => $ctx->msg( 'revdelete-suppress' )->text(),
2022 'align' => 'inline',
2023 'infusable' => true,
2024 ]
2025 );
2026 }
2027
2028 $fields[] = new OOUI\FieldLayout(
2029 new OOUI\ButtonInputWidget( [
2030 'name' => 'wpConfirmB',
2031 'inputId' => 'wpConfirmB',
2032 'tabIndex' => 5,
2033 'value' => $ctx->msg( 'deletepage' )->text(),
2034 'label' => $ctx->msg( 'deletepage' )->text(),
2035 'flags' => [ 'primary', 'destructive' ],
2036 'type' => 'submit',
2037 ] ),
2038 [
2039 'align' => 'top',
2040 ]
2041 );
2042
2043 $fieldset = new OOUI\FieldsetLayout( [
2044 'label' => $ctx->msg( 'delete-legend' )->text(),
2045 'id' => 'mw-delete-table',
2046 'items' => $fields,
2047 ] );
2048
2049 $form = new OOUI\FormLayout( [
2050 'method' => 'post',
2051 'action' => $title->getLocalURL( 'action=delete' ),
2052 'id' => 'deleteconfirm',
2053 ] );
2054 $form->appendContent(
2055 $fieldset,
2056 new OOUI\HtmlSnippet(
2057 Html::hidden( 'wpEditToken', $user->getEditToken( [ 'delete', $title->getPrefixedText() ] ) )
2058 )
2059 );
2060
2061 $outputPage->addHTML(
2062 new OOUI\PanelLayout( [
2063 'classes' => [ 'deletepage-wrapper' ],
2064 'expanded' => false,
2065 'padded' => true,
2066 'framed' => true,
2067 'content' => $form,
2068 ] )
2069 );
2070
2071 if ( $permissionManager->userHasRight( $user, 'editinterface' ) ) {
2072 $link = Linker::linkKnown(
2073 $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
2074 wfMessage( 'delete-edit-reasonlist' )->escaped(),
2075 [],
2076 [ 'action' => 'edit' ]
2077 );
2078 $outputPage->addHTML( '<p class="mw-delete-editreasons">' . $link . '</p>' );
2079 }
2080
2081 $deleteLogPage = new LogPage( 'delete' );
2082 $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
2083 LogEventsList::showLogExtract( $outputPage, 'delete', $title );
2084 }
2085
2094 public function doDelete( $reason, $suppress = false, $immediate = false ) {
2095 $error = '';
2096 $context = $this->getContext();
2097 $outputPage = $context->getOutput();
2098 $user = $context->getUser();
2099 $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user,
2100 [], 'delete', $immediate );
2101
2102 if ( $status->isOK() ) {
2103 $deleted = $this->getTitle()->getPrefixedText();
2104
2105 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
2106 $outputPage->setRobotPolicy( 'noindex,nofollow' );
2107
2108 if ( $status->isGood() ) {
2109 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
2110 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
2111 Hooks::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
2112 } else {
2113 $outputPage->addWikiMsg( 'delete-scheduled', wfEscapeWikiText( $deleted ) );
2114 }
2115
2116 $outputPage->returnToMain( false );
2117 } else {
2118 $outputPage->setPageTitle(
2119 wfMessage( 'cannotdelete-title',
2120 $this->getTitle()->getPrefixedText() )
2121 );
2122
2123 if ( $error == '' ) {
2124 $outputPage->wrapWikiTextAsInterface(
2125 'error mw-error-cannotdelete',
2126 $status->getWikiText( false, false, $context->getLanguage() )
2127 );
2128 $deleteLogPage = new LogPage( 'delete' );
2129 $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
2130
2132 $outputPage,
2133 'delete',
2134 $this->getTitle()
2135 );
2136 } else {
2137 $outputPage->addHTML( $error );
2138 }
2139 }
2140 }
2141
2142 /* Caching functions */
2143
2151 protected function tryFileCache() {
2152 static $called = false;
2153
2154 if ( $called ) {
2155 wfDebug( "Article::tryFileCache(): called twice!?\n" );
2156 return false;
2157 }
2158
2159 $called = true;
2160 if ( $this->isFileCacheable() ) {
2161 $cache = new HTMLFileCache( $this->getTitle(), 'view' );
2162 if ( $cache->isCacheGood( $this->mPage->getTouched() ) ) {
2163 wfDebug( "Article::tryFileCache(): about to load file\n" );
2164 $cache->loadFromFileCache( $this->getContext() );
2165 return true;
2166 } else {
2167 wfDebug( "Article::tryFileCache(): starting buffer\n" );
2168 ob_start( [ &$cache, 'saveToFileCache' ] );
2169 }
2170 } else {
2171 wfDebug( "Article::tryFileCache(): not cacheable\n" );
2172 }
2173
2174 return false;
2175 }
2176
2182 public function isFileCacheable( $mode = HTMLFileCache::MODE_NORMAL ) {
2183 $cacheable = false;
2184
2185 if ( HTMLFileCache::useFileCache( $this->getContext(), $mode ) ) {
2186 $cacheable = $this->mPage->getId()
2187 && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
2188 // Extension may have reason to disable file caching on some pages.
2189 if ( $cacheable ) {
2190 // Avoid PHP 7.1 warning of passing $this by reference
2191 $articlePage = $this;
2192 $cacheable = Hooks::run( 'IsFileCacheable', [ &$articlePage ] );
2193 }
2194 }
2195
2196 return $cacheable;
2197 }
2198
2212 public function getParserOutput( $oldid = null, User $user = null ) {
2213 // XXX: bypasses mParserOptions and thus setParserOptions()
2214
2215 if ( $user === null ) {
2216 $parserOptions = $this->getParserOptions();
2217 } else {
2218 $parserOptions = $this->mPage->makeParserOptions( $user );
2219 }
2220
2221 return $this->mPage->getParserOutput( $parserOptions, $oldid );
2222 }
2223
2230 public function setParserOptions( ParserOptions $options ) {
2231 if ( $this->mParserOptions ) {
2232 throw new MWException( "can't change parser options after they have already been set" );
2233 }
2234
2235 // clone, so if $options is modified later, it doesn't confuse the parser cache.
2236 $this->mParserOptions = clone $options;
2237 }
2238
2243 public function getParserOptions() {
2244 if ( !$this->mParserOptions ) {
2245 $this->mParserOptions = $this->mPage->makeParserOptions( $this->getContext() );
2246 }
2247 // Clone to allow modifications of the return value without affecting cache
2248 return clone $this->mParserOptions;
2249 }
2250
2257 public function setContext( $context ) {
2258 $this->mContext = $context;
2259 }
2260
2267 public function getContext() {
2268 if ( $this->mContext instanceof IContextSource ) {
2269 return $this->mContext;
2270 } else {
2271 wfDebug( __METHOD__ . " called and \$mContext is null. " .
2272 "Return RequestContext::getMain(); for sanity\n" );
2273 return RequestContext::getMain();
2274 }
2275 }
2276
2284 public function __get( $fname ) {
2285 if ( property_exists( $this->mPage, $fname ) ) {
2286 # wfWarn( "Access to raw $fname field " . __CLASS__ );
2287 return $this->mPage->$fname;
2288 }
2289 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE );
2290 }
2291
2299 public function __set( $fname, $fvalue ) {
2300 if ( property_exists( $this->mPage, $fname ) ) {
2301 # wfWarn( "Access to raw $fname field of " . __CLASS__ );
2302 $this->mPage->$fname = $fvalue;
2303 // Note: extensions may want to toss on new fields
2304 } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
2305 $this->mPage->$fname = $fvalue;
2306 } else {
2307 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE );
2308 }
2309 }
2310
2315 public function checkFlags( $flags ) {
2316 return $this->mPage->checkFlags( $flags );
2317 }
2318
2323 public function checkTouched() {
2324 return $this->mPage->checkTouched();
2325 }
2326
2331 public function clearPreparedEdit() {
2332 $this->mPage->clearPreparedEdit();
2333 }
2334
2339 public function doDeleteArticleReal(
2340 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User $user = null,
2341 $tags = [], $immediate = false
2342 ) {
2343 return $this->mPage->doDeleteArticleReal(
2344 $reason, $suppress, $u1, $u2, $error, $user, $tags, 'delete', $immediate
2345 );
2346 }
2347
2352 public function doDeleteUpdates(
2353 $id,
2354 Content $content = null,
2355 $revision = null,
2356 User $user = null
2357 ) {
2358 $this->mPage->doDeleteUpdates( $id, $content, $revision, $user );
2359 }
2360
2366 public function doEditContent( Content $content, $summary, $flags = 0, $originalRevId = false,
2367 User $user = null, $serialFormat = null
2368 ) {
2369 wfDeprecated( __METHOD__, '1.29' );
2370 return $this->mPage->doEditContent( $content, $summary, $flags, $originalRevId,
2371 $user, $serialFormat
2372 );
2373 }
2374
2379 public function doEditUpdates( Revision $revision, User $user, array $options = [] ) {
2380 return $this->mPage->doEditUpdates( $revision, $user, $options );
2381 }
2382
2389 public function doPurge() {
2390 return $this->mPage->doPurge();
2391 }
2392
2397 public function doViewUpdates( User $user, $oldid = 0 ) {
2398 $this->mPage->doViewUpdates( $user, $oldid );
2399 }
2400
2405 public function exists() {
2406 return $this->mPage->exists();
2407 }
2408
2413 public function followRedirect() {
2414 return $this->mPage->followRedirect();
2415 }
2416
2421 public function getActionOverrides() {
2422 return $this->mPage->getActionOverrides();
2423 }
2424
2429 public function getAutoDeleteReason( &$hasHistory ) {
2430 return $this->mPage->getAutoDeleteReason( $hasHistory );
2431 }
2432
2437 public function getCategories() {
2438 return $this->mPage->getCategories();
2439 }
2440
2445 public function getComment( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) {
2446 return $this->mPage->getComment( $audience, $user );
2447 }
2448
2453 public function getContentHandler() {
2454 return $this->mPage->getContentHandler();
2455 }
2456
2461 public function getContentModel() {
2462 return $this->mPage->getContentModel();
2463 }
2464
2469 public function getContributors() {
2470 return $this->mPage->getContributors();
2471 }
2472
2477 public function getCreator( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) {
2478 return $this->mPage->getCreator( $audience, $user );
2479 }
2480
2485 public function getDeletionUpdates( Content $content = null ) {
2486 return $this->mPage->getDeletionUpdates( $content );
2487 }
2488
2493 public function getHiddenCategories() {
2494 return $this->mPage->getHiddenCategories();
2495 }
2496
2501 public function getId() {
2502 return $this->mPage->getId();
2503 }
2504
2509 public function getLatest() {
2510 return $this->mPage->getLatest();
2511 }
2512
2517 public function getLinksTimestamp() {
2518 return $this->mPage->getLinksTimestamp();
2519 }
2520
2525 public function getMinorEdit() {
2526 return $this->mPage->getMinorEdit();
2527 }
2528
2533 public function getOldestRevision() {
2534 return $this->mPage->getOldestRevision();
2535 }
2536
2541 public function getRedirectTarget() {
2542 return $this->mPage->getRedirectTarget();
2543 }
2544
2549 public function getRedirectURL( $rt ) {
2550 return $this->mPage->getRedirectURL( $rt );
2551 }
2552
2557 public function getRevision() {
2558 return $this->mPage->getRevision();
2559 }
2560
2565 public function getTimestamp() {
2566 return $this->mPage->getTimestamp();
2567 }
2568
2573 public function getTouched() {
2574 return $this->mPage->getTouched();
2575 }
2576
2581 public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
2582 return $this->mPage->getUndoContent( $undo, $undoafter );
2583 }
2584
2589 public function getUser( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) {
2590 return $this->mPage->getUser( $audience, $user );
2591 }
2592
2597 public function getUserText( $audience = RevisionRecord::FOR_PUBLIC, User $user = null ) {
2598 return $this->mPage->getUserText( $audience, $user );
2599 }
2600
2605 public function hasViewableContent() {
2606 return $this->mPage->hasViewableContent();
2607 }
2608
2613 public function insertOn( $dbw, $pageId = null ) {
2614 return $this->mPage->insertOn( $dbw, $pageId );
2615 }
2616
2621 public function insertProtectNullRevision( $revCommentMsg, array $limit,
2622 array $expiry, $cascade, $reason, $user = null
2623 ) {
2624 return $this->mPage->insertProtectNullRevision( $revCommentMsg, $limit,
2625 $expiry, $cascade, $reason, $user
2626 );
2627 }
2628
2633 public function insertRedirect() {
2634 return $this->mPage->insertRedirect();
2635 }
2636
2641 public function insertRedirectEntry( Title $rt, $oldLatest = null ) {
2642 return $this->mPage->insertRedirectEntry( $rt, $oldLatest );
2643 }
2644
2649 public function isCountable( $editInfo = false ) {
2650 return $this->mPage->isCountable( $editInfo );
2651 }
2652
2657 public function isRedirect() {
2658 return $this->mPage->isRedirect();
2659 }
2660
2665 public function loadFromRow( $data, $from ) {
2666 return $this->mPage->loadFromRow( $data, $from );
2667 }
2668
2673 public function loadPageData( $from = 'fromdb' ) {
2674 $this->mPage->loadPageData( $from );
2675 }
2676
2681 public function lockAndGetLatest() {
2682 return $this->mPage->lockAndGetLatest();
2683 }
2684
2689 public function makeParserOptions( $context ) {
2690 return $this->mPage->makeParserOptions( $context );
2691 }
2692
2697 public function pageDataFromId( $dbr, $id, $options = [] ) {
2698 return $this->mPage->pageDataFromId( $dbr, $id, $options );
2699 }
2700
2705 public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2706 return $this->mPage->pageDataFromTitle( $dbr, $title, $options );
2707 }
2708
2713 public function prepareContentForEdit(
2714 Content $content, $revision = null, User $user = null,
2715 $serialFormat = null, $useCache = true
2716 ) {
2717 return $this->mPage->prepareContentForEdit(
2718 $content, $revision, $user,
2719 $serialFormat, $useCache
2720 );
2721 }
2722
2727 public function protectDescription( array $limit, array $expiry ) {
2728 return $this->mPage->protectDescription( $limit, $expiry );
2729 }
2730
2735 public function protectDescriptionLog( array $limit, array $expiry ) {
2736 return $this->mPage->protectDescriptionLog( $limit, $expiry );
2737 }
2738
2743 public function replaceSectionAtRev( $sectionId, Content $sectionContent,
2744 $sectionTitle = '', $baseRevId = null
2745 ) {
2746 return $this->mPage->replaceSectionAtRev( $sectionId, $sectionContent,
2747 $sectionTitle, $baseRevId
2748 );
2749 }
2750
2755 public function replaceSectionContent(
2756 $sectionId, Content $sectionContent, $sectionTitle = '', $edittime = null
2757 ) {
2758 return $this->mPage->replaceSectionContent(
2759 $sectionId, $sectionContent, $sectionTitle, $edittime
2760 );
2761 }
2762
2767 public function setTimestamp( $ts ) {
2768 $this->mPage->setTimestamp( $ts );
2769 }
2770
2775 public function shouldCheckParserCache( ParserOptions $parserOptions, $oldId ) {
2776 return $this->mPage->shouldCheckParserCache( $parserOptions, $oldId );
2777 }
2778
2783 public function supportsSections() {
2784 return $this->mPage->supportsSections();
2785 }
2786
2791 public function triggerOpportunisticLinksUpdate( ParserOutput $parserOutput ) {
2792 return $this->mPage->triggerOpportunisticLinksUpdate( $parserOutput );
2793 }
2794
2799 public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2800 return $this->mPage->updateCategoryCounts( $added, $deleted, $id );
2801 }
2802
2807 public function updateIfNewerOn( $dbw, $revision ) {
2808 return $this->mPage->updateIfNewerOn( $dbw, $revision );
2809 }
2810
2815 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2816 return $this->mPage->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect );
2817 }
2818
2823 public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2824 $lastRevIsRedirect = null
2825 ) {
2826 return $this->mPage->updateRevisionOn( $dbw, $revision, $lastRevision,
2827 $lastRevIsRedirect
2828 );
2829 }
2830
2839 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2840 $reason, User $user
2841 ) {
2842 return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2843 }
2844
2852 public function updateRestrictions( $limit = [], $reason = '',
2853 &$cascade = 0, $expiry = []
2854 ) {
2855 return $this->mPage->doUpdateRestrictions(
2856 $limit,
2857 $expiry,
2858 $cascade,
2859 $reason,
2860 $this->getContext()->getUser()
2861 );
2862 }
2863
2875 public function doDeleteArticle(
2876 $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', $immediate = false
2877 ) {
2878 return $this->mPage->doDeleteArticle( $reason, $suppress, $u1, $u2, $error,
2879 null, $immediate );
2880 }
2881
2891 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
2892 if ( !$user ) {
2893 $user = $this->getContext()->getUser();
2894 }
2895
2896 return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2897 }
2898
2907 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
2908 if ( !$guser ) {
2909 $guser = $this->getContext()->getUser();
2910 }
2911
2912 return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2913 }
2914
2919 public function generateReason( &$hasHistory ) {
2920 $title = $this->mPage->getTitle();
2921 $handler = ContentHandler::getForTitle( $title );
2922 return $handler->getAutoDeleteReason( $title, $hasHistory );
2923 }
2924
2925 // ******
2926}
getPermissionManager()
getUser()
$wgArticleRobotPolicies
Robot policies per article.
$wgDefaultRobotPolicy
Default robot policy.
$wgSend404Code
Some web hosts attempt to rewrite all responses with a 404 (not found) status code,...
$wgRedirectSources
If local interwikis are set up which allow redirects, set this regexp to restrict URLs which will be ...
$wgUseFilePatrol
Use file patrolling to check new files on Special:Newfiles.
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
$wgNamespaceRobotPolicies
Robot policies per namespaces.
$wgUseNPPatrol
Use new page patrolling to check new pages on Special:Newpages.
$wgDeleteRevisionsLimit
Optional to restrict deletion of pages with higher revision counts to users with the 'bigdelete' perm...
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Class for viewing MediaWiki article and history.
Definition Article.php:38
shouldCheckParserCache(ParserOptions $parserOptions, $oldId)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2775
getRevisionFetched()
Get the fetched Revision object depending on request parameters or null on failure.
Definition Article.php:575
doDeleteUpdates( $id, Content $content=null, $revision=null, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2352
updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2815
generateReason(&$hasHistory)
Definition Article.php:2919
getSubstituteContent()
Returns Content object to use when the page does not exist.
Definition Article.php:286
checkFlags( $flags)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2315
checkTouched()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2323
getHiddenCategories()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2493
static newFromWikiPage(WikiPage $page, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition Article.php:192
doViewUpdates(User $user, $oldid=0)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2397
getContext()
Gets the context this Article is executed in.
Definition Article.php:2267
getCategories()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2437
commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser=null)
Definition Article.php:2907
getOldIDFromRequest()
Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.
Definition Article.php:339
getParserOutput( $oldid=null, User $user=null)
#-
Definition Article.php:2212
insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2621
doEditContent(Content $content, $summary, $flags=0, $originalRevId=false, User $user=null, $serialFormat=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2366
doPurge()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2389
getRedirectedFrom()
Get the page this view was redirected from.
Definition Article.php:203
Title null $mRedirectedFrom
Title from which we were redirected here, if any.
Definition Article.php:80
insertOn( $dbw, $pageId=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2613
updateRevisionOn( $dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2823
bool $viewIsRenderAction
Whether render() was called.
Definition Article.php:123
fetchContentObject()
Get text content object Does NOT follow redirects.
Definition Article.php:414
supportsSections()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2783
pageDataFromTitle( $dbr, $title, $options=[])
Call to WikiPage function for backwards compatibility.
Definition Article.php:2705
getContentHandler()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2453
updateCategoryCounts(array $added, array $deleted, $id=0)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2799
view()
This is the default action of the index.php entry point: just view the page of the given title.
Definition Article.php:603
loadPageData( $from='fromdb')
Call to WikiPage function for backwards compatibility.
Definition Article.php:2673
doDeleteArticleReal( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $user=null, $tags=[], $immediate=false)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2339
doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user)
Definition Article.php:2839
protectDescriptionLog(array $limit, array $expiry)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2735
WikiPage null $mPage
The WikiPage object of this instance.
Definition Article.php:46
getComment( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2445
clearPreparedEdit()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2331
__construct(Title $title, $oldId=null)
Constructor and clear the article.
Definition Article.php:130
getRobotPolicy( $action, ParserOutput $pOutput=null)
Get the robot policy to be used for the current view.
Definition Article.php:967
static purgePatrolFooterCache( $articleID)
Purge the cache used to check if it is worth showing the patrol footer For example,...
Definition Article.php:1361
followRedirect()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2413
prepareContentForEdit(Content $content, $revision=null, User $user=null, $serialFormat=null, $useCache=true)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2713
doDelete( $reason, $suppress=false, $immediate=false)
Perform a deletion and output success or failure messages.
Definition Article.php:2094
replaceSectionAtRev( $sectionId, Content $sectionContent, $sectionTitle='', $baseRevId=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2743
ParserOutput null false $mParserOutput
The ParserOutput generated for viewing the page, initialized by view().
Definition Article.php:116
getAutoDeleteReason(&$hasHistory)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2429
getLinksTimestamp()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2517
getOldID()
Definition Article.php:326
protectDescription(array $limit, array $expiry)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2727
getOldestRevision()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2533
setTimestamp( $ts)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2767
getTitle()
Get the title object of the article.
Definition Article.php:221
getActionOverrides()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2421
doEditUpdates(Revision $revision, User $user, array $options=[])
Call to WikiPage function for backwards compatibility.
Definition Article.php:2379
adjustDisplayTitle(ParserOutput $pOutput)
Adjust title for pages with displaytitle, -{T|}- or language conversion.
Definition Article.php:902
updateIfNewerOn( $dbw, $revision)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2807
getLatest()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2509
pageDataFromId( $dbr, $id, $options=[])
Call to WikiPage function for backwards compatibility.
Definition Article.php:2697
insertRedirect()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2633
getContributors()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2469
showDeletedRevisionHeader()
If the revision requested for view is deleted, check permissions.
Definition Article.php:1507
isCountable( $editInfo=false)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2649
getParserOptions()
Get parser options suitable for rendering the primary article wikitext.
Definition Article.php:2243
clear()
Clear the object.
Definition Article.php:238
IContextSource null $mContext
The context this Article is executed in.
Definition Article.php:43
getContentModel()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2461
Revision null $mRevision
Revision to be shown.
Definition Article.php:109
static getRedirectHeaderHtml(Language $lang, $target, $forceKnown=false)
Return the HTML for the top of a redirect page.
Definition Article.php:1713
getUserText( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2597
protect()
action=protect handler
Definition Article.php:1776
lockAndGetLatest()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2681
isCurrent()
Returns true if the currently-referenced revision is the current edit to this page (and it exists).
Definition Article.php:557
updateRestrictions( $limit=[], $reason='', &$cascade=0, $expiry=[])
Definition Article.php:2852
showMissingArticle()
Show the error text for a missing article.
Definition Article.php:1370
getUndoContent(Revision $undo, Revision $undoafter=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2581
__set( $fname, $fvalue)
Use PHP's magic __set handler to handle setting of raw WikiPage fields for backwards compatibility.
Definition Article.php:2299
getId()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2501
unprotect()
action=unprotect handler (alias)
Definition Article.php:1784
int $mRevIdFetched
Revision ID of revision that was loaded.
Definition Article.php:90
applyContentOverride(Content $override)
Applies a content override by constructing a fake Revision object and assigning it to mRevision.
Definition Article.php:541
isRedirect()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2657
ParserOptions null $mParserOptions
ParserOptions object for $wgUser articles.
Definition Article.php:52
newPage(Title $title)
Definition Article.php:139
makeFetchErrorContent()
Returns a Content object representing any error in $this->fetchContent, or null if there is no such e...
Definition Article.php:521
confirmDelete( $reason)
Output deletion confirmation dialog.
Definition Article.php:1922
getPage()
Get the WikiPage object of this instance.
Definition Article.php:231
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition Article.php:1748
getTouched()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2573
getRevision()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2557
string bool $mRedirectUrl
URL to redirect to or false if none.
Definition Article.php:83
getTimestamp()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2565
static newFromID( $id)
Constructor from a page id.
Definition Article.php:148
getRedirectTarget()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2541
int null $mOldId
The oldid of the article that was requested to be shown, 0 for the current revision.
Definition Article.php:77
static formatRobotPolicy( $policy)
Converts a String robot policy into an associative array, to allow merging of several policies using ...
Definition Article.php:1047
fetchRevisionRecord()
Fetches the revision to work on.
Definition Article.php:431
viewRedirect( $target, $appendSubtitle=true, $forceKnown=false)
Return the HTML for the top of a redirect page.
Definition Article.php:1691
insertRedirectEntry(Title $rt, $oldLatest=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2641
triggerOpportunisticLinksUpdate(ParserOutput $parserOutput)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2791
makeParserOptions( $context)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2689
showPatrolFooter()
If patrol is possible, output a patrol UI box.
Definition Article.php:1188
setOldSubtitle( $oldid=0)
Generate the navigation links when browsing through an article revisions It shows the information as:...
Definition Article.php:1550
showViewFooter()
Show the footer section of an ordinary page view.
Definition Article.php:1165
Status null $fetchResult
represents the outcome of fetchRevisionRecord().
Definition Article.php:100
loadFromRow( $data, $from)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2665
setRedirectedFrom(Title $from)
Tell the page view functions that this view was redirected from another page on the wiki.
Definition Article.php:212
isFileCacheable( $mode=HTMLFileCache::MODE_NORMAL)
Check if the page can be cached.
Definition Article.php:2182
doDeleteArticle( $reason, $suppress=false, $u1=null, $u2=null, &$error='', $immediate=false)
Definition Article.php:2875
getCreator( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2477
tryFileCache()
checkLastModified returns true if it has taken care of all output to the client that is necessary for...
Definition Article.php:2151
getRevIdFetched()
Use this to fetch the rev ID used on page views.
Definition Article.php:591
replaceSectionContent( $sectionId, Content $sectionContent, $sectionTitle='', $edittime=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2755
getUser( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2589
showNamespaceHeader()
Show a header specific to the namespace currently being viewed, like [[MediaWiki:Talkpagetext]].
Definition Article.php:1153
__get( $fname)
Use PHP's magic __get handler to handle accessing of raw WikiPage fields for backwards compatibility.
Definition Article.php:2284
getRevisionRedirectTarget(RevisionRecord $revision)
Definition Article.php:890
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition Article.php:160
hasViewableContent()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2605
getContentObject()
Returns a Content object representing the pages effective display content, not necessarily the revisi...
Definition Article.php:270
showDiffPage()
Show a diff page according to current request variables.
Definition Article.php:917
getMinorEdit()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2525
setParserOptions(ParserOptions $options)
Override the ParserOptions used to render the primary article wikitext.
Definition Article.php:2230
getEmptyPageParserOutput(ParserOptions $options)
Returns ParserOutput to use when a page does not exist.
Definition Article.php:313
render()
Handle action=render.
Definition Article.php:1765
showRedirectedFromHeader()
If this request is a redirect view, send "redirected from" subtitle to the output.
Definition Article.php:1076
exists()
Call to WikiPage function for backwards compatibility.
Definition Article.php:2405
setContext( $context)
Sets the context this Article is executed in.
Definition Article.php:2257
getRedirectURL( $rt)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2549
bool $mContentLoaded
Is the target revision loaded? Set by fetchRevisionRecord().
Definition Article.php:70
getDeletionUpdates(Content $content=null)
Call to WikiPage function for backwards compatibility.
Definition Article.php:2485
doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user=null)
Definition Article.php:2891
Content null $mContentObject
Content of the main slot of $this->mRevision.
Definition Article.php:62
const POST_EDIT_COOKIE_KEY_PREFIX
Prefix of key for cookie used to pass post-edit state.
Definition EditPage.php:203
Page view caching in the file system.
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
Internationalisation code.
Definition Language.php:37
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition Linker.php:85
static getRevDeleteLink(User $user, Revision $rev, LinkTarget $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
Definition Linker.php:2110
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:141
static revComment(Revision $rev, $local=false, $isPublic=false, $useParentheses=true)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
Definition Linker.php:1577
static revUserTools( $rev, $isPublic=false, $useParentheses=true)
Generate a user tool link cluster if the current user is allowed to view it.
Definition Linker.php:1124
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
Definition Linker.php:848
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Class to simplify the use of log pages.
Definition LogPage.php:33
MediaWiki exception.
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may...
MediaWikiServices is the service locator for the application scope of MediaWiki.
Page revision base class.
getContent( $role, $audience=self::FOR_PUBLIC, User $user=null)
Returns the Content of the given slot of this revision.
Value object representing a content slot associated with a page revision.
Wrapper allowing us to handle a system message as a Content object.
static numParam( $num)
Definition Message.php:1038
Set options of the Parser.
Show an error when a user tries to do something they do not have the necessary permissions for.
Handles the page protection UI and backend.
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition Revision.php:119
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:40
Represents a title within MediaWiki.
Definition Title.php:42
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:51
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:518
static isIP( $name)
Does the string match an anonymous IP address?
Definition User.php:933
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
Class representing a MediaWiki article and history.
Definition WikiPage.php:47
getTitle()
Get the title object of the article.
Definition WikiPage.php:298
const NS_USER
Definition Defines.php:71
const NS_FILE
Definition Defines.php:75
const NS_MEDIAWIKI
Definition Defines.php:77
const RC_LOG
Definition Defines.php:133
const NS_MEDIA
Definition Defines.php:57
const NS_USER_TALK
Definition Defines.php:72
const NS_CATEGORY
Definition Defines.php:83
Base interface for content objects.
Definition Content.php:34
Interface for objects which can provide a MediaWiki context on request.
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
Definition Page.php:29
$context
Definition load.php:45
$cache
Definition mcc.php:33
const DB_REPLICA
Definition defines.php:25
$content
Definition router.php:78
if(!isset( $args[0])) $lang