MediaWiki  1.29.2
Article.php
Go to the documentation of this file.
1 <?php
23 
35 class Article implements Page {
37  protected $mContext;
38 
40  protected $mPage;
41 
44 
49  public $mContent;
50 
56 
58  public $mContentLoaded = false;
59 
61  public $mOldId;
62 
64  public $mRedirectedFrom = null;
65 
67  public $mRedirectUrl = false;
68 
70  public $mRevIdFetched = 0;
71 
73  public $mRevision = null;
74 
77 
83  public function __construct( Title $title, $oldId = null ) {
84  $this->mOldId = $oldId;
85  $this->mPage = $this->newPage( $title );
86  }
87 
92  protected function newPage( Title $title ) {
93  return new WikiPage( $title );
94  }
95 
101  public static function newFromID( $id ) {
102  $t = Title::newFromID( $id );
103  return $t == null ? null : new static( $t );
104  }
105 
113  public static function newFromTitle( $title, IContextSource $context ) {
114  if ( NS_MEDIA == $title->getNamespace() ) {
115  // FIXME: where should this go?
116  $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
117  }
118 
119  $page = null;
120  Hooks::run( 'ArticleFromTitle', [ &$title, &$page, $context ] );
121  if ( !$page ) {
122  switch ( $title->getNamespace() ) {
123  case NS_FILE:
124  $page = new ImagePage( $title );
125  break;
126  case NS_CATEGORY:
127  $page = new CategoryPage( $title );
128  break;
129  default:
130  $page = new Article( $title );
131  }
132  }
133  $page->setContext( $context );
134 
135  return $page;
136  }
137 
145  public static function newFromWikiPage( WikiPage $page, IContextSource $context ) {
146  $article = self::newFromTitle( $page->getTitle(), $context );
147  $article->mPage = $page; // override to keep process cached vars
148  return $article;
149  }
150 
156  public function getRedirectedFrom() {
157  return $this->mRedirectedFrom;
158  }
159 
165  public function setRedirectedFrom( Title $from ) {
166  $this->mRedirectedFrom = $from;
167  }
168 
174  public function getTitle() {
175  return $this->mPage->getTitle();
176  }
177 
184  public function getPage() {
185  return $this->mPage;
186  }
187 
191  public function clear() {
192  $this->mContentLoaded = false;
193 
194  $this->mRedirectedFrom = null; # Title object if set
195  $this->mRevIdFetched = 0;
196  $this->mRedirectUrl = false;
197 
198  $this->mPage->clear();
199  }
200 
216  protected function getContentObject() {
217 
218  if ( $this->mPage->getId() === 0 ) {
219  # If this is a MediaWiki:x message, then load the messages
220  # and return the message value for x.
221  if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) {
222  $text = $this->getTitle()->getDefaultMessageText();
223  if ( $text === false ) {
224  $text = '';
225  }
226 
227  $content = ContentHandler::makeContent( $text, $this->getTitle() );
228  } else {
229  $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
230  $content = new MessageContent( $message, null, 'parsemag' );
231  }
232  } else {
233  $this->fetchContentObject();
235  }
236 
237  return $content;
238  }
239 
243  public function getOldID() {
244  if ( is_null( $this->mOldId ) ) {
245  $this->mOldId = $this->getOldIDFromRequest();
246  }
247 
248  return $this->mOldId;
249  }
250 
256  public function getOldIDFromRequest() {
257  $this->mRedirectUrl = false;
258 
259  $request = $this->getContext()->getRequest();
260  $oldid = $request->getIntOrNull( 'oldid' );
261 
262  if ( $oldid === null ) {
263  return 0;
264  }
265 
266  if ( $oldid !== 0 ) {
267  # Load the given revision and check whether the page is another one.
268  # In that case, update this instance to reflect the change.
269  if ( $oldid === $this->mPage->getLatest() ) {
270  $this->mRevision = $this->mPage->getRevision();
271  } else {
272  $this->mRevision = Revision::newFromId( $oldid );
273  if ( $this->mRevision !== null ) {
274  // Revision title doesn't match the page title given?
275  if ( $this->mPage->getId() != $this->mRevision->getPage() ) {
276  $function = [ get_class( $this->mPage ), 'newFromID' ];
277  $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
278  }
279  }
280  }
281  }
282 
283  if ( $request->getVal( 'direction' ) == 'next' ) {
284  $nextid = $this->getTitle()->getNextRevisionID( $oldid );
285  if ( $nextid ) {
286  $oldid = $nextid;
287  $this->mRevision = null;
288  } else {
289  $this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
290  }
291  } elseif ( $request->getVal( 'direction' ) == 'prev' ) {
292  $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
293  if ( $previd ) {
294  $oldid = $previd;
295  $this->mRevision = null;
296  }
297  }
298 
299  return $oldid;
300  }
301 
314  protected function fetchContentObject() {
315  if ( $this->mContentLoaded ) {
316  return $this->mContentObject;
317  }
318 
319  $this->mContentLoaded = true;
320  $this->mContent = null;
321 
322  $oldid = $this->getOldID();
323 
324  # Pre-fill content with error message so that if something
325  # fails we'll have something telling us what we intended.
326  // XXX: this isn't page content but a UI message. horrible.
327  $this->mContentObject = new MessageContent( 'missing-revision', [ $oldid ] );
328 
329  if ( $oldid ) {
330  # $this->mRevision might already be fetched by getOldIDFromRequest()
331  if ( !$this->mRevision ) {
332  $this->mRevision = Revision::newFromId( $oldid );
333  if ( !$this->mRevision ) {
334  wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" );
335  return false;
336  }
337  }
338  } else {
339  $oldid = $this->mPage->getLatest();
340  if ( !$oldid ) {
341  wfDebug( __METHOD__ . " failed to find page data for title " .
342  $this->getTitle()->getPrefixedText() . "\n" );
343  return false;
344  }
345 
346  # Update error message with correct oldid
347  $this->mContentObject = new MessageContent( 'missing-revision', [ $oldid ] );
348 
349  $this->mRevision = $this->mPage->getRevision();
350 
351  if ( !$this->mRevision ) {
352  wfDebug( __METHOD__ . " failed to retrieve current page, rev_id $oldid\n" );
353  return false;
354  }
355  }
356 
357  // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
358  // We should instead work with the Revision object when we need it...
359  // Loads if user is allowed
360  $content = $this->mRevision->getContent(
362  $this->getContext()->getUser()
363  );
364 
365  if ( !$content ) {
366  wfDebug( __METHOD__ . " failed to retrieve content of revision " .
367  $this->mRevision->getId() . "\n" );
368  return false;
369  }
370 
371  $this->mContentObject = $content;
372  $this->mRevIdFetched = $this->mRevision->getId();
373 
374  // Avoid PHP 7.1 warning of passing $this by reference
375  $articlePage = $this;
376 
377  Hooks::run(
378  'ArticleAfterFetchContentObject',
379  [ &$articlePage, &$this->mContentObject ]
380  );
381 
382  return $this->mContentObject;
383  }
384 
390  public function isCurrent() {
391  # If no oldid, this is the current version.
392  if ( $this->getOldID() == 0 ) {
393  return true;
394  }
395 
396  return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent();
397  }
398 
406  public function getRevisionFetched() {
407  $this->fetchContentObject();
408 
409  return $this->mRevision;
410  }
411 
417  public function getRevIdFetched() {
418  if ( $this->mRevIdFetched ) {
419  return $this->mRevIdFetched;
420  } else {
421  return $this->mPage->getLatest();
422  }
423  }
424 
429  public function view() {
430  global $wgUseFileCache, $wgDebugToolbar;
431 
432  # Get variables from query string
433  # As side effect this will load the revision and update the title
434  # in a revision ID is passed in the request, so this should remain
435  # the first call of this method even if $oldid is used way below.
436  $oldid = $this->getOldID();
437 
438  $user = $this->getContext()->getUser();
439  # Another whitelist check in case getOldID() is altering the title
440  $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
441  if ( count( $permErrors ) ) {
442  wfDebug( __METHOD__ . ": denied on secondary read check\n" );
443  throw new PermissionsError( 'read', $permErrors );
444  }
445 
446  $outputPage = $this->getContext()->getOutput();
447  # getOldID() may as well want us to redirect somewhere else
448  if ( $this->mRedirectUrl ) {
449  $outputPage->redirect( $this->mRedirectUrl );
450  wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
451 
452  return;
453  }
454 
455  # If we got diff in the query, we want to see a diff page instead of the article.
456  if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
457  wfDebug( __METHOD__ . ": showing diff page\n" );
458  $this->showDiffPage();
459 
460  return;
461  }
462 
463  # Set page title (may be overridden by DISPLAYTITLE)
464  $outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
465 
466  $outputPage->setArticleFlag( true );
467  # Allow frames by default
468  $outputPage->allowClickjacking();
469 
470  $parserCache = ParserCache::singleton();
471 
472  $parserOptions = $this->getParserOptions();
473  # Render printable version, use printable version cache
474  if ( $outputPage->isPrintable() ) {
475  $parserOptions->setIsPrintable( true );
476  $parserOptions->setEditSection( false );
477  } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user ) ) {
478  $parserOptions->setEditSection( false );
479  }
480 
481  # Try client and file cache
482  if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) {
483  # Try to stream the output from file cache
484  if ( $wgUseFileCache && $this->tryFileCache() ) {
485  wfDebug( __METHOD__ . ": done file cache\n" );
486  # tell wgOut that output is taken care of
487  $outputPage->disable();
488  $this->mPage->doViewUpdates( $user, $oldid );
489 
490  return;
491  }
492  }
493 
494  # Should the parser cache be used?
495  $useParserCache = $this->mPage->shouldCheckParserCache( $parserOptions, $oldid );
496  wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
497  if ( $user->getStubThreshold() ) {
498  MediaWikiServices::getInstance()->getStatsdDataFactory()->increment( 'pcache_miss_stub' );
499  }
500 
501  $this->showRedirectedFromHeader();
502  $this->showNamespaceHeader();
503 
504  # Iterate through the possible ways of constructing the output text.
505  # Keep going until $outputDone is set, or we run out of things to do.
506  $pass = 0;
507  $outputDone = false;
508  $this->mParserOutput = false;
509 
510  while ( !$outputDone && ++$pass ) {
511  switch ( $pass ) {
512  case 1:
513  // Avoid PHP 7.1 warning of passing $this by reference
514  $articlePage = $this;
515  Hooks::run( 'ArticleViewHeader', [ &$articlePage, &$outputDone, &$useParserCache ] );
516  break;
517  case 2:
518  # Early abort if the page doesn't exist
519  if ( !$this->mPage->exists() ) {
520  wfDebug( __METHOD__ . ": showing missing article\n" );
521  $this->showMissingArticle();
522  $this->mPage->doViewUpdates( $user );
523  return;
524  }
525 
526  # Try the parser cache
527  if ( $useParserCache ) {
528  $this->mParserOutput = $parserCache->get( $this->mPage, $parserOptions );
529 
530  if ( $this->mParserOutput !== false ) {
531  if ( $oldid ) {
532  wfDebug( __METHOD__ . ": showing parser cache contents for current rev permalink\n" );
533  $this->setOldSubtitle( $oldid );
534  } else {
535  wfDebug( __METHOD__ . ": showing parser cache contents\n" );
536  }
537  $outputPage->addParserOutput( $this->mParserOutput );
538  # Ensure that UI elements requiring revision ID have
539  # the correct version information.
540  $outputPage->setRevisionId( $this->mPage->getLatest() );
541  # Preload timestamp to avoid a DB hit
542  $cachedTimestamp = $this->mParserOutput->getTimestamp();
543  if ( $cachedTimestamp !== null ) {
544  $outputPage->setRevisionTimestamp( $cachedTimestamp );
545  $this->mPage->setTimestamp( $cachedTimestamp );
546  }
547  $outputDone = true;
548  }
549  }
550  break;
551  case 3:
552  # This will set $this->mRevision if needed
553  $this->fetchContentObject();
554 
555  # Are we looking at an old revision
556  if ( $oldid && $this->mRevision ) {
557  $this->setOldSubtitle( $oldid );
558 
559  if ( !$this->showDeletedRevisionHeader() ) {
560  wfDebug( __METHOD__ . ": cannot view deleted revision\n" );
561  return;
562  }
563  }
564 
565  # Ensure that UI elements requiring revision ID have
566  # the correct version information.
567  $outputPage->setRevisionId( $this->getRevIdFetched() );
568  # Preload timestamp to avoid a DB hit
569  $outputPage->setRevisionTimestamp( $this->mPage->getTimestamp() );
570 
571  if ( !Hooks::run( 'ArticleContentViewCustom',
572  [ $this->fetchContentObject(), $this->getTitle(), $outputPage ] ) ) {
573 
574  # Allow extensions do their own custom view for certain pages
575  $outputDone = true;
576  }
577  break;
578  case 4:
579  # Run the parse, protected by a pool counter
580  wfDebug( __METHOD__ . ": doing uncached parse\n" );
581 
582  $content = $this->getContentObject();
583  $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
584  $this->getRevIdFetched(), $useParserCache, $content );
585 
586  if ( !$poolArticleView->execute() ) {
587  $error = $poolArticleView->getError();
588  if ( $error ) {
589  $outputPage->clearHTML(); // for release() errors
590  $outputPage->enableClientCache( false );
591  $outputPage->setRobotPolicy( 'noindex,nofollow' );
592 
593  $errortext = $error->getWikiText( false, 'view-pool-error' );
594  $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
595  }
596  # Connection or timeout error
597  return;
598  }
599 
600  $this->mParserOutput = $poolArticleView->getParserOutput();
601  $outputPage->addParserOutput( $this->mParserOutput );
602  if ( $content->getRedirectTarget() ) {
603  $outputPage->addSubtitle( "<span id=\"redirectsub\">" .
604  $this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
605  }
606 
607  # Don't cache a dirty ParserOutput object
608  if ( $poolArticleView->getIsDirty() ) {
609  $outputPage->setCdnMaxage( 0 );
610  $outputPage->addHTML( "<!-- parser cache is expired, " .
611  "sending anyway due to pool overload-->\n" );
612  }
613 
614  $outputDone = true;
615  break;
616  # Should be unreachable, but just in case...
617  default:
618  break 2;
619  }
620  }
621 
622  # Get the ParserOutput actually *displayed* here.
623  # Note that $this->mParserOutput is the *current*/oldid version output.
624  $pOutput = ( $outputDone instanceof ParserOutput )
625  ? $outputDone // object fetched by hook
626  : $this->mParserOutput;
627 
628  # Adjust title for main page & pages with displaytitle
629  if ( $pOutput ) {
630  $this->adjustDisplayTitle( $pOutput );
631  }
632 
633  # For the main page, overwrite the <title> element with the con-
634  # tents of 'pagetitle-view-mainpage' instead of the default (if
635  # that's not empty).
636  # This message always exists because it is in the i18n files
637  if ( $this->getTitle()->isMainPage() ) {
638  $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
639  if ( !$msg->isDisabled() ) {
640  $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
641  }
642  }
643 
644  # Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
645  # This could use getTouched(), but that could be scary for major template edits.
646  $outputPage->adaptCdnTTL( $this->mPage->getTimestamp(), IExpiringStore::TTL_DAY );
647 
648  # Check for any __NOINDEX__ tags on the page using $pOutput
649  $policy = $this->getRobotPolicy( 'view', $pOutput );
650  $outputPage->setIndexPolicy( $policy['index'] );
651  $outputPage->setFollowPolicy( $policy['follow'] );
652 
653  $this->showViewFooter();
654  $this->mPage->doViewUpdates( $user, $oldid );
655 
656  $outputPage->addModules( 'mediawiki.action.view.postEdit' );
657  }
658 
663  public function adjustDisplayTitle( ParserOutput $pOutput ) {
664  # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
665  $titleText = $pOutput->getTitleText();
666  if ( strval( $titleText ) !== '' ) {
667  $this->getContext()->getOutput()->setPageTitle( $titleText );
668  }
669  }
670 
675  protected function showDiffPage() {
676  $request = $this->getContext()->getRequest();
677  $user = $this->getContext()->getUser();
678  $diff = $request->getVal( 'diff' );
679  $rcid = $request->getVal( 'rcid' );
680  $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
681  $purge = $request->getVal( 'action' ) == 'purge';
682  $unhide = $request->getInt( 'unhide' ) == 1;
683  $oldid = $this->getOldID();
684 
685  $rev = $this->getRevisionFetched();
686 
687  if ( !$rev ) {
688  $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
689  $msg = $this->getContext()->msg( 'difference-missing-revision' )
690  ->params( $oldid )
691  ->numParams( 1 )
692  ->parseAsBlock();
693  $this->getContext()->getOutput()->addHTML( $msg );
694  return;
695  }
696 
697  $contentHandler = $rev->getContentHandler();
698  $de = $contentHandler->createDifferenceEngine(
699  $this->getContext(),
700  $oldid,
701  $diff,
702  $rcid,
703  $purge,
704  $unhide
705  );
706 
707  // DifferenceEngine directly fetched the revision:
708  $this->mRevIdFetched = $de->mNewid;
709  $de->showDiffPage( $diffOnly );
710 
711  // Run view updates for the newer revision being diffed (and shown
712  // below the diff if not $diffOnly).
713  list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
714  // New can be false, convert it to 0 - this conveniently means the latest revision
715  $this->mPage->doViewUpdates( $user, (int)$new );
716  }
717 
725  public function getRobotPolicy( $action, $pOutput = null ) {
726  global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
727 
728  $ns = $this->getTitle()->getNamespace();
729 
730  # Don't index user and user talk pages for blocked users (T13443)
731  if ( ( $ns == NS_USER || $ns == NS_USER_TALK ) && !$this->getTitle()->isSubpage() ) {
732  $specificTarget = null;
733  $vagueTarget = null;
734  $titleText = $this->getTitle()->getText();
735  if ( IP::isValid( $titleText ) ) {
736  $vagueTarget = $titleText;
737  } else {
738  $specificTarget = $titleText;
739  }
740  if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) {
741  return [
742  'index' => 'noindex',
743  'follow' => 'nofollow'
744  ];
745  }
746  }
747 
748  if ( $this->mPage->getId() === 0 || $this->getOldID() ) {
749  # Non-articles (special pages etc), and old revisions
750  return [
751  'index' => 'noindex',
752  'follow' => 'nofollow'
753  ];
754  } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
755  # Discourage indexing of printable versions, but encourage following
756  return [
757  'index' => 'noindex',
758  'follow' => 'follow'
759  ];
760  } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
761  # For ?curid=x urls, disallow indexing
762  return [
763  'index' => 'noindex',
764  'follow' => 'follow'
765  ];
766  }
767 
768  # Otherwise, construct the policy based on the various config variables.
769  $policy = self::formatRobotPolicy( $wgDefaultRobotPolicy );
770 
771  if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
772  # Honour customised robot policies for this namespace
773  $policy = array_merge(
774  $policy,
775  self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
776  );
777  }
778  if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
779  # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
780  # a final sanity check that we have really got the parser output.
781  $policy = array_merge(
782  $policy,
783  [ 'index' => $pOutput->getIndexPolicy() ]
784  );
785  }
786 
787  if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
788  # (T16900) site config can override user-defined __INDEX__ or __NOINDEX__
789  $policy = array_merge(
790  $policy,
791  self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
792  );
793  }
794 
795  return $policy;
796  }
797 
805  public static function formatRobotPolicy( $policy ) {
806  if ( is_array( $policy ) ) {
807  return $policy;
808  } elseif ( !$policy ) {
809  return [];
810  }
811 
812  $policy = explode( ',', $policy );
813  $policy = array_map( 'trim', $policy );
814 
815  $arr = [];
816  foreach ( $policy as $var ) {
817  if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
818  $arr['index'] = $var;
819  } elseif ( in_array( $var, [ 'follow', 'nofollow' ] ) ) {
820  $arr['follow'] = $var;
821  }
822  }
823 
824  return $arr;
825  }
826 
834  public function showRedirectedFromHeader() {
835  global $wgRedirectSources;
836 
837  $context = $this->getContext();
838  $outputPage = $context->getOutput();
840  $rdfrom = $request->getVal( 'rdfrom' );
841 
842  // Construct a URL for the current page view, but with the target title
843  $query = $request->getValues();
844  unset( $query['rdfrom'] );
845  unset( $query['title'] );
846  if ( $this->getTitle()->isRedirect() ) {
847  // Prevent double redirects
848  $query['redirect'] = 'no';
849  }
850  $redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
851 
852  if ( isset( $this->mRedirectedFrom ) ) {
853  // Avoid PHP 7.1 warning of passing $this by reference
854  $articlePage = $this;
855 
856  // This is an internally redirected page view.
857  // We'll need a backlink to the source page for navigation.
858  if ( Hooks::run( 'ArticleViewRedirect', [ &$articlePage ] ) ) {
859  $redir = Linker::linkKnown(
860  $this->mRedirectedFrom,
861  null,
862  [],
863  [ 'redirect' => 'no' ]
864  );
865 
866  $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
867  $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
868  . "</span>" );
869 
870  // Add the script to update the displayed URL and
871  // set the fragment if one was specified in the redirect
872  $outputPage->addJsConfigVars( [
873  'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
874  ] );
875  $outputPage->addModules( 'mediawiki.action.view.redirect' );
876 
877  // Add a <link rel="canonical"> tag
878  $outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
879 
880  // Tell the output object that the user arrived at this article through a redirect
881  $outputPage->setRedirectedFrom( $this->mRedirectedFrom );
882 
883  return true;
884  }
885  } elseif ( $rdfrom ) {
886  // This is an externally redirected view, from some other wiki.
887  // If it was reported from a trusted site, supply a backlink.
888  if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
889  $redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
890  $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
891  $context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
892  . "</span>" );
893 
894  // Add the script to update the displayed URL
895  $outputPage->addJsConfigVars( [
896  'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
897  ] );
898  $outputPage->addModules( 'mediawiki.action.view.redirect' );
899 
900  return true;
901  }
902  }
903 
904  return false;
905  }
906 
911  public function showNamespaceHeader() {
912  if ( $this->getTitle()->isTalkPage() ) {
913  if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
914  $this->getContext()->getOutput()->wrapWikiMsg(
915  "<div class=\"mw-talkpageheader\">\n$1\n</div>",
916  [ 'talkpageheader' ]
917  );
918  }
919  }
920  }
921 
925  public function showViewFooter() {
926  # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
927  if ( $this->getTitle()->getNamespace() == NS_USER_TALK
928  && IP::isValid( $this->getTitle()->getText() )
929  ) {
930  $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
931  }
932 
933  // Show a footer allowing the user to patrol the shown revision or page if possible
934  $patrolFooterShown = $this->showPatrolFooter();
935 
936  Hooks::run( 'ArticleViewFooter', [ $this, $patrolFooterShown ] );
937  }
938 
948  public function showPatrolFooter() {
949  global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol, $wgEnableAPI, $wgEnableWriteAPI;
950 
951  $outputPage = $this->getContext()->getOutput();
952  $user = $this->getContext()->getUser();
953  $title = $this->getTitle();
954  $rc = false;
955 
956  if ( !$title->quickUserCan( 'patrol', $user )
957  || !( $wgUseRCPatrol || $wgUseNPPatrol
958  || ( $wgUseFilePatrol && $title->inNamespace( NS_FILE ) ) )
959  ) {
960  // Patrolling is disabled or the user isn't allowed to
961  return false;
962  }
963 
964  if ( $this->mRevision
965  && !RecentChange::isInRCLifespan( $this->mRevision->getTimestamp(), 21600 )
966  ) {
967  // The current revision is already older than what could be in the RC table
968  // 6h tolerance because the RC might not be cleaned out regularly
969  return false;
970  }
971 
972  // Check for cached results
973  $key = wfMemcKey( 'unpatrollable-page', $title->getArticleID() );
975  if ( $cache->get( $key ) ) {
976  return false;
977  }
978 
979  $dbr = wfGetDB( DB_REPLICA );
980  $oldestRevisionTimestamp = $dbr->selectField(
981  'revision',
982  'MIN( rev_timestamp )',
983  [ 'rev_page' => $title->getArticleID() ],
984  __METHOD__
985  );
986 
987  // New page patrol: Get the timestamp of the oldest revison which
988  // the revision table holds for the given page. Then we look
989  // whether it's within the RC lifespan and if it is, we try
990  // to get the recentchanges row belonging to that entry
991  // (with rc_new = 1).
992  $recentPageCreation = false;
993  if ( $oldestRevisionTimestamp
994  && RecentChange::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
995  ) {
996  // 6h tolerance because the RC might not be cleaned out regularly
997  $recentPageCreation = true;
999  [
1000  'rc_new' => 1,
1001  'rc_timestamp' => $oldestRevisionTimestamp,
1002  'rc_namespace' => $title->getNamespace(),
1003  'rc_cur_id' => $title->getArticleID()
1004  ],
1005  __METHOD__
1006  );
1007  if ( $rc ) {
1008  // Use generic patrol message for new pages
1009  $markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
1010  }
1011  }
1012 
1013  // File patrol: Get the timestamp of the latest upload for this page,
1014  // check whether it is within the RC lifespan and if it is, we try
1015  // to get the recentchanges row belonging to that entry
1016  // (with rc_type = RC_LOG, rc_log_type = upload).
1017  $recentFileUpload = false;
1018  if ( ( !$rc || $rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
1019  && $title->getNamespace() === NS_FILE ) {
1020  // Retrieve timestamp of most recent upload
1021  $newestUploadTimestamp = $dbr->selectField(
1022  'image',
1023  'MAX( img_timestamp )',
1024  [ 'img_name' => $title->getDBkey() ],
1025  __METHOD__
1026  );
1027  if ( $newestUploadTimestamp
1028  && RecentChange::isInRCLifespan( $newestUploadTimestamp, 21600 )
1029  ) {
1030  // 6h tolerance because the RC might not be cleaned out regularly
1031  $recentFileUpload = true;
1033  [
1034  'rc_type' => RC_LOG,
1035  'rc_log_type' => 'upload',
1036  'rc_timestamp' => $newestUploadTimestamp,
1037  'rc_namespace' => NS_FILE,
1038  'rc_cur_id' => $title->getArticleID()
1039  ],
1040  __METHOD__,
1041  [ 'USE INDEX' => 'rc_timestamp' ]
1042  );
1043  if ( $rc ) {
1044  // Use patrol message specific to files
1045  $markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
1046  }
1047  }
1048  }
1049 
1050  if ( !$recentPageCreation && !$recentFileUpload ) {
1051  // Page creation and latest upload (for files) is too old to be in RC
1052 
1053  // We definitely can't patrol so cache the information
1054  // When a new file version is uploaded, the cache is cleared
1055  $cache->set( $key, '1' );
1056 
1057  return false;
1058  }
1059 
1060  if ( !$rc ) {
1061  // Don't cache: This can be hit if the page gets accessed very fast after
1062  // its creation / latest upload or in case we have high replica DB lag. In case
1063  // the revision is too old, we will already return above.
1064  return false;
1065  }
1066 
1067  if ( $rc->getAttribute( 'rc_patrolled' ) ) {
1068  // Patrolled RC entry around
1069 
1070  // Cache the information we gathered above in case we can't patrol
1071  // Don't cache in case we can patrol as this could change
1072  $cache->set( $key, '1' );
1073 
1074  return false;
1075  }
1076 
1077  if ( $rc->getPerformer()->equals( $user ) ) {
1078  // Don't show a patrol link for own creations/uploads. If the user could
1079  // patrol them, they already would be patrolled
1080  return false;
1081  }
1082 
1083  $outputPage->preventClickjacking();
1084  if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
1085  $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1086  }
1087 
1089  $title,
1090  $markPatrolledMsg->escaped(),
1091  [],
1092  [
1093  'action' => 'markpatrolled',
1094  'rcid' => $rc->getAttribute( 'rc_id' ),
1095  ]
1096  );
1097 
1098  $outputPage->addHTML(
1099  "<div class='patrollink' data-mw='interface'>" .
1100  wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1101  '</div>'
1102  );
1103 
1104  return true;
1105  }
1106 
1113  public static function purgePatrolFooterCache( $articleID ) {
1115  $cache->delete( wfMemcKey( 'unpatrollable-page', $articleID ) );
1116  }
1117 
1122  public function showMissingArticle() {
1123  global $wgSend404Code;
1124 
1125  $outputPage = $this->getContext()->getOutput();
1126  // Whether the page is a root user page of an existing user (but not a subpage)
1127  $validUserPage = false;
1128 
1129  $title = $this->getTitle();
1130 
1131  # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1132  if ( $title->getNamespace() == NS_USER
1133  || $title->getNamespace() == NS_USER_TALK
1134  ) {
1135  $rootPart = explode( '/', $title->getText() )[0];
1136  $user = User::newFromName( $rootPart, false /* allow IP users */ );
1137  $ip = User::isIP( $rootPart );
1138  $block = Block::newFromTarget( $user, $user );
1139 
1140  if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
1141  $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1142  [ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
1143  } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
1144  # Show log extract if the user is currently blocked
1146  $outputPage,
1147  'block',
1148  MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
1149  '',
1150  [
1151  'lim' => 1,
1152  'showIfEmpty' => false,
1153  'msgKey' => [
1154  'blocked-notice-logextract',
1155  $user->getName() # Support GENDER in notice
1156  ]
1157  ]
1158  );
1159  $validUserPage = !$title->isSubpage();
1160  } else {
1161  $validUserPage = !$title->isSubpage();
1162  }
1163  }
1164 
1165  Hooks::run( 'ShowMissingArticle', [ $this ] );
1166 
1167  # Show delete and move logs if there were any such events.
1168  # The logging query can DOS the site when bots/crawlers cause 404 floods,
1169  # so be careful showing this. 404 pages must be cheap as they are hard to cache.
1171  $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
1172  $loggedIn = $this->getContext()->getUser()->isLoggedIn();
1173  if ( $loggedIn || $cache->get( $key ) ) {
1174  $logTypes = [ 'delete', 'move' ];
1175 
1176  $dbr = wfGetDB( DB_REPLICA );
1177 
1178  $conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
1179  // Give extensions a chance to hide their (unrelated) log entries
1180  Hooks::run( 'Article::MissingArticleConditions', [ &$conds, $logTypes ] );
1182  $outputPage,
1183  $logTypes,
1184  $title,
1185  '',
1186  [
1187  'lim' => 10,
1188  'conds' => $conds,
1189  'showIfEmpty' => false,
1190  'msgKey' => [ $loggedIn
1191  ? 'moveddeleted-notice'
1192  : 'moveddeleted-notice-recent'
1193  ]
1194  ]
1195  );
1196  }
1197 
1198  if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
1199  // If there's no backing content, send a 404 Not Found
1200  // for better machine handling of broken links.
1201  $this->getContext()->getRequest()->response()->statusHeader( 404 );
1202  }
1203 
1204  // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
1205  $policy = $this->getRobotPolicy( 'view' );
1206  $outputPage->setIndexPolicy( $policy['index'] );
1207  $outputPage->setFollowPolicy( $policy['follow'] );
1208 
1209  $hookResult = Hooks::run( 'BeforeDisplayNoArticleText', [ $this ] );
1210 
1211  if ( !$hookResult ) {
1212  return;
1213  }
1214 
1215  # Show error message
1216  $oldid = $this->getOldID();
1217  if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI && $title->hasSourceText() ) {
1218  $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
1219  } else {
1220  if ( $oldid ) {
1221  $text = wfMessage( 'missing-revision', $oldid )->plain();
1222  } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
1223  && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
1224  ) {
1225  $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
1226  $text = wfMessage( $message )->plain();
1227  } else {
1228  $text = wfMessage( 'noarticletext-nopermission' )->plain();
1229  }
1230 
1231  $dir = $this->getContext()->getLanguage()->getDir();
1232  $lang = $this->getContext()->getLanguage()->getCode();
1233  $outputPage->addWikiText( Xml::openElement( 'div', [
1234  'class' => "noarticletext mw-content-$dir",
1235  'dir' => $dir,
1236  'lang' => $lang,
1237  ] ) . "\n$text\n</div>" );
1238  }
1239  }
1240 
1247  public function showDeletedRevisionHeader() {
1248  if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
1249  // Not deleted
1250  return true;
1251  }
1252 
1253  $outputPage = $this->getContext()->getOutput();
1254  $user = $this->getContext()->getUser();
1255  // If the user is not allowed to see it...
1256  if ( !$this->mRevision->userCan( Revision::DELETED_TEXT, $user ) ) {
1257  $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1258  'rev-deleted-text-permission' );
1259 
1260  return false;
1261  // If the user needs to confirm that they want to see it...
1262  } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1263  # Give explanation and add a link to view the revision...
1264  $oldid = intval( $this->getOldID() );
1265  $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
1266  $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
1267  'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1268  $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1269  [ $msg, $link ] );
1270 
1271  return false;
1272  // We are allowed to see...
1273  } else {
1274  $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
1275  'rev-suppressed-text-view' : 'rev-deleted-text-view';
1276  $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1277 
1278  return true;
1279  }
1280  }
1281 
1290  public function setOldSubtitle( $oldid = 0 ) {
1291  // Avoid PHP 7.1 warning of passing $this by reference
1292  $articlePage = $this;
1293 
1294  if ( !Hooks::run( 'DisplayOldSubtitle', [ &$articlePage, &$oldid ] ) ) {
1295  return;
1296  }
1297 
1298  $context = $this->getContext();
1299  $unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
1300 
1301  # Cascade unhide param in links for easy deletion browsing
1302  $extraParams = [];
1303  if ( $unhide ) {
1304  $extraParams['unhide'] = 1;
1305  }
1306 
1307  if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
1308  $revision = $this->mRevision;
1309  } else {
1310  $revision = Revision::newFromId( $oldid );
1311  }
1312 
1313  $timestamp = $revision->getTimestamp();
1314 
1315  $current = ( $oldid == $this->mPage->getLatest() );
1316  $language = $context->getLanguage();
1317  $user = $context->getUser();
1318 
1319  $td = $language->userTimeAndDate( $timestamp, $user );
1320  $tddate = $language->userDate( $timestamp, $user );
1321  $tdtime = $language->userTime( $timestamp, $user );
1322 
1323  # Show user links if allowed to see them. If hidden, then show them only if requested...
1324  $userlinks = Linker::revUserTools( $revision, !$unhide );
1325 
1326  $infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
1327  ? 'revision-info-current'
1328  : 'revision-info';
1329 
1330  $outputPage = $context->getOutput();
1331  $revisionInfo = "<div id=\"mw-{$infomsg}\">" .
1332  $context->msg( $infomsg, $td )
1333  ->rawParams( $userlinks )
1334  ->params( $revision->getId(), $tddate, $tdtime, $revision->getUserText() )
1335  ->rawParams( Linker::revComment( $revision, true, true ) )
1336  ->parse() .
1337  "</div>";
1338 
1339  $lnk = $current
1340  ? $context->msg( 'currentrevisionlink' )->escaped()
1342  $this->getTitle(),
1343  $context->msg( 'currentrevisionlink' )->escaped(),
1344  [],
1345  $extraParams
1346  );
1347  $curdiff = $current
1348  ? $context->msg( 'diff' )->escaped()
1350  $this->getTitle(),
1351  $context->msg( 'diff' )->escaped(),
1352  [],
1353  [
1354  'diff' => 'cur',
1355  'oldid' => $oldid
1356  ] + $extraParams
1357  );
1358  $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
1359  $prevlink = $prev
1361  $this->getTitle(),
1362  $context->msg( 'previousrevision' )->escaped(),
1363  [],
1364  [
1365  'direction' => 'prev',
1366  'oldid' => $oldid
1367  ] + $extraParams
1368  )
1369  : $context->msg( 'previousrevision' )->escaped();
1370  $prevdiff = $prev
1372  $this->getTitle(),
1373  $context->msg( 'diff' )->escaped(),
1374  [],
1375  [
1376  'diff' => 'prev',
1377  'oldid' => $oldid
1378  ] + $extraParams
1379  )
1380  : $context->msg( 'diff' )->escaped();
1381  $nextlink = $current
1382  ? $context->msg( 'nextrevision' )->escaped()
1384  $this->getTitle(),
1385  $context->msg( 'nextrevision' )->escaped(),
1386  [],
1387  [
1388  'direction' => 'next',
1389  'oldid' => $oldid
1390  ] + $extraParams
1391  );
1392  $nextdiff = $current
1393  ? $context->msg( 'diff' )->escaped()
1395  $this->getTitle(),
1396  $context->msg( 'diff' )->escaped(),
1397  [],
1398  [
1399  'diff' => 'next',
1400  'oldid' => $oldid
1401  ] + $extraParams
1402  );
1403 
1404  $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
1405  if ( $cdel !== '' ) {
1406  $cdel .= ' ';
1407  }
1408 
1409  // the outer div is need for styling the revision info and nav in MobileFrontend
1410  $outputPage->addSubtitle( "<div class=\"mw-revision\">" . $revisionInfo .
1411  "<div id=\"mw-revision-nav\">" . $cdel .
1412  $context->msg( 'revision-nav' )->rawParams(
1413  $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1414  )->escaped() . "</div></div>" );
1415  }
1416 
1428  public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1429  $lang = $this->getTitle()->getPageLanguage();
1430  $out = $this->getContext()->getOutput();
1431  if ( $appendSubtitle ) {
1432  $out->addSubtitle( wfMessage( 'redirectpagesub' ) );
1433  }
1434  $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
1435  return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
1436  }
1437 
1450  public static function getRedirectHeaderHtml( Language $lang, $target, $forceKnown = false ) {
1451  if ( !is_array( $target ) ) {
1452  $target = [ $target ];
1453  }
1454 
1455  $html = '<ul class="redirectText">';
1457  foreach ( $target as $title ) {
1458  $html .= '<li>' . Linker::link(
1459  $title,
1460  htmlspecialchars( $title->getFullText() ),
1461  [],
1462  // Make sure wiki page redirects are not followed
1463  $title->isRedirect() ? [ 'redirect' => 'no' ] : [],
1464  ( $forceKnown ? [ 'known', 'noclasses' ] : [] )
1465  ) . '</li>';
1466  }
1467  $html .= '</ul>';
1468 
1469  $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
1470 
1471  return '<div class="redirectMsg">' .
1472  '<p>' . $redirectToText . '</p>' .
1473  $html .
1474  '</div>';
1475  }
1476 
1485  public function addHelpLink( $to, $overrideBaseUrl = false ) {
1486  $msg = wfMessage(
1487  'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
1488  );
1489 
1490  $out = $this->getContext()->getOutput();
1491  if ( !$msg->isDisabled() ) {
1492  $helpUrl = Skin::makeUrl( $msg->plain() );
1493  $out->addHelpLink( $helpUrl, true );
1494  } else {
1495  $out->addHelpLink( $to, $overrideBaseUrl );
1496  }
1497  }
1498 
1502  public function render() {
1503  $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
1504  $this->getContext()->getOutput()->setArticleBodyOnly( true );
1505  $this->getContext()->getOutput()->enableSectionEditLinks( false );
1506  $this->view();
1507  }
1508 
1512  public function protect() {
1513  $form = new ProtectionForm( $this );
1514  $form->execute();
1515  }
1516 
1520  public function unprotect() {
1521  $this->protect();
1522  }
1523 
1527  public function delete() {
1528  # This code desperately needs to be totally rewritten
1529 
1530  $title = $this->getTitle();
1531  $context = $this->getContext();
1532  $user = $context->getUser();
1534 
1535  # Check permissions
1536  $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
1537  if ( count( $permissionErrors ) ) {
1538  throw new PermissionsError( 'delete', $permissionErrors );
1539  }
1540 
1541  # Read-only check...
1542  if ( wfReadOnly() ) {
1543  throw new ReadOnlyError;
1544  }
1545 
1546  # Better double-check that it hasn't been deleted yet!
1547  $this->mPage->loadPageData(
1548  $request->wasPosted() ? WikiPage::READ_LATEST : WikiPage::READ_NORMAL
1549  );
1550  if ( !$this->mPage->exists() ) {
1551  $deleteLogPage = new LogPage( 'delete' );
1552  $outputPage = $context->getOutput();
1553  $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
1554  $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1555  [ 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) ]
1556  );
1557  $outputPage->addHTML(
1558  Xml::element( 'h2', null, $deleteLogPage->getName()->text() )
1559  );
1561  $outputPage,
1562  'delete',
1563  $title
1564  );
1565 
1566  return;
1567  }
1568 
1569  $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1570  $deleteReason = $request->getText( 'wpReason' );
1571 
1572  if ( $deleteReasonList == 'other' ) {
1573  $reason = $deleteReason;
1574  } elseif ( $deleteReason != '' ) {
1575  // Entry from drop down menu + additional comment
1576  $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1577  $reason = $deleteReasonList . $colonseparator . $deleteReason;
1578  } else {
1579  $reason = $deleteReasonList;
1580  }
1581 
1582  if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1583  [ 'delete', $this->getTitle()->getPrefixedText() ] )
1584  ) {
1585  # Flag to hide all contents of the archived revisions
1586  $suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1587 
1588  $this->doDelete( $reason, $suppress );
1589 
1590  WatchAction::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
1591 
1592  return;
1593  }
1594 
1595  // Generate deletion reason
1596  $hasHistory = false;
1597  if ( !$reason ) {
1598  try {
1599  $reason = $this->generateReason( $hasHistory );
1600  } catch ( Exception $e ) {
1601  # if a page is horribly broken, we still want to be able to
1602  # delete it. So be lenient about errors here.
1603  wfDebug( "Error while building auto delete summary: $e" );
1604  $reason = '';
1605  }
1606  }
1607 
1608  // If the page has a history, insert a warning
1609  if ( $hasHistory ) {
1610  $title = $this->getTitle();
1611 
1612  // The following can use the real revision count as this is only being shown for users
1613  // that can delete this page.
1614  // This, as a side-effect, also makes sure that the following query isn't being run for
1615  // pages with a larger history, unless the user has the 'bigdelete' right
1616  // (and is about to delete this page).
1617  $dbr = wfGetDB( DB_REPLICA );
1618  $revisions = $edits = (int)$dbr->selectField(
1619  'revision',
1620  'COUNT(rev_page)',
1621  [ 'rev_page' => $title->getArticleID() ],
1622  __METHOD__
1623  );
1624 
1625  // @todo FIXME: i18n issue/patchwork message
1626  $context->getOutput()->addHTML(
1627  '<strong class="mw-delete-warning-revisions">' .
1628  $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
1629  $context->msg( 'word-separator' )->escaped() . Linker::linkKnown( $title,
1630  $context->msg( 'history' )->escaped(),
1631  [],
1632  [ 'action' => 'history' ] ) .
1633  '</strong>'
1634  );
1635 
1636  if ( $title->isBigDeletion() ) {
1637  global $wgDeleteRevisionsLimit;
1638  $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1639  [
1640  'delete-warning-toobig',
1641  $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
1642  ]
1643  );
1644  }
1645  }
1646 
1647  $this->confirmDelete( $reason );
1648  }
1649 
1655  public function confirmDelete( $reason ) {
1656  wfDebug( "Article::confirmDelete\n" );
1657 
1658  $title = $this->getTitle();
1659  $ctx = $this->getContext();
1660  $outputPage = $ctx->getOutput();
1661  $useMediaWikiUIEverywhere = $ctx->getConfig()->get( 'UseMediaWikiUIEverywhere' );
1662  $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
1663  $outputPage->addBacklinkSubtitle( $title );
1664  $outputPage->setRobotPolicy( 'noindex,nofollow' );
1665  $backlinkCache = $title->getBacklinkCache();
1666  if ( $backlinkCache->hasLinks( 'pagelinks' ) || $backlinkCache->hasLinks( 'templatelinks' ) ) {
1667  $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1668  'deleting-backlinks-warning' );
1669  }
1670  $outputPage->addWikiMsg( 'confirmdeletetext' );
1671 
1672  Hooks::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
1673 
1674  $user = $this->getContext()->getUser();
1675  if ( $user->isAllowed( 'suppressrevision' ) ) {
1676  $suppress = Html::openElement( 'div', [ 'id' => 'wpDeleteSuppressRow' ] ) .
1677  Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
1678  'wpSuppress', 'wpSuppress', false, [ 'tabindex' => '4' ] ) .
1679  Html::closeElement( 'div' );
1680  } else {
1681  $suppress = '';
1682  }
1683  $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $title );
1684  $form = Html::openElement( 'form', [ 'method' => 'post',
1685  'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ] ) .
1686  Html::openElement( 'fieldset', [ 'id' => 'mw-delete-table' ] ) .
1687  Html::element( 'legend', null, wfMessage( 'delete-legend' )->text() ) .
1688  Html::openElement( 'div', [ 'id' => 'mw-deleteconfirm-table' ] ) .
1689  Html::openElement( 'div', [ 'id' => 'wpDeleteReasonListRow' ] ) .
1690  Html::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
1691  '&nbsp;' .
1693  'wpDeleteReasonList',
1694  wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
1695  wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(),
1696  '',
1697  'wpReasonDropDown',
1698  1
1699  ) .
1700  Html::closeElement( 'div' ) .
1701  Html::openElement( 'div', [ 'id' => 'wpDeleteReasonRow' ] ) .
1702  Html::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) .
1703  '&nbsp;' .
1704  Html::input( 'wpReason', $reason, 'text', [
1705  'size' => '60',
1706  'maxlength' => '255',
1707  'tabindex' => '2',
1708  'id' => 'wpReason',
1709  'class' => 'mw-ui-input-inline',
1710  'autofocus'
1711  ] ) .
1712  Html::closeElement( 'div' );
1713 
1714  # Disallow watching if user is not logged in
1715  if ( $user->isLoggedIn() ) {
1716  $form .=
1717  Xml::checkLabel( wfMessage( 'watchthis' )->text(),
1718  'wpWatch', 'wpWatch', $checkWatch, [ 'tabindex' => '3' ] );
1719  }
1720 
1721  $form .=
1722  Html::openElement( 'div' ) .
1723  $suppress .
1724  Xml::submitButton( wfMessage( 'deletepage' )->text(),
1725  [
1726  'name' => 'wpConfirmB',
1727  'id' => 'wpConfirmB',
1728  'tabindex' => '5',
1729  'class' => $useMediaWikiUIEverywhere ? 'mw-ui-button mw-ui-destructive' : '',
1730  ]
1731  ) .
1732  Html::closeElement( 'div' ) .
1733  Html::closeElement( 'div' ) .
1734  Xml::closeElement( 'fieldset' ) .
1735  Html::hidden(
1736  'wpEditToken',
1737  $user->getEditToken( [ 'delete', $title->getPrefixedText() ] )
1738  ) .
1739  Xml::closeElement( 'form' );
1740 
1741  if ( $user->isAllowed( 'editinterface' ) ) {
1743  $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
1744  wfMessage( 'delete-edit-reasonlist' )->escaped(),
1745  [],
1746  [ 'action' => 'edit' ]
1747  );
1748  $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
1749  }
1750 
1751  $outputPage->addHTML( $form );
1752 
1753  $deleteLogPage = new LogPage( 'delete' );
1754  $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1755  LogEventsList::showLogExtract( $outputPage, 'delete', $title );
1756  }
1757 
1763  public function doDelete( $reason, $suppress = false ) {
1764  $error = '';
1765  $context = $this->getContext();
1766  $outputPage = $context->getOutput();
1767  $user = $context->getUser();
1768  $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error, $user );
1769 
1770  if ( $status->isGood() ) {
1771  $deleted = $this->getTitle()->getPrefixedText();
1772 
1773  $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1774  $outputPage->setRobotPolicy( 'noindex,nofollow' );
1775 
1776  $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1777 
1778  $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1779 
1780  Hooks::run( 'ArticleDeleteAfterSuccess', [ $this->getTitle(), $outputPage ] );
1781 
1782  $outputPage->returnToMain( false );
1783  } else {
1784  $outputPage->setPageTitle(
1785  wfMessage( 'cannotdelete-title',
1786  $this->getTitle()->getPrefixedText() )
1787  );
1788 
1789  if ( $error == '' ) {
1790  $outputPage->addWikiText(
1791  "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1792  );
1793  $deleteLogPage = new LogPage( 'delete' );
1794  $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1795 
1797  $outputPage,
1798  'delete',
1799  $this->getTitle()
1800  );
1801  } else {
1802  $outputPage->addHTML( $error );
1803  }
1804  }
1805  }
1806 
1807  /* Caching functions */
1808 
1816  protected function tryFileCache() {
1817  static $called = false;
1818 
1819  if ( $called ) {
1820  wfDebug( "Article::tryFileCache(): called twice!?\n" );
1821  return false;
1822  }
1823 
1824  $called = true;
1825  if ( $this->isFileCacheable() ) {
1826  $cache = new HTMLFileCache( $this->getTitle(), 'view' );
1827  if ( $cache->isCacheGood( $this->mPage->getTouched() ) ) {
1828  wfDebug( "Article::tryFileCache(): about to load file\n" );
1829  $cache->loadFromFileCache( $this->getContext() );
1830  return true;
1831  } else {
1832  wfDebug( "Article::tryFileCache(): starting buffer\n" );
1833  ob_start( [ &$cache, 'saveToFileCache' ] );
1834  }
1835  } else {
1836  wfDebug( "Article::tryFileCache(): not cacheable\n" );
1837  }
1838 
1839  return false;
1840  }
1841 
1847  public function isFileCacheable( $mode = HTMLFileCache::MODE_NORMAL ) {
1848  $cacheable = false;
1849 
1850  if ( HTMLFileCache::useFileCache( $this->getContext(), $mode ) ) {
1851  $cacheable = $this->mPage->getId()
1852  && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
1853  // Extension may have reason to disable file caching on some pages.
1854  if ( $cacheable ) {
1855  // Avoid PHP 7.1 warning of passing $this by reference
1856  $articlePage = $this;
1857  $cacheable = Hooks::run( 'IsFileCacheable', [ &$articlePage ] );
1858  }
1859  }
1860 
1861  return $cacheable;
1862  }
1863 
1877  public function getParserOutput( $oldid = null, User $user = null ) {
1878  // XXX: bypasses mParserOptions and thus setParserOptions()
1879 
1880  if ( $user === null ) {
1881  $parserOptions = $this->getParserOptions();
1882  } else {
1883  $parserOptions = $this->mPage->makeParserOptions( $user );
1884  }
1885 
1886  return $this->mPage->getParserOutput( $parserOptions, $oldid );
1887  }
1888 
1896  if ( $this->mParserOptions ) {
1897  throw new MWException( "can't change parser options after they have already been set" );
1898  }
1899 
1900  // clone, so if $options is modified later, it doesn't confuse the parser cache.
1901  $this->mParserOptions = clone $options;
1902  }
1903 
1908  public function getParserOptions() {
1909  if ( !$this->mParserOptions ) {
1910  $this->mParserOptions = $this->mPage->makeParserOptions( $this->getContext() );
1911  }
1912  // Clone to allow modifications of the return value without affecting cache
1913  return clone $this->mParserOptions;
1914  }
1915 
1922  public function setContext( $context ) {
1923  $this->mContext = $context;
1924  }
1925 
1932  public function getContext() {
1933  if ( $this->mContext instanceof IContextSource ) {
1934  return $this->mContext;
1935  } else {
1936  wfDebug( __METHOD__ . " called and \$mContext is null. " .
1937  "Return RequestContext::getMain(); for sanity\n" );
1938  return RequestContext::getMain();
1939  }
1940  }
1941 
1949  public function __get( $fname ) {
1950  if ( property_exists( $this->mPage, $fname ) ) {
1951  # wfWarn( "Access to raw $fname field " . __CLASS__ );
1952  return $this->mPage->$fname;
1953  }
1954  trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE );
1955  }
1956 
1964  public function __set( $fname, $fvalue ) {
1965  if ( property_exists( $this->mPage, $fname ) ) {
1966  # wfWarn( "Access to raw $fname field of " . __CLASS__ );
1967  $this->mPage->$fname = $fvalue;
1968  // Note: extensions may want to toss on new fields
1969  } elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
1970  $this->mPage->$fname = $fvalue;
1971  } else {
1972  trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE );
1973  }
1974  }
1975 
1980  public function checkFlags( $flags ) {
1981  return $this->mPage->checkFlags( $flags );
1982  }
1983 
1988  public function checkTouched() {
1989  return $this->mPage->checkTouched();
1990  }
1991 
1996  public function clearPreparedEdit() {
1997  $this->mPage->clearPreparedEdit();
1998  }
1999 
2004  public function doDeleteArticleReal(
2005  $reason, $suppress = false, $u1 = null, $u2 = null, &$error = '', User $user = null,
2006  $tags = []
2007  ) {
2008  return $this->mPage->doDeleteArticleReal(
2009  $reason, $suppress, $u1, $u2, $error, $user, $tags
2010  );
2011  }
2012 
2017  public function doDeleteUpdates( $id, Content $content = null ) {
2018  return $this->mPage->doDeleteUpdates( $id, $content );
2019  }
2020 
2026  public function doEditContent( Content $content, $summary, $flags = 0, $baseRevId = false,
2027  User $user = null, $serialFormat = null
2028  ) {
2029  wfDeprecated( __METHOD__, '1.29' );
2030  return $this->mPage->doEditContent( $content, $summary, $flags, $baseRevId,
2031  $user, $serialFormat
2032  );
2033  }
2034 
2039  public function doEditUpdates( Revision $revision, User $user, array $options = [] ) {
2040  return $this->mPage->doEditUpdates( $revision, $user, $options );
2041  }
2042 
2049  public function doPurge() {
2050  return $this->mPage->doPurge();
2051  }
2052 
2058  public function getLastPurgeTimestamp() {
2059  wfDeprecated( __METHOD__, '1.29' );
2060  return $this->mPage->getLastPurgeTimestamp();
2061  }
2062 
2067  public function doViewUpdates( User $user, $oldid = 0 ) {
2068  $this->mPage->doViewUpdates( $user, $oldid );
2069  }
2070 
2075  public function exists() {
2076  return $this->mPage->exists();
2077  }
2078 
2083  public function followRedirect() {
2084  return $this->mPage->followRedirect();
2085  }
2086 
2091  public function getActionOverrides() {
2092  return $this->mPage->getActionOverrides();
2093  }
2094 
2099  public function getAutoDeleteReason( &$hasHistory ) {
2100  return $this->mPage->getAutoDeleteReason( $hasHistory );
2101  }
2102 
2107  public function getCategories() {
2108  return $this->mPage->getCategories();
2109  }
2110 
2115  public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2116  return $this->mPage->getComment( $audience, $user );
2117  }
2118 
2123  public function getContentHandler() {
2124  return $this->mPage->getContentHandler();
2125  }
2126 
2131  public function getContentModel() {
2132  return $this->mPage->getContentModel();
2133  }
2134 
2139  public function getContributors() {
2140  return $this->mPage->getContributors();
2141  }
2142 
2147  public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2148  return $this->mPage->getCreator( $audience, $user );
2149  }
2150 
2155  public function getDeletionUpdates( Content $content = null ) {
2156  return $this->mPage->getDeletionUpdates( $content );
2157  }
2158 
2163  public function getHiddenCategories() {
2164  return $this->mPage->getHiddenCategories();
2165  }
2166 
2171  public function getId() {
2172  return $this->mPage->getId();
2173  }
2174 
2179  public function getLatest() {
2180  return $this->mPage->getLatest();
2181  }
2182 
2187  public function getLinksTimestamp() {
2188  return $this->mPage->getLinksTimestamp();
2189  }
2190 
2195  public function getMinorEdit() {
2196  return $this->mPage->getMinorEdit();
2197  }
2198 
2203  public function getOldestRevision() {
2204  return $this->mPage->getOldestRevision();
2205  }
2206 
2211  public function getRedirectTarget() {
2212  return $this->mPage->getRedirectTarget();
2213  }
2214 
2219  public function getRedirectURL( $rt ) {
2220  return $this->mPage->getRedirectURL( $rt );
2221  }
2222 
2227  public function getRevision() {
2228  return $this->mPage->getRevision();
2229  }
2230 
2235  public function getTimestamp() {
2236  return $this->mPage->getTimestamp();
2237  }
2238 
2243  public function getTouched() {
2244  return $this->mPage->getTouched();
2245  }
2246 
2251  public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
2252  return $this->mPage->getUndoContent( $undo, $undoafter );
2253  }
2254 
2259  public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2260  return $this->mPage->getUser( $audience, $user );
2261  }
2262 
2267  public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
2268  return $this->mPage->getUserText( $audience, $user );
2269  }
2270 
2275  public function hasViewableContent() {
2276  return $this->mPage->hasViewableContent();
2277  }
2278 
2283  public function insertOn( $dbw, $pageId = null ) {
2284  return $this->mPage->insertOn( $dbw, $pageId );
2285  }
2286 
2291  public function insertProtectNullRevision( $revCommentMsg, array $limit,
2292  array $expiry, $cascade, $reason, $user = null
2293  ) {
2294  return $this->mPage->insertProtectNullRevision( $revCommentMsg, $limit,
2295  $expiry, $cascade, $reason, $user
2296  );
2297  }
2298 
2303  public function insertRedirect() {
2304  return $this->mPage->insertRedirect();
2305  }
2306 
2311  public function insertRedirectEntry( Title $rt, $oldLatest = null ) {
2312  return $this->mPage->insertRedirectEntry( $rt, $oldLatest );
2313  }
2314 
2319  public function isCountable( $editInfo = false ) {
2320  return $this->mPage->isCountable( $editInfo );
2321  }
2322 
2327  public function isRedirect() {
2328  return $this->mPage->isRedirect();
2329  }
2330 
2335  public function loadFromRow( $data, $from ) {
2336  return $this->mPage->loadFromRow( $data, $from );
2337  }
2338 
2343  public function loadPageData( $from = 'fromdb' ) {
2344  $this->mPage->loadPageData( $from );
2345  }
2346 
2351  public function lockAndGetLatest() {
2352  return $this->mPage->lockAndGetLatest();
2353  }
2354 
2359  public function makeParserOptions( $context ) {
2360  return $this->mPage->makeParserOptions( $context );
2361  }
2362 
2367  public function pageDataFromId( $dbr, $id, $options = [] ) {
2368  return $this->mPage->pageDataFromId( $dbr, $id, $options );
2369  }
2370 
2375  public function pageDataFromTitle( $dbr, $title, $options = [] ) {
2376  return $this->mPage->pageDataFromTitle( $dbr, $title, $options );
2377  }
2378 
2383  public function prepareContentForEdit(
2384  Content $content, $revision = null, User $user = null,
2385  $serialFormat = null, $useCache = true
2386  ) {
2387  return $this->mPage->prepareContentForEdit(
2388  $content, $revision, $user,
2389  $serialFormat, $useCache
2390  );
2391  }
2392 
2397  public function protectDescription( array $limit, array $expiry ) {
2398  return $this->mPage->protectDescription( $limit, $expiry );
2399  }
2400 
2405  public function protectDescriptionLog( array $limit, array $expiry ) {
2406  return $this->mPage->protectDescriptionLog( $limit, $expiry );
2407  }
2408 
2413  public function replaceSectionAtRev( $sectionId, Content $sectionContent,
2414  $sectionTitle = '', $baseRevId = null
2415  ) {
2416  return $this->mPage->replaceSectionAtRev( $sectionId, $sectionContent,
2417  $sectionTitle, $baseRevId
2418  );
2419  }
2420 
2425  public function replaceSectionContent(
2426  $sectionId, Content $sectionContent, $sectionTitle = '', $edittime = null
2427  ) {
2428  return $this->mPage->replaceSectionContent(
2429  $sectionId, $sectionContent, $sectionTitle, $edittime
2430  );
2431  }
2432 
2437  public function setTimestamp( $ts ) {
2438  return $this->mPage->setTimestamp( $ts );
2439  }
2440 
2445  public function shouldCheckParserCache( ParserOptions $parserOptions, $oldId ) {
2446  return $this->mPage->shouldCheckParserCache( $parserOptions, $oldId );
2447  }
2448 
2453  public function supportsSections() {
2454  return $this->mPage->supportsSections();
2455  }
2456 
2462  return $this->mPage->triggerOpportunisticLinksUpdate( $parserOutput );
2463  }
2464 
2469  public function updateCategoryCounts( array $added, array $deleted, $id = 0 ) {
2470  return $this->mPage->updateCategoryCounts( $added, $deleted, $id );
2471  }
2472 
2477  public function updateIfNewerOn( $dbw, $revision ) {
2478  return $this->mPage->updateIfNewerOn( $dbw, $revision );
2479  }
2480 
2485  public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
2486  return $this->mPage->updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null );
2487  }
2488 
2493  public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
2494  $lastRevIsRedirect = null
2495  ) {
2496  return $this->mPage->updateRevisionOn( $dbw, $revision, $lastRevision,
2497  $lastRevIsRedirect
2498  );
2499  }
2500 
2509  public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
2510  $reason, User $user
2511  ) {
2512  return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
2513  }
2514 
2522  public function updateRestrictions( $limit = [], $reason = '',
2523  &$cascade = 0, $expiry = []
2524  ) {
2525  return $this->mPage->doUpdateRestrictions(
2526  $limit,
2527  $expiry,
2528  $cascade,
2529  $reason,
2530  $this->getContext()->getUser()
2531  );
2532  }
2533 
2542  public function doDeleteArticle(
2543  $reason, $suppress = false, $u1 = null, $u2 = null, &$error = ''
2544  ) {
2545  return $this->mPage->doDeleteArticle( $reason, $suppress, $u1, $u2, $error );
2546  }
2547 
2557  public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
2558  $user = is_null( $user ) ? $this->getContext()->getUser() : $user;
2559  return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2560  }
2561 
2570  public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
2571  $guser = is_null( $guser ) ? $this->getContext()->getUser() : $guser;
2572  return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2573  }
2574 
2579  public function generateReason( &$hasHistory ) {
2580  $title = $this->mPage->getTitle();
2582  return $handler->getAutoDeleteReason( $title, $hasHistory );
2583  }
2584 
2590  public static function selectFields() {
2591  wfDeprecated( __METHOD__, '1.24' );
2592  return WikiPage::selectFields();
2593  }
2594 
2600  public static function onArticleCreate( $title ) {
2601  wfDeprecated( __METHOD__, '1.24' );
2603  }
2604 
2610  public static function onArticleDelete( $title ) {
2611  wfDeprecated( __METHOD__, '1.24' );
2613  }
2614 
2620  public static function onArticleEdit( $title ) {
2621  wfDeprecated( __METHOD__, '1.24' );
2623  }
2624 
2625  // ******
2626 }
ReadOnlyError
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
Definition: ReadOnlyError.php:28
Revision\FOR_PUBLIC
const FOR_PUBLIC
Definition: Revision.php:98
Article\showMissingArticle
showMissingArticle()
Show the error text for a missing article.
Definition: Article.php:1122
Article\checkFlags
checkFlags( $flags)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:1980
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:33
HTMLFileCache\useFileCache
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
Definition: HTMLFileCache.php:93
Page
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
Definition: Page.php:24
Revision\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: Revision.php:93
$context
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2612
WikiPage\onArticleCreate
static onArticleCreate(Title $title)
The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of ...
Definition: WikiPage.php:3243
Article\isRedirect
isRedirect()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2327
Article\getCategories
getCategories()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2107
$request
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2612
ParserOutput
Definition: ParserOutput.php:24
Article\formatRobotPolicy
static formatRobotPolicy( $policy)
Converts a String robot policy into an associative array, to allow merging of several policies using ...
Definition: Article.php:805
Article\getRedirectTarget
getRedirectTarget()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2211
Article\view
view()
This is the default action of the index.php entry point: just view the page of the given title.
Definition: Article.php:429
Revision\newFromId
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:116
Article\doDeleteUpdates
doDeleteUpdates( $id, Content $content=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2017
ContextSource\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:187
Article\getContentModel
getContentModel()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2131
Article\getUserText
getUserText( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2267
Article\getLinksTimestamp
getLinksTimestamp()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2187
Article\onArticleCreate
static onArticleCreate( $title)
Definition: Article.php:2600
Article\getOldIDFromRequest
getOldIDFromRequest()
Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect.
Definition: Article.php:256
Article\showPatrolFooter
showPatrolFooter()
If patrol is possible, output a patrol UI box.
Definition: Article.php:948
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
RecentChange\newFromConds
static newFromConds( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
Definition: RecentChange.php:185
Article\tryFileCache
tryFileCache()
checkLastModified returns true if it has taken care of all output to the client that is necessary for...
Definition: Article.php:1816
Article\getContentHandler
getContentHandler()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2123
Article\clearPreparedEdit
clearPreparedEdit()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:1996
HTMLFileCache
Page view caching in the file system.
Definition: HTMLFileCache.php:33
captcha-old.count
count
Definition: captcha-old.py:225
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
Article\lockAndGetLatest
lockAndGetLatest()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2351
Article\$mParserOutput
ParserOutput $mParserOutput
Definition: Article.php:76
Article\supportsSections
supportsSections()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2453
Article\getOldestRevision
getOldestRevision()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2203
Article\getDeletionUpdates
getDeletionUpdates(Content $content=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2155
Article\checkTouched
checkTouched()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:1988
$sectionContent
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty & $sectionContent
Definition: hooks.txt:2536
$status
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1049
Article\getRevision
getRevision()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2227
RC_LOG
const RC_LOG
Definition: Defines.php:142
CategoryPage
Special handling for category description pages, showing pages, subcategories and file that belong to...
Definition: CategoryPage.php:28
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:36
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:36
Article\getRobotPolicy
getRobotPolicy( $action, $pOutput=null)
Get the robot policy to be used for the current view.
Definition: Article.php:725
PoolWorkArticleView
Definition: PoolWorkArticleView.php:21
NS_FILE
const NS_FILE
Definition: Defines.php:68
Article\doDeleteArticle
doDeleteArticle( $reason, $suppress=false, $u1=null, $u2=null, &$error='')
Definition: Article.php:2542
Article\getCreator
getCreator( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2147
Block\newFromTarget
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Definition: Block.php:1113
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1277
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:556
Linker\linkKnown
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:159
Article\showDiffPage
showDiffPage()
Show a diff page according to current request variables.
Definition: Article.php:675
ContentHandler\getForTitle
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
Definition: ContentHandler.php:240
ImagePage
Class for viewing MediaWiki file description pages.
Definition: ImagePage.php:30
ContextSource\getRequest
getRequest()
Get the WebRequest object.
Definition: ContextSource.php:78
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition: PermissionsError.php:28
Article\confirmDelete
confirmDelete( $reason)
Output deletion confirmation dialog.
Definition: Article.php:1655
Article\$mContext
IContextSource $mContext
The context this Article is executed in.
Definition: Article.php:37
Article\updateCategoryCounts
updateCategoryCounts(array $added, array $deleted, $id=0)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2469
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
WikiPage\onArticleEdit
static onArticleEdit(Title $title, Revision $revision=null)
Purge caches on page update etc.
Definition: WikiPage.php:3315
Article\adjustDisplayTitle
adjustDisplayTitle(ParserOutput $pOutput)
Adjust title for pages with displaytitle, -{T|}- or language conversion.
Definition: Article.php:663
Article\showNamespaceHeader
showNamespaceHeader()
Show a header specific to the namespace currently being viewed, like [[MediaWiki:Talkpagetext]].
Definition: Article.php:911
Article\shouldCheckParserCache
shouldCheckParserCache(ParserOptions $parserOptions, $oldId)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2445
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
Article\$mContentObject
Content $mContentObject
Content of the revision we are working on.
Definition: Article.php:55
ProtectionForm
Handles the page protection UI and backend.
Definition: ProtectionForm.php:30
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Article\protectDescriptionLog
protectDescriptionLog(array $limit, array $expiry)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2405
Html\input
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:663
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:143
Revision\FOR_THIS_USER
const FOR_THIS_USER
Definition: Revision.php:99
Revision
Definition: Revision.php:33
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:309
Article\unprotect
unprotect()
action=unprotect handler (alias)
Definition: Article.php:1520
Article\insertRedirect
insertRedirect()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2303
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1572
Article\getRedirectedFrom
getRedirectedFrom()
Get the page this view was redirected from.
Definition: Article.php:156
Article\fetchContentObject
fetchContentObject()
Get text content object Does NOT follow redirects.
Definition: Article.php:314
Article\getLastPurgeTimestamp
getLastPurgeTimestamp()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2058
Article\clear
clear()
Clear the object.
Definition: Article.php:191
Article\updateRedirectOn
updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2485
Article\newFromWikiPage
static newFromWikiPage(WikiPage $page, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition: Article.php:145
Article\getTouched
getTouched()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2243
$html
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1956
Article\onArticleDelete
static onArticleDelete( $title)
Definition: Article.php:2610
MWException
MediaWiki exception.
Definition: MWException.php:26
wfMemcKey
wfMemcKey()
Make a cache key for the local wiki.
Definition: GlobalFunctions.php:2961
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
Article\getTitle
getTitle()
Get the title object of the article.
Definition: Article.php:174
Article\updateRevisionOn
updateRevisionOn( $dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2493
Article\render
render()
Handle action=render.
Definition: Article.php:1502
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1128
ObjectCache\getMainStashInstance
static getMainStashInstance()
Get the cache object for the main stash.
Definition: ObjectCache.php:393
Article\insertProtectNullRevision
insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2291
Article\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: Article.php:1485
Article\exists
exists()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2075
Article\setRedirectedFrom
setRedirectedFrom(Title $from)
Tell the page view functions that this view was redirected from another page on the wiki.
Definition: Article.php:165
$wgUseFileCache
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
Definition: DefaultSettings.php:2532
WikiPage\selectFields
static selectFields()
Return the list of revision fields that should be selected to create a new page.
Definition: WikiPage.php:286
$content
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
Definition: hooks.txt:1049
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
Linker\revUserTools
static revUserTools( $rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
Definition: Linker.php:1055
$page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2536
Article\__construct
__construct(Title $title, $oldId=null)
Constructor and clear the article.
Definition: Article.php:83
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:123
in
null for the wiki Added in
Definition: hooks.txt:1572
Article\showDeletedRevisionHeader
showDeletedRevisionHeader()
If the revision requested for view is deleted, check permissions.
Definition: Article.php:1247
IExpiringStore\TTL_DAY
const TTL_DAY
Definition: IExpiringStore.php:35
Article\isFileCacheable
isFileCacheable( $mode=HTMLFileCache::MODE_NORMAL)
Check if the page can be cached.
Definition: Article.php:1847
Article\doRollback
doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user=null)
Definition: Article.php:2557
not
if not
Definition: COPYING.txt:307
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:31
Article\setOldSubtitle
setOldSubtitle( $oldid=0)
Generate the navigation links when browsing through an article revisions It shows the information as:...
Definition: Article.php:1290
$limit
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
Definition: hooks.txt:1049
WikiPage\onArticleDelete
static onArticleDelete(Title $title)
Clears caches when article is deleted.
Definition: WikiPage.php:3272
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
Article\getPage
getPage()
Get the WikiPage object of this instance.
Definition: Article.php:184
Article\getContext
getContext()
Gets the context this Article is executed in.
Definition: Article.php:1932
User\isIP
static isIP( $name)
Does the string match an anonymous IP address?
Definition: User.php:819
WatchAction\doWatchOrUnwatch
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
Definition: WatchAction.php:93
Article\getComment
getComment( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2115
Article\pageDataFromId
pageDataFromId( $dbr, $id, $options=[])
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2367
Article\insertOn
insertOn( $dbw, $pageId=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2283
Linker\makeExternalLink
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
Definition: Linker.php:838
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:514
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
Article\getRedirectURL
getRedirectURL( $rt)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2219
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:564
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
Article\newFromID
static newFromID( $id)
Constructor from a page id.
Definition: Article.php:101
Article\newPage
newPage(Title $title)
Definition: Article.php:92
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:76
Article\getUndoContent
getUndoContent(Revision $undo, Revision $undoafter=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2251
Article\prepareContentForEdit
prepareContentForEdit(Content $content, $revision=null, User $user=null, $serialFormat=null, $useCache=true)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2383
Html\label
static label( $label, $id, array $attribs=[])
Convenience function for generating a label for inputs.
Definition: Html.php:730
Article\$mRevIdFetched
int $mRevIdFetched
Revision ID of revision we are working on.
Definition: Article.php:70
Article\doEditContent
doEditContent(Content $content, $summary, $flags=0, $baseRevId=false, User $user=null, $serialFormat=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2026
Article\getLatest
getLatest()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2179
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:999
Article\isCurrent
isCurrent()
Returns true if the currently-referenced revision is the current edit to this page (and it exists).
Definition: Article.php:390
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
$dir
$dir
Definition: Autoload.php:8
ContentHandler\makeContent
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Definition: ContentHandler.php:129
Article\getAutoDeleteReason
getAutoDeleteReason(&$hasHistory)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2099
Article\$mContentLoaded
bool $mContentLoaded
Is the content ($mContent) already loaded?
Definition: Article.php:58
Article\setParserOptions
setParserOptions(ParserOptions $options)
Override the ParserOptions used to render the primary article wikitext.
Definition: Article.php:1895
Article\isCountable
isCountable( $editInfo=false)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2319
Article\$mRedirectedFrom
Title $mRedirectedFrom
Title from which we were redirected here.
Definition: Article.php:64
Article\doDelete
doDelete( $reason, $suppress=false)
Perform a deletion and output success or failure messages.
Definition: Article.php:1763
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:746
ParserOutput\getTitleText
getTitleText()
Definition: ParserOutput.php:329
Article\doPurge
doPurge()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2049
Linker\revComment
static revComment(Revision $rev, $local=false, $isPublic=false)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
Definition: Linker.php:1464
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:65
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2122
ParserCache\singleton
static singleton()
Get an instance of this object.
Definition: ParserCache.php:36
Article\hasViewableContent
hasViewableContent()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2275
Article\$mOldId
int null $mOldId
The oldid of the article that is to be shown, 0 for the current revision.
Definition: Article.php:61
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:50
Article\getContributors
getContributors()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2139
HTMLFileCache\MODE_NORMAL
const MODE_NORMAL
Definition: HTMLFileCache.php:34
Article\loadFromRow
loadFromRow( $data, $from)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2335
Linker\getRevDeleteLink
static getRevDeleteLink(User $user, Revision $rev, Title $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
Definition: Linker.php:2017
Article\onArticleEdit
static onArticleEdit( $title)
Definition: Article.php:2620
Article\protect
protect()
action=protect handler
Definition: Article.php:1512
Article\getTimestamp
getTimestamp()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2235
Linker\link
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition: Linker.php:107
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1657
Article\getMinorEdit
getMinorEdit()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2195
Article\commitRollback
commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser=null)
Definition: Article.php:2570
Article\getParserOutput
getParserOutput( $oldid=null, User $user=null)
#-
Definition: Article.php:1877
Article\$mParserOptions
ParserOptions $mParserOptions
ParserOptions object for $wgUser articles.
Definition: Article.php:43
Article\getUser
getUser( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2259
Article\getContentObject
getContentObject()
Returns a Content object representing the pages effective display content, not necessarily the revisi...
Definition: Article.php:216
Article\followRedirect
followRedirect()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2083
Block\TYPE_AUTO
const TYPE_AUTO
Definition: Block.php:86
Article\getHiddenCategories
getHiddenCategories()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2163
$handler
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
Definition: hooks.txt:783
RequestContext\getMain
static getMain()
Static methods.
Definition: RequestContext.php:468
IP\isValid
static isValid( $ip)
Validate an IP address.
Definition: IP.php:113
Article\setTimestamp
setTimestamp( $ts)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2437
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
Article\__get
__get( $fname)
Use PHP's magic __get handler to handle accessing of raw WikiPage fields for backwards compatibility.
Definition: Article.php:1949
Content
Base interface for content objects.
Definition: Content.php:34
Article\replaceSectionAtRev
replaceSectionAtRev( $sectionId, Content $sectionContent, $sectionTitle='', $baseRevId=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2413
$unhide
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify as strings Extensions should add to this list prev or next refreshes the diff cache $unhide
Definition: hooks.txt:1572
Title
Represents a title within MediaWiki.
Definition: Title.php:39
Article\selectFields
static selectFields()
Definition: Article.php:2590
Skin\makeUrl
static makeUrl( $name, $urlaction='')
Definition: Skin.php:1119
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
$dbr
if(! $regexes) $dbr
Definition: cleanup.php:94
$cache
$cache
Definition: mcc.php:33
Xml\listDropDown
static listDropDown( $name='', $list='', $other='', $selected='', $class='', $tabindex=null)
Build a drop-down box from a textual list.
Definition: Xml.php:507
Article\replaceSectionContent
replaceSectionContent( $sectionId, Content $sectionContent, $sectionTitle='', $edittime=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2425
ObjectCache\getMainWANInstance
static getMainWANInstance()
Get the main WAN cache object.
Definition: ObjectCache.php:370
Article\getRevIdFetched
getRevIdFetched()
Use this to fetch the rev ID used on page views.
Definition: Article.php:417
MessageContent
Wrapper allowing us to handle a system message as a Content object.
Definition: MessageContent.php:36
Article\makeParserOptions
makeParserOptions( $context)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2359
Article\showRedirectedFromHeader
showRedirectedFromHeader()
If this request is a redirect view, send "redirected from" subtitle to the output.
Definition: Article.php:834
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1741
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Block
Definition: Block.php:27
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:251
RecentChange\isInRCLifespan
static isInRCLifespan( $timestamp, $tolerance=0)
Check whether the given timestamp is new enough to have a RC row with a given tolerance as the recent...
Definition: RecentChange.php:1003
$article
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
Definition: hooks.txt:78
NS_USER
const NS_USER
Definition: Defines.php:64
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
Article\getId
getId()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2171
Article\getActionOverrides
getActionOverrides()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2091
Article\$mRedirectUrl
string bool $mRedirectUrl
URL to redirect to or false if none.
Definition: Article.php:67
Article\doUpdateRestrictions
doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user)
Definition: Article.php:2509
Article\updateRestrictions
updateRestrictions( $limit=[], $reason='', &$cascade=0, $expiry=[])
Definition: Article.php:2522
Article\$mRevision
Revision $mRevision
Revision we are working on.
Definition: Article.php:73
Article\protectDescription
protectDescription(array $limit, array $expiry)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2397
Article\getParserOptions
getParserOptions()
Get parser options suitable for rendering the primary article wikitext.
Definition: Article.php:1908
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
Article\updateIfNewerOn
updateIfNewerOn( $dbw, $revision)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2477
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:70
$t
$t
Definition: testCompression.php:67
Article
Class for viewing MediaWiki article and history.
Definition: Article.php:35
Article\pageDataFromTitle
pageDataFromTitle( $dbr, $title, $options=[])
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2375
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
Article\triggerOpportunisticLinksUpdate
triggerOpportunisticLinksUpdate(ParserOutput $parserOutput)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2461
Article\getOldID
getOldID()
Definition: Article.php:243
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:50
Article\setContext
setContext( $context)
Sets the context this Article is executed in.
Definition: Article.php:1922
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:405
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
Article\insertRedirectEntry
insertRedirectEntry(Title $rt, $oldLatest=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2311
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
Article\getRevisionFetched
getRevisionFetched()
Get the fetched Revision object depending on request parameters or null on failure.
Definition: Article.php:406
MWNamespace\getCanonicalName
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
Definition: MWNamespace.php:228
Article\viewRedirect
viewRedirect( $target, $appendSubtitle=true, $forceKnown=false)
Return the HTML for the top of a redirect page.
Definition: Article.php:1428
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:90
Article\loadPageData
loadPageData( $from='fromdb')
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2343
Language
Internationalisation code.
Definition: Language.php:35
Article\doEditUpdates
doEditUpdates(Revision $revision, User $user, array $options=[])
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2039
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2749
$parserOutput
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context $parserOutput
Definition: hooks.txt:1049
Article\$mContent
string $mContent
Text of the revision we are working on.
Definition: Article.php:49
Article\__set
__set( $fname, $fvalue)
Use PHP's magic __set handler to handle setting of raw WikiPage fields for backwards compatibility.
Definition: Article.php:1964
Article\showViewFooter
showViewFooter()
Show the footer section of an ordinary page view.
Definition: Article.php:925
Article\$mPage
WikiPage $mPage
The WikiPage object of this instance.
Definition: Article.php:40
array
the array() calling protocol came about after MediaWiki 1.4rc1.
Article\getRedirectHeaderHtml
static getRedirectHeaderHtml(Language $lang, $target, $forceKnown=false)
Return the HTML for the top of a redirect page.
Definition: Article.php:1450
Article\doDeleteArticleReal
doDeleteArticleReal( $reason, $suppress=false, $u1=null, $u2=null, &$error='', User $user=null, $tags=[])
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2004
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:459
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:419
Article\newFromTitle
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition: Article.php:113
Article\generateReason
generateReason(&$hasHistory)
Definition: Article.php:2579
Article\purgePatrolFooterCache
static purgePatrolFooterCache( $articleID)
Purge the cache used to check if it is worth showing the patrol footer For example,...
Definition: Article.php:1113
Article\doViewUpdates
doViewUpdates(User $user, $oldid=0)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2067
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:783