MediaWiki  1.29.2
ParserOptions.php
Go to the documentation of this file.
1 <?php
23 use Wikimedia\ScopedCallback;
24 
34 
39 
44 
49 
54 
58  private $mDateFormat = null;
59 
63  private $mEditSection = true;
64 
69 
73  private $mTidy = false;
74 
78  private $mInterfaceMessage = false;
79 
83  private $mTargetLanguage = null;
84 
89 
94 
99 
104 
109 
114 
118  private $mRemoveComments = true;
119 
124  [ 'Parser', 'statelessFetchRevision' ];
125 
130  [ 'Parser', 'statelessFetchTemplate' ];
131 
136 
140  private $mEnableLimitReport = false;
141 
145  private $mTimestamp;
146 
151 
157 
161  private $mPreSaveTransform = true;
162 
167 
172 
177 
181  private $mThumbSize;
182 
187 
191  private $mUserLang;
192 
197  private $mUser;
198 
202  private $mIsPreview = false;
203 
207  private $mIsSectionPreview = false;
208 
212  private $mIsPrintable = false;
213 
217  private $mExtraKey = '';
218 
222  private $mMagicISBNLinks = true;
223 
227  private $mMagicPMIDLinks = true;
228 
232  private $mMagicRFCLinks = true;
233 
237  private $onAccessCallback = null;
238 
244  private $redirectTarget = null;
245 
259  private $allowUnsafeRawHtml = true;
260 
261  public function getInterwikiMagic() {
262  return $this->mInterwikiMagic;
263  }
264 
265  public function getAllowExternalImages() {
267  }
268 
269  public function getAllowExternalImagesFrom() {
271  }
272 
273  public function getEnableImageWhitelist() {
275  }
276 
277  public function getEditSection() {
278  return $this->mEditSection;
279  }
280 
281  public function getNumberHeadings() {
282  $this->optionUsed( 'numberheadings' );
283 
284  return $this->mNumberHeadings;
285  }
286 
287  public function getAllowSpecialInclusion() {
289  }
290 
291  public function getTidy() {
292  return $this->mTidy;
293  }
294 
295  public function getInterfaceMessage() {
297  }
298 
299  public function getTargetLanguage() {
300  return $this->mTargetLanguage;
301  }
302 
303  public function getMaxIncludeSize() {
304  return $this->mMaxIncludeSize;
305  }
306 
307  public function getMaxPPNodeCount() {
308  return $this->mMaxPPNodeCount;
309  }
310 
311  public function getMaxGeneratedPPNodeCount() {
313  }
314 
315  public function getMaxPPExpandDepth() {
317  }
318 
319  public function getMaxTemplateDepth() {
321  }
322 
323  /* @since 1.20 */
326  }
327 
328  public function getRemoveComments() {
329  return $this->mRemoveComments;
330  }
331 
332  /* @since 1.24 */
333  public function getCurrentRevisionCallback() {
335  }
336 
337  public function getTemplateCallback() {
339  }
340 
342  public function getSpeculativeRevIdCallback() {
344  }
345 
346  public function getEnableLimitReport() {
348  }
349 
350  public function getCleanSignatures() {
352  }
353 
354  public function getExternalLinkTarget() {
356  }
357 
358  public function getDisableContentConversion() {
360  }
361 
362  public function getDisableTitleConversion() {
364  }
365 
366  public function getThumbSize() {
367  $this->optionUsed( 'thumbsize' );
368 
369  return $this->mThumbSize;
370  }
371 
372  public function getStubThreshold() {
373  $this->optionUsed( 'stubthreshold' );
374 
375  return $this->mStubThreshold;
376  }
377 
378  public function getIsPreview() {
379  return $this->mIsPreview;
380  }
381 
382  public function getIsSectionPreview() {
384  }
385 
386  public function getIsPrintable() {
387  $this->optionUsed( 'printable' );
388 
389  return $this->mIsPrintable;
390  }
391 
392  public function getUser() {
393  return $this->mUser;
394  }
395 
396  public function getPreSaveTransform() {
398  }
399 
400  public function getDateFormat() {
401  $this->optionUsed( 'dateformat' );
402  if ( !isset( $this->mDateFormat ) ) {
403  $this->mDateFormat = $this->mUser->getDatePreference();
404  }
405  return $this->mDateFormat;
406  }
407 
408  public function getTimestamp() {
409  if ( !isset( $this->mTimestamp ) ) {
410  $this->mTimestamp = wfTimestampNow();
411  }
412  return $this->mTimestamp;
413  }
414 
432  public function getUserLangObj() {
433  $this->optionUsed( 'userlang' );
434  return $this->mUserLang;
435  }
436 
449  public function getUserLang() {
450  return $this->getUserLangObj()->getCode();
451  }
452 
457  public function getMagicISBNLinks() {
458  return $this->mMagicISBNLinks;
459  }
460 
465  public function getMagicPMIDLinks() {
466  return $this->mMagicPMIDLinks;
467  }
472  public function getMagicRFCLinks() {
473  return $this->mMagicRFCLinks;
474  }
475 
480  public function getAllowUnsafeRawHtml() {
482  }
483 
484  public function setInterwikiMagic( $x ) {
485  return wfSetVar( $this->mInterwikiMagic, $x );
486  }
487 
488  public function setAllowExternalImages( $x ) {
489  return wfSetVar( $this->mAllowExternalImages, $x );
490  }
491 
492  public function setAllowExternalImagesFrom( $x ) {
493  return wfSetVar( $this->mAllowExternalImagesFrom, $x );
494  }
495 
496  public function setEnableImageWhitelist( $x ) {
497  return wfSetVar( $this->mEnableImageWhitelist, $x );
498  }
499 
500  public function setDateFormat( $x ) {
501  return wfSetVar( $this->mDateFormat, $x );
502  }
503 
504  public function setEditSection( $x ) {
505  return wfSetVar( $this->mEditSection, $x );
506  }
507 
508  public function setNumberHeadings( $x ) {
509  return wfSetVar( $this->mNumberHeadings, $x );
510  }
511 
512  public function setAllowSpecialInclusion( $x ) {
513  return wfSetVar( $this->mAllowSpecialInclusion, $x );
514  }
515 
516  public function setTidy( $x ) {
517  return wfSetVar( $this->mTidy, $x );
518  }
519 
520  public function setInterfaceMessage( $x ) {
521  return wfSetVar( $this->mInterfaceMessage, $x );
522  }
523 
524  public function setTargetLanguage( $x ) {
525  return wfSetVar( $this->mTargetLanguage, $x, true );
526  }
527 
528  public function setMaxIncludeSize( $x ) {
529  return wfSetVar( $this->mMaxIncludeSize, $x );
530  }
531 
532  public function setMaxPPNodeCount( $x ) {
533  return wfSetVar( $this->mMaxPPNodeCount, $x );
534  }
535 
536  public function setMaxGeneratedPPNodeCount( $x ) {
537  return wfSetVar( $this->mMaxGeneratedPPNodeCount, $x );
538  }
539 
540  public function setMaxTemplateDepth( $x ) {
541  return wfSetVar( $this->mMaxTemplateDepth, $x );
542  }
543 
544  /* @since 1.20 */
545  public function setExpensiveParserFunctionLimit( $x ) {
546  return wfSetVar( $this->mExpensiveParserFunctionLimit, $x );
547  }
548 
549  public function setRemoveComments( $x ) {
550  return wfSetVar( $this->mRemoveComments, $x );
551  }
552 
553  /* @since 1.24 */
554  public function setCurrentRevisionCallback( $x ) {
555  return wfSetVar( $this->mCurrentRevisionCallback, $x );
556  }
557 
559  public function setSpeculativeRevIdCallback( $x ) {
560  return wfSetVar( $this->mSpeculativeRevIdCallback, $x );
561  }
562 
563  public function setTemplateCallback( $x ) {
564  return wfSetVar( $this->mTemplateCallback, $x );
565  }
566 
567  public function enableLimitReport( $x = true ) {
568  return wfSetVar( $this->mEnableLimitReport, $x );
569  }
570 
571  public function setTimestamp( $x ) {
572  return wfSetVar( $this->mTimestamp, $x );
573  }
574 
575  public function setCleanSignatures( $x ) {
576  return wfSetVar( $this->mCleanSignatures, $x );
577  }
578 
579  public function setExternalLinkTarget( $x ) {
580  return wfSetVar( $this->mExternalLinkTarget, $x );
581  }
582 
583  public function disableContentConversion( $x = true ) {
584  return wfSetVar( $this->mDisableContentConversion, $x );
585  }
586 
587  public function disableTitleConversion( $x = true ) {
588  return wfSetVar( $this->mDisableTitleConversion, $x );
589  }
590 
591  public function setUserLang( $x ) {
592  if ( is_string( $x ) ) {
593  $x = Language::factory( $x );
594  }
595 
596  return wfSetVar( $this->mUserLang, $x );
597  }
598 
599  public function setThumbSize( $x ) {
600  return wfSetVar( $this->mThumbSize, $x );
601  }
602 
603  public function setStubThreshold( $x ) {
604  return wfSetVar( $this->mStubThreshold, $x );
605  }
606 
607  public function setPreSaveTransform( $x ) {
608  return wfSetVar( $this->mPreSaveTransform, $x );
609  }
610 
611  public function setIsPreview( $x ) {
612  return wfSetVar( $this->mIsPreview, $x );
613  }
614 
615  public function setIsSectionPreview( $x ) {
616  return wfSetVar( $this->mIsSectionPreview, $x );
617  }
618 
619  public function setIsPrintable( $x ) {
620  return wfSetVar( $this->mIsPrintable, $x );
621  }
622 
628  public function setAllowUnsafeRawHtml( $x ) {
629  return wfSetVar( $this->allowUnsafeRawHtml, $x );
630  }
631 
642  function setRedirectTarget( $title ) {
643  $this->redirectTarget = $title;
644  }
645 
652  function getRedirectTarget() {
653  return $this->redirectTarget;
654  }
655 
660  public function addExtraKey( $key ) {
661  $this->mExtraKey .= '!' . $key;
662  }
663 
669  public function __construct( $user = null, $lang = null ) {
670  if ( $user === null ) {
671  global $wgUser;
672  if ( $wgUser === null ) {
673  $user = new User;
674  } else {
675  $user = $wgUser;
676  }
677  }
678  if ( $lang === null ) {
679  global $wgLang;
680  if ( !StubObject::isRealObject( $wgLang ) ) {
681  $wgLang->_unstub();
682  }
683  $lang = $wgLang;
684  }
685  $this->initialiseFromUser( $user, $lang );
686  }
687 
693  public static function newFromAnon() {
695  return new ParserOptions( new User, $wgContLang );
696  }
697 
705  public static function newFromUser( $user ) {
706  return new ParserOptions( $user );
707  }
708 
716  public static function newFromUserAndLang( User $user, Language $lang ) {
717  return new ParserOptions( $user, $lang );
718  }
719 
726  public static function newFromContext( IContextSource $context ) {
727  return new ParserOptions( $context->getUser(), $context->getLanguage() );
728  }
729 
736  private function initialiseFromUser( $user, $lang ) {
737  global $wgInterwikiMagic, $wgAllowExternalImages,
738  $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion,
739  $wgMaxArticleSize, $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth,
740  $wgCleanSignatures, $wgExternalLinkTarget, $wgExpensiveParserFunctionLimit,
741  $wgMaxGeneratedPPNodeCount, $wgDisableLangConversion, $wgDisableTitleConversion,
742  $wgEnableMagicLinks;
743 
744  // *UPDATE* ParserOptions::matches() if any of this changes as needed
745  $this->mInterwikiMagic = $wgInterwikiMagic;
746  $this->mAllowExternalImages = $wgAllowExternalImages;
747  $this->mAllowExternalImagesFrom = $wgAllowExternalImagesFrom;
748  $this->mEnableImageWhitelist = $wgEnableImageWhitelist;
749  $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion;
750  $this->mMaxIncludeSize = $wgMaxArticleSize * 1024;
751  $this->mMaxPPNodeCount = $wgMaxPPNodeCount;
752  $this->mMaxGeneratedPPNodeCount = $wgMaxGeneratedPPNodeCount;
753  $this->mMaxPPExpandDepth = $wgMaxPPExpandDepth;
754  $this->mMaxTemplateDepth = $wgMaxTemplateDepth;
755  $this->mExpensiveParserFunctionLimit = $wgExpensiveParserFunctionLimit;
756  $this->mCleanSignatures = $wgCleanSignatures;
757  $this->mExternalLinkTarget = $wgExternalLinkTarget;
758  $this->mDisableContentConversion = $wgDisableLangConversion;
759  $this->mDisableTitleConversion = $wgDisableLangConversion || $wgDisableTitleConversion;
760  $this->mMagicISBNLinks = $wgEnableMagicLinks['ISBN'];
761  $this->mMagicPMIDLinks = $wgEnableMagicLinks['PMID'];
762  $this->mMagicRFCLinks = $wgEnableMagicLinks['RFC'];
763 
764  $this->mUser = $user;
765  $this->mNumberHeadings = $user->getOption( 'numberheadings' );
766  $this->mThumbSize = $user->getOption( 'thumbsize' );
767  $this->mStubThreshold = $user->getStubThreshold();
768  $this->mUserLang = $lang;
769  }
770 
780  public function matches( ParserOptions $other ) {
781  $fields = array_keys( get_class_vars( __CLASS__ ) );
782  $fields = array_diff( $fields, [
783  'mEnableLimitReport', // only effects HTML comments
784  'onAccessCallback', // only used for ParserOutput option tracking
785  ] );
786  foreach ( $fields as $field ) {
787  if ( !is_object( $this->$field ) && $this->$field !== $other->$field ) {
788  return false;
789  }
790  }
791  // Check the object and lazy-loaded options
792  return (
793  $this->mUserLang->equals( $other->mUserLang ) &&
794  $this->getDateFormat() === $other->getDateFormat()
795  );
796  }
797 
803  public function registerWatcher( $callback ) {
804  $this->onAccessCallback = $callback;
805  }
806 
815  public function optionUsed( $optionName ) {
816  if ( $this->onAccessCallback ) {
817  call_user_func( $this->onAccessCallback, $optionName );
818  }
819  }
820 
827  public static function legacyOptions() {
828  return [
829  'stubthreshold',
830  'numberheadings',
831  'userlang',
832  'thumbsize',
833  'editsection',
834  'printable'
835  ];
836  }
837 
854  public function optionsHash( $forOptions, $title = null ) {
856 
857  // FIXME: Once the cache key is reorganized this argument
858  // can be dropped. It was used when the math extension was
859  // part of core.
860  $confstr = '*';
861 
862  // Space assigned for the stubthreshold but unused
863  // since it disables the parser cache, its value will always
864  // be 0 when this function is called by parsercache.
865  if ( in_array( 'stubthreshold', $forOptions ) ) {
866  $confstr .= '!' . $this->mStubThreshold;
867  } else {
868  $confstr .= '!*';
869  }
870 
871  if ( in_array( 'dateformat', $forOptions ) ) {
872  $confstr .= '!' . $this->getDateFormat();
873  }
874 
875  if ( in_array( 'numberheadings', $forOptions ) ) {
876  $confstr .= '!' . ( $this->mNumberHeadings ? '1' : '' );
877  } else {
878  $confstr .= '!*';
879  }
880 
881  if ( in_array( 'userlang', $forOptions ) ) {
882  $confstr .= '!' . $this->mUserLang->getCode();
883  } else {
884  $confstr .= '!*';
885  }
886 
887  if ( in_array( 'thumbsize', $forOptions ) ) {
888  $confstr .= '!' . $this->mThumbSize;
889  } else {
890  $confstr .= '!*';
891  }
892 
893  // add in language specific options, if any
894  // @todo FIXME: This is just a way of retrieving the url/user preferred variant
895  if ( !is_null( $title ) ) {
896  $confstr .= $title->getPageLanguage()->getExtraHashOptions();
897  } else {
899  $confstr .= $wgContLang->getExtraHashOptions();
900  }
901 
902  $confstr .= $wgRenderHashAppend;
903 
904  // @note: as of Feb 2015, core never sets the editsection flag, since it uses
905  // <mw:editsection> tags to inject editsections on the fly. However, extensions
906  // may be using it by calling ParserOption::optionUsed resp. ParserOutput::registerOption
907  // directly. At least Wikibase does at this point in time.
908  if ( !in_array( 'editsection', $forOptions ) ) {
909  $confstr .= '!*';
910  } elseif ( !$this->mEditSection ) {
911  $confstr .= '!edit=0';
912  }
913 
914  if ( $this->mIsPrintable && in_array( 'printable', $forOptions ) ) {
915  $confstr .= '!printable=1';
916  }
917 
918  if ( $this->mExtraKey != '' ) {
919  $confstr .= $this->mExtraKey;
920  }
921 
922  // Give a chance for extensions to modify the hash, if they have
923  // extra options or other effects on the parser cache.
924  Hooks::run( 'PageRenderingHash', [ &$confstr, $this->getUser(), &$forOptions ] );
925 
926  // Make it a valid memcached key fragment
927  $confstr = str_replace( ' ', '_', $confstr );
928 
929  return $confstr;
930  }
931 
942  public function setupFakeRevision( $title, $content, $user ) {
943  $oldCallback = $this->setCurrentRevisionCallback(
944  function (
945  $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback
946  ) {
947  if ( $titleToCheck->equals( $title ) ) {
948  return new Revision( [
949  'page' => $title->getArticleID(),
950  'user_text' => $user->getName(),
951  'user' => $user->getId(),
952  'parent_id' => $title->getLatestRevID(),
953  'title' => $title,
954  'content' => $content
955  ] );
956  } else {
957  return call_user_func( $oldCallback, $titleToCheck, $parser );
958  }
959  }
960  );
961 
963  $wgHooks['TitleExists'][] =
964  function ( $titleToCheck, &$exists ) use ( $title ) {
965  if ( $titleToCheck->equals( $title ) ) {
966  $exists = true;
967  }
968  };
969  end( $wgHooks['TitleExists'] );
970  $key = key( $wgHooks['TitleExists'] );
971  LinkCache::singleton()->clearBadLink( $title->getPrefixedDBkey() );
972  return new ScopedCallback( function () use ( $title, $key ) {
974  unset( $wgHooks['TitleExists'][$key] );
975  LinkCache::singleton()->clearLink( $title );
976  } );
977  }
978 }
ParserOptions\$onAccessCallback
$onAccessCallback
Function to be called when an option is accessed.
Definition: ParserOptions.php:237
ParserOptions\setMaxIncludeSize
setMaxIncludeSize( $x)
Definition: ParserOptions.php:528
ParserOptions\getMagicPMIDLinks
getMagicPMIDLinks()
Definition: ParserOptions.php:465
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:33
ParserOptions\getAllowExternalImagesFrom
getAllowExternalImagesFrom()
Definition: ParserOptions.php:269
$wgUser
$wgUser
Definition: Setup.php:781
$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
ParserOptions\getExpensiveParserFunctionLimit
getExpensiveParserFunctionLimit()
Definition: ParserOptions.php:324
ParserOptions\$mMaxTemplateDepth
$mMaxTemplateDepth
Maximum recursion depth for templates within templates.
Definition: ParserOptions.php:108
ParserOptions\setTidy
setTidy( $x)
Definition: ParserOptions.php:516
ParserOptions\getIsSectionPreview
getIsSectionPreview()
Definition: ParserOptions.php:382
$wgMaxArticleSize
$wgMaxArticleSize
Maximum article size in kilobytes.
Definition: DefaultSettings.php:2174
ParserOptions\getRemoveComments
getRemoveComments()
Definition: ParserOptions.php:328
ParserOptions\$mCurrentRevisionCallback
callable $mCurrentRevisionCallback
Callback for current revision fetching; first argument to call_user_func().
Definition: ParserOptions.php:123
ParserOptions\setAllowUnsafeRawHtml
setAllowUnsafeRawHtml( $x)
Definition: ParserOptions.php:628
ParserOptions\disableContentConversion
disableContentConversion( $x=true)
Definition: ParserOptions.php:583
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
ParserOptions\$mStubThreshold
$mStubThreshold
Maximum article size of an article to be marked as "stub".
Definition: ParserOptions.php:186
ParserOptions\initialiseFromUser
initialiseFromUser( $user, $lang)
Get user options.
Definition: ParserOptions.php:736
wfSetVar
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
Definition: GlobalFunctions.php:1713
ParserOptions\$mTargetLanguage
$mTargetLanguage
Overrides $mInterfaceMessage with arbitrary language.
Definition: ParserOptions.php:83
ParserOptions\getIsPreview
getIsPreview()
Definition: ParserOptions.php:378
ParserOptions\$allowUnsafeRawHtml
boolean $allowUnsafeRawHtml
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
Definition: ParserOptions.php:259
ParserOptions\getDisableTitleConversion
getDisableTitleConversion()
Definition: ParserOptions.php:362
ParserOptions\setAllowExternalImages
setAllowExternalImages( $x)
Definition: ParserOptions.php:488
ParserOptions\setTemplateCallback
setTemplateCallback( $x)
Definition: ParserOptions.php:563
ParserOptions\setIsPreview
setIsPreview( $x)
Definition: ParserOptions.php:611
ParserOptions\$mTemplateCallback
callable $mTemplateCallback
Callback for template fetching; first argument to call_user_func().
Definition: ParserOptions.php:129
ParserOptions\setTargetLanguage
setTargetLanguage( $x)
Definition: ParserOptions.php:524
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
ParserOptions\$mMaxPPExpandDepth
$mMaxPPExpandDepth
Maximum recursion depth in PPFrame::expand()
Definition: ParserOptions.php:103
ParserOptions\$mRemoveComments
$mRemoveComments
Remove HTML comments.
Definition: ParserOptions.php:118
ParserOptions\getInterfaceMessage
getInterfaceMessage()
Definition: ParserOptions.php:295
$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
ParserOptions\setIsSectionPreview
setIsSectionPreview( $x)
Definition: ParserOptions.php:615
ParserOptions\newFromAnon
static newFromAnon()
Get a ParserOptions object for an anonymous user.
Definition: ParserOptions.php:693
ParserOptions\setEnableImageWhitelist
setEnableImageWhitelist( $x)
Definition: ParserOptions.php:496
ParserOptions\$mMaxGeneratedPPNodeCount
$mMaxGeneratedPPNodeCount
Maximum number of nodes generated by Preprocessor::preprocessToObj()
Definition: ParserOptions.php:98
ParserOptions\$mIsPrintable
$mIsPrintable
Parsing the printable version of the page?
Definition: ParserOptions.php:212
ParserOptions\setSpeculativeRevIdCallback
setSpeculativeRevIdCallback( $x)
Definition: ParserOptions.php:559
ParserOptions\disableTitleConversion
disableTitleConversion( $x=true)
Definition: ParserOptions.php:587
ParserOptions\getIsPrintable
getIsPrintable()
Definition: ParserOptions.php:386
ParserOptions\setMaxGeneratedPPNodeCount
setMaxGeneratedPPNodeCount( $x)
Definition: ParserOptions.php:536
User
User
Definition: All_system_messages.txt:425
ParserOptions\setCurrentRevisionCallback
setCurrentRevisionCallback( $x)
Definition: ParserOptions.php:554
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
ParserOptions\setMaxTemplateDepth
setMaxTemplateDepth( $x)
Definition: ParserOptions.php:540
ParserOptions\getMagicRFCLinks
getMagicRFCLinks()
Definition: ParserOptions.php:472
ParserOptions\getUserLangObj
getUserLangObj()
Get the user language used by the parser for this page and split the parser cache.
Definition: ParserOptions.php:432
ParserOptions\$mPreSaveTransform
$mPreSaveTransform
Transform wiki markup when saving the page?
Definition: ParserOptions.php:161
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
ParserOptions\registerWatcher
registerWatcher( $callback)
Registers a callback for tracking which ParserOptions which are used.
Definition: ParserOptions.php:803
ParserOptions\setupFakeRevision
setupFakeRevision( $title, $content, $user)
Sets a hook to force that a page exists, and sets a current revision callback to return a revision wi...
Definition: ParserOptions.php:942
ParserOptions\getDateFormat
getDateFormat()
Definition: ParserOptions.php:400
ParserOptions\$mInterfaceMessage
$mInterfaceMessage
Which lang to call for PLURAL and GRAMMAR.
Definition: ParserOptions.php:78
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:143
ParserOptions\$mExpensiveParserFunctionLimit
$mExpensiveParserFunctionLimit
Maximum number of calls per parse to expensive parser functions.
Definition: ParserOptions.php:113
ParserOptions\$mAllowExternalImages
$mAllowExternalImages
Allow external images inline?
Definition: ParserOptions.php:43
Revision
Definition: Revision.php:33
key
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 in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Definition: design.txt:25
ParserOptions\$mAllowSpecialInclusion
$mAllowSpecialInclusion
Allow inclusion of special pages?
Definition: ParserOptions.php:68
ParserOptions\setNumberHeadings
setNumberHeadings( $x)
Definition: ParserOptions.php:508
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
ParserOptions\$mTidy
$mTidy
Use tidy to cleanup output HTML?
Definition: ParserOptions.php:73
ParserOptions\$mSpeculativeRevIdCallback
callable null $mSpeculativeRevIdCallback
Callback to generate a guess for {{REVISIONID}}.
Definition: ParserOptions.php:135
ParserOptions\getRedirectTarget
getRedirectTarget()
Get the previously-set redirect target.
Definition: ParserOptions.php:652
ParserOptions\newFromUserAndLang
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
Definition: ParserOptions.php:716
ParserOptions\setUserLang
setUserLang( $x)
Definition: ParserOptions.php:591
ParserOptions\getAllowSpecialInclusion
getAllowSpecialInclusion()
Definition: ParserOptions.php:287
$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
ParserOptions\$mMagicRFCLinks
$mMagicRFCLinks
Are magic RFC links enabled?
Definition: ParserOptions.php:232
ParserOptions\getTidy
getTidy()
Definition: ParserOptions.php:291
ParserOptions\getMaxIncludeSize
getMaxIncludeSize()
Definition: ParserOptions.php:303
ParserOptions\$mUserLang
$mUserLang
Language object of the User language.
Definition: ParserOptions.php:191
ParserOptions\$mDisableTitleConversion
$mDisableTitleConversion
Whether title conversion should be disabled.
Definition: ParserOptions.php:171
ParserOptions\$mIsSectionPreview
$mIsSectionPreview
Parsing the page for a "preview" operation on a single section?
Definition: ParserOptions.php:207
ParserOptions\setThumbSize
setThumbSize( $x)
Definition: ParserOptions.php:599
ParserOptions\getEnableImageWhitelist
getEnableImageWhitelist()
Definition: ParserOptions.php:273
$wgInterwikiMagic
$wgInterwikiMagic
Treat language links as magic connectors, not inline links.
Definition: DefaultSettings.php:2861
ParserOptions\setExternalLinkTarget
setExternalLinkTarget( $x)
Definition: ParserOptions.php:579
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
ParserOptions\$mMagicPMIDLinks
$mMagicPMIDLinks
Are magic PMID links enabled?
Definition: ParserOptions.php:227
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:2536
ParserOptions\setDateFormat
setDateFormat( $x)
Definition: ParserOptions.php:500
ParserOptions\getTargetLanguage
getTargetLanguage()
Definition: ParserOptions.php:299
ParserOptions\setAllowSpecialInclusion
setAllowSpecialInclusion( $x)
Definition: ParserOptions.php:512
ParserOptions\getExternalLinkTarget
getExternalLinkTarget()
Definition: ParserOptions.php:354
ParserOptions\$mDateFormat
$mDateFormat
Date format index.
Definition: ParserOptions.php:58
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:2023
ParserOptions\getStubThreshold
getStubThreshold()
Definition: ParserOptions.php:372
ParserOptions\getUserLang
getUserLang()
Same as getUserLangObj() but returns a string instead.
Definition: ParserOptions.php:449
ParserOptions\getPreSaveTransform
getPreSaveTransform()
Definition: ParserOptions.php:396
ParserOptions\setStubThreshold
setStubThreshold( $x)
Definition: ParserOptions.php:603
ParserOptions\$mDisableContentConversion
$mDisableContentConversion
Whether content conversion should be disabled.
Definition: ParserOptions.php:166
ParserOptions\$mExtraKey
$mExtraKey
Extra key that should be present in the caching key.
Definition: ParserOptions.php:217
ParserOptions\getAllowUnsafeRawHtml
getAllowUnsafeRawHtml()
Definition: ParserOptions.php:480
ParserOptions\$mAllowExternalImagesFrom
$mAllowExternalImagesFrom
If not, any exception?
Definition: ParserOptions.php:48
ParserOptions\getDisableContentConversion
getDisableContentConversion()
Definition: ParserOptions.php:358
ParserOptions\optionUsed
optionUsed( $optionName)
Called when an option is accessed.
Definition: ParserOptions.php:815
ParserOptions\$mInterwikiMagic
$mInterwikiMagic
Interlanguage links are removed and returned in an array.
Definition: ParserOptions.php:38
ParserOptions\setTimestamp
setTimestamp( $x)
Definition: ParserOptions.php:571
ParserOptions\$mEnableImageWhitelist
$mEnableImageWhitelist
If not or it doesn't match, should we check an on-wiki whitelist?
Definition: ParserOptions.php:53
ParserOptions\setCleanSignatures
setCleanSignatures( $x)
Definition: ParserOptions.php:575
ParserOptions\getSpeculativeRevIdCallback
getSpeculativeRevIdCallback()
Definition: ParserOptions.php:342
ParserOptions\newFromContext
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
Definition: ParserOptions.php:726
ParserOptions\getCurrentRevisionCallback
getCurrentRevisionCallback()
Definition: ParserOptions.php:333
ParserOptions\$mMaxIncludeSize
$mMaxIncludeSize
Maximum size of template expansions, in bytes.
Definition: ParserOptions.php:88
ParserOptions\$mMaxPPNodeCount
$mMaxPPNodeCount
Maximum number of nodes touched by PPFrame::expand()
Definition: ParserOptions.php:93
ParserOptions\getTemplateCallback
getTemplateCallback()
Definition: ParserOptions.php:337
ParserOptions\$mTimestamp
$mTimestamp
Timestamp used for {{CURRENTDAY}} etc.
Definition: ParserOptions.php:145
ParserOptions\setRemoveComments
setRemoveComments( $x)
Definition: ParserOptions.php:549
ParserOptions\setInterwikiMagic
setInterwikiMagic( $x)
Definition: ParserOptions.php:484
ParserOptions\$mNumberHeadings
$mNumberHeadings
Automatically number headings?
Definition: ParserOptions.php:176
ParserOptions\setRedirectTarget
setRedirectTarget( $title)
Set the redirect target.
Definition: ParserOptions.php:642
ParserOptions\setExpensiveParserFunctionLimit
setExpensiveParserFunctionLimit( $x)
Definition: ParserOptions.php:545
ParserOptions\getTimestamp
getTimestamp()
Definition: ParserOptions.php:408
ParserOptions\$mEditSection
$mEditSection
Create "edit section" links?
Definition: ParserOptions.php:63
ParserOptions\setMaxPPNodeCount
setMaxPPNodeCount( $x)
Definition: ParserOptions.php:532
ParserOptions\$mExternalLinkTarget
$mExternalLinkTarget
Target attribute for external links.
Definition: ParserOptions.php:150
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
ParserOptions\getCleanSignatures
getCleanSignatures()
Definition: ParserOptions.php:350
ParserOptions\$redirectTarget
Title null $redirectTarget
If the page being parsed is a redirect, this should hold the redirect target.
Definition: ParserOptions.php:244
ParserOptions\setAllowExternalImagesFrom
setAllowExternalImagesFrom( $x)
Definition: ParserOptions.php:492
ParserOptions\matches
matches(ParserOptions $other)
Check if these options match that of another options set.
Definition: ParserOptions.php:780
ParserOptions\enableLimitReport
enableLimitReport( $x=true)
Definition: ParserOptions.php:567
Title
Represents a title within MediaWiki.
Definition: Title.php:39
ParserOptions\__construct
__construct( $user=null, $lang=null)
Constructor.
Definition: ParserOptions.php:669
ParserOptions\getInterwikiMagic
getInterwikiMagic()
Definition: ParserOptions.php:261
ParserOptions\$mUser
User $mUser
Stored user object.
Definition: ParserOptions.php:197
ParserOptions\setInterfaceMessage
setInterfaceMessage( $x)
Definition: ParserOptions.php:520
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
LinkCache\singleton
static singleton()
Get an instance of this class.
Definition: LinkCache.php:67
ParserOptions\getUser
getUser()
Definition: ParserOptions.php:392
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
ParserOptions\$mIsPreview
$mIsPreview
Parsing the page for a "preview" operation?
Definition: ParserOptions.php:202
ParserOptions\getThumbSize
getThumbSize()
Definition: ParserOptions.php:366
StubObject\isRealObject
static isRealObject( $obj)
Returns a bool value whenever $obj is a stub object.
Definition: StubObject.php:82
ParserOptions\getMagicISBNLinks
getMagicISBNLinks()
Definition: ParserOptions.php:457
ParserOptions\setIsPrintable
setIsPrintable( $x)
Definition: ParserOptions.php:619
ParserOptions\getMaxPPNodeCount
getMaxPPNodeCount()
Definition: ParserOptions.php:307
ParserOptions\legacyOptions
static legacyOptions()
Returns the full array of options that would have been used by in 1.16.
Definition: ParserOptions.php:827
$wgRenderHashAppend
$wgRenderHashAppend
Append a configured value to the parser cache and the sitenotice key so that they can be kept separat...
Definition: DefaultSettings.php:2552
ParserOptions\setEditSection
setEditSection( $x)
Definition: ParserOptions.php:504
ParserOptions\$mMagicISBNLinks
$mMagicISBNLinks
Are magic ISBN links enabled?
Definition: ParserOptions.php:222
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:183
ParserOptions\getMaxGeneratedPPNodeCount
getMaxGeneratedPPNodeCount()
Definition: ParserOptions.php:311
ParserOptions\getMaxPPExpandDepth
getMaxPPExpandDepth()
Definition: ParserOptions.php:315
ParserOptions\getEnableLimitReport
getEnableLimitReport()
Definition: ParserOptions.php:346
ParserOptions\getNumberHeadings
getNumberHeadings()
Definition: ParserOptions.php:281
ParserOptions\getMaxTemplateDepth
getMaxTemplateDepth()
Definition: ParserOptions.php:319
ParserOptions\setPreSaveTransform
setPreSaveTransform( $x)
Definition: ParserOptions.php:607
ParserOptions\getEditSection
getEditSection()
Definition: ParserOptions.php:277
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:50
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
ParserOptions\$mCleanSignatures
$mCleanSignatures
Clean up signature texts?
Definition: ParserOptions.php:156
ParserOptions\$mEnableLimitReport
$mEnableLimitReport
Enable limit report in an HTML comment on output.
Definition: ParserOptions.php:140
Language
Internationalisation code.
Definition: Language.php:35
ParserOptions\optionsHash
optionsHash( $forOptions, $title=null)
Generate a hash string with the values set on these ParserOptions for the keys given in the array.
Definition: ParserOptions.php:854
ParserOptions\$mThumbSize
$mThumbSize
Thumb size preferred by the user.
Definition: ParserOptions.php:181
ParserOptions\getAllowExternalImages
getAllowExternalImages()
Definition: ParserOptions.php:265
ParserOptions\newFromUser
static newFromUser( $user)
Get a ParserOptions object from a given user.
Definition: ParserOptions.php:705
ParserOptions\addExtraKey
addExtraKey( $key)
Extra key that should be present in the parser cache key.
Definition: ParserOptions.php:660
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56