MediaWiki  master
ExtensionRegistry Class Reference

The Registry loads JSON files, and uses a Processor to extract information from them. More...

Collaboration diagram for ExtensionRegistry:

Public Member Functions

 clearQueue ()
 Clear the current load queue. More...
 
 finish ()
 After this is called, no more extensions can be loaded. More...
 
 getAllThings ()
 Get credits information about all installed extensions and skins. More...
 
 getAttribute ( $name)
 
 getQueue ()
 Get the current load queue. More...
 
 isLoaded ( $name, $constraint=' *')
 Whether a thing has been loaded. More...
 
 loadFromQueue ()
 
 queue ( $path)
 
 readFromQueue (array $queue)
 Process a queue of extensions and return their extracted data. More...
 
 setAttributeForTest ( $name, array $value)
 Force override the value of an attribute during tests. More...
 
 setCache (BagOStuff $cache)
 Set the cache to use for extension info. More...
 
 setCheckDevRequires ( $check)
 
 setLoadTestClassesAndNamespaces ( $load)
 Controls if classes and namespaces defined under the keys TestAutoloadClasses and TestAutoloadNamespaces should be added to the autoloader. More...
 

Static Public Member Functions

static getInstance ()
 

Public Attributes

const MANIFEST_VERSION = 2
 Version of the highest supported manifest version Note: Update MANIFEST_VERSION_MW_VERSION when changing this. More...
 
const MANIFEST_VERSION_MW_VERSION = '>= 1.29.0'
 MediaWiki version constraint representing what the current highest MANIFEST_VERSION is supported in. More...
 
const MEDIAWIKI_CORE = 'MediaWiki'
 "requires" key that applies to MediaWiki core More...
 
const MERGE_STRATEGY = '_merge_strategy'
 Special key that defines the merge strategy. More...
 
const OLDEST_MANIFEST_VERSION = 1
 Version of the oldest supported manifest version. More...
 

Protected Member Functions

 exportExtractedData (array $info)
 
 getLazyLoadedAttribute ( $name)
 Get an attribute value that isn't cached by reading each extension.json file again. More...
 
 saveToCache (BagOStuff $cache, array $data)
 Save data in the cache. More...
 

Static Protected Member Functions

static processAutoLoader ( $dir, array $files)
 Fully expand autoloader paths. More...
 

Protected Attributes

array $attributes = []
 Items in the JSON file that aren't being set as globals. More...
 
bool $checkDev = false
 Whether to check dev-requires. More...
 
array $lazyAttributes = []
 Lazy-loaded attributes. More...
 
bool $loadTestClassesAndNamespaces = false
 Whether test classes and namespaces should be added to the auto loader. More...
 
int[] $queued = []
 List of paths that should be loaded. More...
 
array $testAttributes = []
 Attributes for testing. More...
 

Private Member Functions

 buildVersionChecker ()
 Queries information about the software environment and constructs an appropriate version checker. More...
 
 getAbilities ()
 Get the list of abilities and their values. More...
 
 getCache ()
 
 getVaryHash ()
 Get the cache varying hash. More...
 
 invalidateProcessCache ()
 Invalidate the cache of the vary hash and the lazy options. More...
 
 makeCacheKey (BagOStuff $cache, $component,... $extra)
 

Private Attributes

BagOStuff $cache = null
 
bool $finished = false
 Whether we are done loading things. More...
 
array[] $loaded = []
 Array of loaded things, keyed by name, values are credits information. More...
 
string null $varyHash
 The hash of cache-varying options, lazy-initialised. More...
 
const CACHE_EXPIRY = 60 * 60 * 24
 
const CACHE_VERSION = 8
 Bump whenever the registration cache needs resetting. More...
 
const LAZY_LOADED_ATTRIBUTES
 Attributes that should be lazy-loaded. More...
 

Static Private Attributes

static ExtensionRegistry $instance
 

Detailed Description

The Registry loads JSON files, and uses a Processor to extract information from them.

It also registers classes with the autoloader.

Since
1.25

Definition at line 15 of file ExtensionRegistry.php.

Member Function Documentation

◆ buildVersionChecker()

ExtensionRegistry::buildVersionChecker ( )
private

Queries information about the software environment and constructs an appropriate version checker.

Returns
VersionChecker

Definition at line 356 of file ExtensionRegistry.php.

References MW_VERSION.

◆ clearQueue()

ExtensionRegistry::clearQueue ( )

Clear the current load queue.

Not intended to be used outside of the installer.

Definition at line 327 of file ExtensionRegistry.php.

◆ exportExtractedData()

ExtensionRegistry::exportExtractedData ( array  $info)
protected

Definition at line 438 of file ExtensionRegistry.php.

References wfArrayPlus2d().

◆ finish()

ExtensionRegistry::finish ( )

After this is called, no more extensions can be loaded.

Since
1.29

Definition at line 337 of file ExtensionRegistry.php.

◆ getAbilities()

ExtensionRegistry::getAbilities ( )
private

Get the list of abilities and their values.

Returns
bool[]

Definition at line 345 of file ExtensionRegistry.php.

◆ getAllThings()

ExtensionRegistry::getAllThings ( )

Get credits information about all installed extensions and skins.

Returns
array[] Keyed by component name.

Definition at line 636 of file ExtensionRegistry.php.

◆ getAttribute()

ExtensionRegistry::getAttribute (   $name)
Parameters
string$name
Returns
array

Definition at line 558 of file ExtensionRegistry.php.

◆ getCache()

ExtensionRegistry::getCache ( )
private

Definition at line 207 of file ExtensionRegistry.php.

References ObjectCache\makeLocalServerCache().

◆ getInstance()

◆ getLazyLoadedAttribute()

ExtensionRegistry::getLazyLoadedAttribute (   $name)
protected

Get an attribute value that isn't cached by reading each extension.json file again.

Parameters
string$name
Returns
array

Definition at line 576 of file ExtensionRegistry.php.

References $cache.

◆ getQueue()

ExtensionRegistry::getQueue ( )

Get the current load queue.

Not intended to be used outside of the installer.

Returns
int[] Map of extension.json files' modification timestamps keyed by absolute path

Definition at line 319 of file ExtensionRegistry.php.

◆ getVaryHash()

ExtensionRegistry::getVaryHash ( )
private

Get the cache varying hash.

Returns
string

Definition at line 231 of file ExtensionRegistry.php.

References MW_VERSION.

◆ invalidateProcessCache()

ExtensionRegistry::invalidateProcessCache ( )
private

Invalidate the cache of the vary hash and the lazy options.

Definition at line 250 of file ExtensionRegistry.php.

◆ isLoaded()

ExtensionRegistry::isLoaded (   $name,
  $constraint = '*' 
)

Whether a thing has been loaded.

Parameters
string$name
string$constraintThe required version constraint for this dependency
Exceptions
LogicExceptionif a specific constraint is asked for, but the extension isn't versioned
Returns
bool

Definition at line 539 of file ExtensionRegistry.php.

◆ loadFromQueue()

ExtensionRegistry::loadFromQueue ( )
Exceptions
MWExceptionIf the queue is already marked as finished (no further things should be loaded then).

Definition at line 259 of file ExtensionRegistry.php.

References $cache.

◆ makeCacheKey()

ExtensionRegistry::makeCacheKey ( BagOStuff  $cache,
  $component,
  $extra 
)
private

Definition at line 217 of file ExtensionRegistry.php.

References $cache.

◆ processAutoLoader()

static ExtensionRegistry::processAutoLoader (   $dir,
array  $files 
)
staticprotected

Fully expand autoloader paths.

Parameters
string$dir
string[]$files
Returns
array

Definition at line 647 of file ExtensionRegistry.php.

References $file.

◆ queue()

ExtensionRegistry::queue (   $path)
Parameters
string$pathAbsolute path to the JSON file

Definition at line 189 of file ExtensionRegistry.php.

References $path, and $wgExtensionInfoMTime.

◆ readFromQueue()

ExtensionRegistry::readFromQueue ( array  $queue)

Process a queue of extensions and return their extracted data.

Access: internal
since 1.39. Extensions should use ExtensionProcessor instead.
Parameters
int[]$queuekeys are filenames, values are ignored
Returns
array extracted info
Exceptions
Exception
ExtensionDependencyError

Definition at line 382 of file ExtensionRegistry.php.

References $path, $queue, and wfDeprecatedMsg().

◆ saveToCache()

ExtensionRegistry::saveToCache ( BagOStuff  $cache,
array  $data 
)
protected

Save data in the cache.

Parameters
BagOStuff$cache
array$data

Definition at line 288 of file ExtensionRegistry.php.

References $cache, and $wgDevelopmentWarnings.

◆ setAttributeForTest()

ExtensionRegistry::setAttributeForTest (   $name,
array  $value 
)

Force override the value of an attribute during tests.

Parameters
string$nameName of attribute to override
array$valueValue to set
Returns
ScopedCallback to reset
Since
1.33

Definition at line 616 of file ExtensionRegistry.php.

◆ setCache()

ExtensionRegistry::setCache ( BagOStuff  $cache)

Set the cache to use for extension info.

Intended for use during testing.

Access: internal
Parameters
BagOStuff$cache

Definition at line 162 of file ExtensionRegistry.php.

◆ setCheckDevRequires()

ExtensionRegistry::setCheckDevRequires (   $check)
Since
1.34
Parameters
bool$check

Definition at line 170 of file ExtensionRegistry.php.

◆ setLoadTestClassesAndNamespaces()

ExtensionRegistry::setLoadTestClassesAndNamespaces (   $load)

Controls if classes and namespaces defined under the keys TestAutoloadClasses and TestAutoloadNamespaces should be added to the autoloader.

Since
1.35
Parameters
bool$load

Definition at line 182 of file ExtensionRegistry.php.

Member Data Documentation

◆ $attributes

array ExtensionRegistry::$attributes = []
protected

Items in the JSON file that aren't being set as globals.

Definition at line 95 of file ExtensionRegistry.php.

◆ $cache

BagOStuff ExtensionRegistry::$cache = null
private

Definition at line 140 of file ExtensionRegistry.php.

◆ $checkDev

bool ExtensionRegistry::$checkDev = false
protected

Whether to check dev-requires.

Definition at line 123 of file ExtensionRegistry.php.

◆ $finished

bool ExtensionRegistry::$finished = false
private

Whether we are done loading things.

Definition at line 87 of file ExtensionRegistry.php.

◆ $instance

ExtensionRegistry ExtensionRegistry::$instance
staticprivate

Definition at line 135 of file ExtensionRegistry.php.

Referenced by getInstance().

◆ $lazyAttributes

array ExtensionRegistry::$lazyAttributes = []
protected

Lazy-loaded attributes.

Definition at line 109 of file ExtensionRegistry.php.

◆ $loaded

array [] ExtensionRegistry::$loaded = []
private

Array of loaded things, keyed by name, values are credits information.

The keys that the credit info arrays may have is defined by ExtensionProcessor::CREDIT_ATTRIBS (plus a 'path' key that points to the skin or extension JSON file).

This info may be accessed via ExtensionRegistry::getAllThings.

Definition at line 73 of file ExtensionRegistry.php.

◆ $loadTestClassesAndNamespaces

bool ExtensionRegistry::$loadTestClassesAndNamespaces = false
protected

Whether test classes and namespaces should be added to the auto loader.

Definition at line 130 of file ExtensionRegistry.php.

◆ $queued

int [] ExtensionRegistry::$queued = []
protected

List of paths that should be loaded.

Definition at line 80 of file ExtensionRegistry.php.

◆ $testAttributes

array ExtensionRegistry::$testAttributes = []
protected

Attributes for testing.

Definition at line 102 of file ExtensionRegistry.php.

◆ $varyHash

string null ExtensionRegistry::$varyHash
private

The hash of cache-varying options, lazy-initialised.

Definition at line 116 of file ExtensionRegistry.php.

◆ CACHE_EXPIRY

const ExtensionRegistry::CACHE_EXPIRY = 60 * 60 * 24
private

Definition at line 44 of file ExtensionRegistry.php.

◆ CACHE_VERSION

const ExtensionRegistry::CACHE_VERSION = 8
private

Bump whenever the registration cache needs resetting.

Definition at line 42 of file ExtensionRegistry.php.

◆ LAZY_LOADED_ATTRIBUTES

const ExtensionRegistry::LAZY_LOADED_ATTRIBUTES
private
Initial value:
= [
'TrackingCategories',
'QUnitTestModules',
'SkinLessImportPaths',
]

Attributes that should be lazy-loaded.

Definition at line 56 of file ExtensionRegistry.php.

◆ MANIFEST_VERSION

const ExtensionRegistry::MANIFEST_VERSION = 2

Version of the highest supported manifest version Note: Update MANIFEST_VERSION_MW_VERSION when changing this.

Definition at line 26 of file ExtensionRegistry.php.

Referenced by ConvertExtensionToRegistration\execute(), UpdateExtensionJsonSchema\execute(), and ExtensionJsonValidator\validate().

◆ MANIFEST_VERSION_MW_VERSION

const ExtensionRegistry::MANIFEST_VERSION_MW_VERSION = '>= 1.29.0'

MediaWiki version constraint representing what the current highest MANIFEST_VERSION is supported in.

Definition at line 32 of file ExtensionRegistry.php.

Referenced by ConvertExtensionToRegistration\execute(), and UpdateExtensionJsonSchema\updateRequiredMwVersion().

◆ MEDIAWIKI_CORE

const ExtensionRegistry::MEDIAWIKI_CORE = 'MediaWiki'

◆ MERGE_STRATEGY

const ExtensionRegistry::MERGE_STRATEGY = '_merge_strategy'

Special key that defines the merge strategy.

Since
1.26

Definition at line 51 of file ExtensionRegistry.php.

Referenced by ExtensionProcessor\extractConfig2(), ExtensionProcessor\getExtractedInfo(), and UpdateExtensionJsonSchema\updateTo2().

◆ OLDEST_MANIFEST_VERSION

const ExtensionRegistry::OLDEST_MANIFEST_VERSION = 1

Version of the oldest supported manifest version.

Definition at line 37 of file ExtensionRegistry.php.

Referenced by ExtensionJsonValidator\validate().


The documentation for this class was generated from the following file: