23use Wikimedia\ScopedCallback;
124 [
'Parser',
'statelessFetchRevision' ];
130 [
'Parser',
'statelessFetchTemplate' ];
402 if ( !isset( $this->mDateFormat ) ) {
403 $this->mDateFormat = $this->mUser->getDatePreference();
409 if ( !isset( $this->mTimestamp ) ) {
485 return wfSetVar( $this->mInterwikiMagic, $x );
489 return wfSetVar( $this->mAllowExternalImages, $x );
493 return wfSetVar( $this->mAllowExternalImagesFrom, $x );
497 return wfSetVar( $this->mEnableImageWhitelist, $x );
501 return wfSetVar( $this->mDateFormat, $x );
505 return wfSetVar( $this->mEditSection, $x );
509 return wfSetVar( $this->mNumberHeadings, $x );
513 return wfSetVar( $this->mAllowSpecialInclusion, $x );
517 return wfSetVar( $this->mTidy, $x );
521 return wfSetVar( $this->mInterfaceMessage, $x );
525 return wfSetVar( $this->mTargetLanguage, $x,
true );
529 return wfSetVar( $this->mMaxIncludeSize, $x );
533 return wfSetVar( $this->mMaxPPNodeCount, $x );
537 return wfSetVar( $this->mMaxGeneratedPPNodeCount, $x );
541 return wfSetVar( $this->mMaxTemplateDepth, $x );
546 return wfSetVar( $this->mExpensiveParserFunctionLimit, $x );
550 return wfSetVar( $this->mRemoveComments, $x );
555 return wfSetVar( $this->mCurrentRevisionCallback, $x );
560 return wfSetVar( $this->mSpeculativeRevIdCallback, $x );
564 return wfSetVar( $this->mTemplateCallback, $x );
568 return wfSetVar( $this->mEnableLimitReport, $x );
572 return wfSetVar( $this->mTimestamp, $x );
576 return wfSetVar( $this->mCleanSignatures, $x );
580 return wfSetVar( $this->mExternalLinkTarget, $x );
584 return wfSetVar( $this->mDisableContentConversion, $x );
588 return wfSetVar( $this->mDisableTitleConversion, $x );
592 if ( is_string( $x ) ) {
593 $x = Language::factory( $x );
596 return wfSetVar( $this->mUserLang, $x );
600 return wfSetVar( $this->mThumbSize, $x );
604 return wfSetVar( $this->mStubThreshold, $x );
608 return wfSetVar( $this->mPreSaveTransform, $x );
612 return wfSetVar( $this->mIsPreview, $x );
616 return wfSetVar( $this->mIsSectionPreview, $x );
620 return wfSetVar( $this->mIsPrintable, $x );
629 return wfSetVar( $this->allowUnsafeRawHtml, $x );
643 $this->redirectTarget =
$title;
661 $this->mExtraKey .=
'!' . $key;
670 if (
$user ===
null ) {
678 if (
$lang ===
null ) {
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;
782 $fields = array_keys( get_class_vars( __CLASS__ ) );
783 $fields = array_diff( $fields, [
784 'mEnableLimitReport',
787 foreach ( $fields
as $field ) {
788 if ( !is_object( $this->$field ) && $this->$field !== $other->$field ) {
794 $this->mUserLang->equals( $other->mUserLang ) &&
805 $this->onAccessCallback = $callback;
817 if ( $this->onAccessCallback ) {
818 call_user_func( $this->onAccessCallback, $optionName );
866 if ( in_array(
'stubthreshold', $forOptions ) ) {
872 if ( in_array(
'dateformat', $forOptions ) ) {
876 if ( in_array(
'numberheadings', $forOptions ) ) {
877 $confstr .=
'!' . ( $this->mNumberHeadings ?
'1' :
'' );
882 if ( in_array(
'userlang', $forOptions ) ) {
883 $confstr .=
'!' . $this->mUserLang->getCode();
888 if ( in_array(
'thumbsize', $forOptions ) ) {
896 if ( !is_null(
$title ) ) {
897 $confstr .=
$title->getPageLanguage()->getExtraHashOptions();
909 if ( !in_array(
'editsection', $forOptions ) ) {
911 } elseif ( !$this->mEditSection ) {
912 $confstr .=
'!edit=0';
915 if ( $this->mIsPrintable && in_array(
'printable', $forOptions ) ) {
916 $confstr .=
'!printable=1';
919 if ( $this->mExtraKey !=
'' ) {
925 Hooks::run(
'PageRenderingHash', [ &$confstr, $this->
getUser(), &$forOptions ] );
928 $confstr = str_replace(
' ',
'_', $confstr );
948 if ( $titleToCheck->equals(
$title ) ) {
949 return new Revision( [
950 'page' => $title->getArticleID(),
951 'user_text' => $user->getName(),
952 'user' => $user->getId(),
953 'parent_id' => $title->getLatestRevID(),
955 'content' => $content
958 return call_user_func( $oldCallback, $titleToCheck, $parser );
965 function ( $titleToCheck, &$exists )
use (
$title ) {
966 if ( $titleToCheck->equals(
$title ) ) {
972 LinkCache::singleton()->clearBadLink(
$title->getPrefixedDBkey() );
973 return new ScopedCallback(
function ()
use (
$title, $key ) {
975 unset(
$wgHooks[
'TitleExists'][$key] );
976 LinkCache::singleton()->clearLink(
$title );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgMaxTemplateDepth
Maximum recursion depth for templates within templates.
$wgMaxPPNodeCount
A complexity limit on template expansion: the maximum number of nodes visited by PPFrame::expand()
$wgMaxArticleSize
Maximum article size in kilobytes.
$wgMaxGeneratedPPNodeCount
A complexity limit on template expansion: the maximum number of elements generated by Preprocessor::p...
$wgEnableImageWhitelist
If $wgAllowExternalImages is false, you can allow an on-wiki whitelist of regular expression fragment...
$wgCleanSignatures
If true, removes (by substituting) templates in signatures.
$wgRenderHashAppend
Append a configured value to the parser cache and the sitenotice key so that they can be kept separat...
$wgDisableLangConversion
Whether to enable language variant conversion.
$wgAllowSpecialInclusion
Allow special page inclusions such as {{Special:Allpages}}.
$wgAllowExternalImagesFrom
If the above is false, you can specify an exception here.
$wgInterwikiMagic
Treat language links as magic connectors, not inline links.
$wgAllowExternalImages
Whether to allow inline image pointing to other websites.
$wgEnableMagicLinks
Enable the magic links feature of automatically turning ISBN xxx, PMID xxx, RFC xxx into links.
$wgExternalLinkTarget
Set a default target for external links, e.g.
$wgExpensiveParserFunctionLimit
Maximum number of calls per parse to expensive parser functions such as PAGESINCATEGORY.
$wgDisableTitleConversion
Whether to enable language variant conversion for links.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
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...
Internationalisation code.
Set options of the Parser.
setAllowExternalImagesFrom( $x)
disableTitleConversion( $x=true)
$mEnableImageWhitelist
If not or it doesn't match, should we check an on-wiki whitelist?
$mMaxTemplateDepth
Maximum recursion depth for templates within templates.
$mAllowExternalImages
Allow external images inline?
$mIsPrintable
Parsing the printable version of the page?
getRedirectTarget()
Get the previously-set redirect target.
$mMaxPPNodeCount
Maximum number of nodes touched by PPFrame::expand()
setAllowUnsafeRawHtml( $x)
$mInterwikiMagic
Interlanguage links are removed and returned in an array.
getSpeculativeRevIdCallback()
enableLimitReport( $x=true)
$mMaxGeneratedPPNodeCount
Maximum number of nodes generated by Preprocessor::preprocessToObj()
callable $mCurrentRevisionCallback
Callback for current revision fetching; first argument to call_user_func().
$mDisableTitleConversion
Whether title conversion should be disabled.
matches(ParserOptions $other)
Check if these options match that of another options set.
$mEnableLimitReport
Enable limit report in an HTML comment on output.
$mMaxPPExpandDepth
Maximum recursion depth in PPFrame::expand()
$mPreSaveTransform
Transform wiki markup when saving the page?
$mRemoveComments
Remove HTML comments.
$mMagicISBNLinks
Are magic ISBN links enabled?
setAllowExternalImages( $x)
getUserLangObj()
Get the user language used by the parser for this page and split the parser cache.
callable null $mSpeculativeRevIdCallback
Callback to generate a guess for {{REVISIONID}}.
$mExternalLinkTarget
Target attribute for external links.
$mInterfaceMessage
Which lang to call for PLURAL and GRAMMAR.
getEnableImageWhitelist()
$mAllowExternalImagesFrom
If not, any exception?
getAllowExternalImagesFrom()
$onAccessCallback
Function to be called when an option is accessed.
$mNumberHeadings
Automatically number headings?
getCurrentRevisionCallback()
$mStubThreshold
Maximum article size of an article to be marked as "stub".
$mExpensiveParserFunctionLimit
Maximum number of calls per parse to expensive parser functions.
getDisableContentConversion()
$mMagicRFCLinks
Are magic RFC links enabled?
getExpensiveParserFunctionLimit()
$mTimestamp
Timestamp used for {{CURRENTDAY}} etc.
setCurrentRevisionCallback( $x)
$mTargetLanguage
Overrides $mInterfaceMessage with arbitrary language.
$mEditSection
Create "edit section" links?
callable $mTemplateCallback
Callback for template fetching; first argument to call_user_func().
setEnableImageWhitelist( $x)
$mThumbSize
Thumb size preferred by the user.
$mIsPreview
Parsing the page for a "preview" operation?
User $mUser
Stored user object.
optionUsed( $optionName)
Called when an option is accessed.
setRedirectTarget( $title)
Set the redirect target.
disableContentConversion( $x=true)
initialiseFromUser( $user, $lang)
Get user options.
optionsHash( $forOptions, $title=null)
Generate a hash string with the values set on these ParserOptions for the keys given in the array.
$mExtraKey
Extra key that should be present in the caching key.
setAllowSpecialInclusion( $x)
$mIsSectionPreview
Parsing the page for a "preview" operation on a single section?
$mDisableContentConversion
Whether content conversion should be disabled.
getAllowSpecialInclusion()
setupFakeRevision( $title, $content, $user)
Sets a hook to force that a page exists, and sets a current revision callback to return a revision wi...
static legacyOptions()
Returns the full array of options that would have been used by in 1.16.
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
$mTidy
Use tidy to cleanup output HTML?
registerWatcher( $callback)
Registers a callback for tracking which ParserOptions which are used.
addExtraKey( $key)
Extra key that should be present in the parser cache key.
static newFromAnon()
Get a ParserOptions object for an anonymous user.
static newFromUser( $user)
Get a ParserOptions object from a given user.
getUserLang()
Same as getUserLangObj() but returns a string instead.
setExternalLinkTarget( $x)
getMaxGeneratedPPNodeCount()
Title null $redirectTarget
If the page being parsed is a redirect, this should hold the redirect target.
boolean $allowUnsafeRawHtml
If the wiki is configured to allow raw html ($wgRawHtml = true) is it allowed in the specific case of...
setMaxGeneratedPPNodeCount( $x)
$mUserLang
Language object of the User language.
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
$mCleanSignatures
Clean up signature texts?
__construct( $user=null, $lang=null)
Constructor.
$mDateFormat
Date format index.
setSpeculativeRevIdCallback( $x)
getDisableTitleConversion()
$mMaxIncludeSize
Maximum size of template expansions, in bytes.
$mMagicPMIDLinks
Are magic PMID links enabled?
$mAllowSpecialInclusion
Allow inclusion of special pages?
setExpensiveParserFunctionLimit( $x)
static isRealObject( $obj)
Returns a bool value whenever $obj is a stub object.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
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 local content language as $wgContLang
when a variable name is used in a it is silently declared as a new local masking the global
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
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
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
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 local account $user
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead $parser
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
$wgHooks['ArticleShow'][]
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
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang