Manual:Extension registration/Architecture

This page documents the architecture of the new extension registration system introduced in MediaWiki 1.25. Note that generally wherever the term "extension" is used, "skin" can also be used interchangeably.

ExtensionRegistry
The ExtensionRegistry is a singleton that maintains state of the current load queue and what extensions have already been loaded.

LocalSettings.php will call  (or  ), adding the extension to the load queue. At the beginning of Setup.php, the load queue will be read, and the cache (APCu) will be checked to see if we can use it. If there is a cache miss, each extension.json file will be read individually, and the result will be combined into a single array. The array is then cached as one, so future reads will just need to read one key for any number of extensions. The cache is based on the modified time of all the individual files plus their file paths.

Based on what was read, the registry then sets various values into the global namespace.

Public functions:
 * getInstance - static method to return the singleton instance
 * queue - Add a file to the load queue
 * loadFromQueue - Read the load queue and load those extensions
 * load - Load a specific file and cache it on its own
 * readFromQueue - Public function to get structured data out of extension.json files, for uses like the installer
 * isLoaded - Check whether a specific extension has been loaded
 * getAttribute - See Manual:Extension_registration
 * getAllThings - Bulk get credits information about all loaded extensions, useful for things like Special:Version

When setting global variables, we try for O(1) performance:

The first case is O(1) since we can just do a variable assignment, while the latter is more expensive due to requiring an array_merge. By making initial arrays empty like was done for $wgMessagesDirs in 177385 will provide a performance benefit.

ExtensionProcessor
The ExtensionProcessor is responsible for reading the extension.json files and returning structured data based on that. It does not modify global state in any way.