This is a tracking task for various miscellaneous tasks relating to MediaWiki PHP set-up code. It will be resolved when the sub tasks added during Spring 2018, are resolved.
Goals:
- Reduce maintenance overhead by addressing Technical-Debt.
- Make the code easier to contribute to by simplifying it and improving its documentation.
- Improve startup performance, especially for stateless requests (api.php, load.php) and read-only routes.
Sub tasks:
- Understand current initialisation logic.
- Understand current initialisation requirements.
- Understand current initialisation performance. – T233886#5532734
- Improve and simplify initialisation performance in a way that continues to satisfy current requirements.
Current code (Feb 2018)
From: /w/{entrypoint}.php:
- include PHPVersionCheck
- PHPVersionCheck::checkRequiredPHPVersion()
- PHPVersionCheck::checkVendorExistence()
- PHPVersionCheck::checkExtensionExistence()
- include WebStart
WebStart: assert php-env mbstring.func_overload- WebStart: emit header X-Content-Type-Options: nosniff
WebStart: global set $wgRequestTimeWebStart: global unset $IP- WebStart: define MEDIAWIKI
- WebStart: global set $IP
- WebStart: include Setup
Setup: global set $wgProfilerSetup: include StartProfiler (conditional)- Setup: include AutoLoader
- Setup: include Defines
- Setup: include DefaultSettings
- Setup: include GlobalFunctions
- Setup: include vendor/autoload (conditional)
- Setup: assert vendor
- Setup: php-env add HeaderCallback
- Setup: include LocalSettings
WebStart: include OutputHandler (conditional)- WebStart: register ob_start wfOutputHandler (conditional)
OutputHandler: handle ValidateAllHtml (conditional)- OutputHandler: handle compression (conditional)
- OutputHandler: emit header Content-Length (conditional)
- WebStart: include Setup [continued]
Setup: process Profiler (implicit)- Setup: process ExtensionRegistry
- Setup: php-env ensure mb_internal_encoding( .. )
- Setup: php-env ensure LC_ALL=..
- Setup: process mw-config phase1/2 (DefaultSettings, LocalSettings, shortcuts, derivatives, deprecations, normalising)
- Setup: process MWDebug
- Setup: process MediaWikiServices
- Setup: define MW_SERVICE_BOOTSTRAP_COMPLETE
- Setup: php-env add MWExceptionHandler
Setup: include UtfNormalUtilSetup: Setup: assert validity of $wgArticlePath- Setup: process mw-config phase2/2 (more defaults, shortcuts, normalising)
- Setup: php-env ensure wfMemoryLimit
- Setup: process singletons phase1/3 (wgMemc, messageMemc, parserMemc)
- Setup: process hooks for SetupAfterCache
- Setup: process singletons phase2/3 (wgContLang, wgAuth)
- Setup: php-env add MediaWiki\Session
- Setup: process singletons phase3/3 (wgUser, wgLang, wgOut, wgParser, wgTitle)
- Setup: process hooks for wgExtensionFunctions
- Setup: process Pingback
Issues
1: WebStart: assert php-env mbstring.func_overload
Unsure why this is in WebStart instead of Setup. Is it fine to apply this to CLI?
3: WebStart: global set $wgRequestTime
Deprecated since MediaWiki 1.25.
- Remove usage: https://gerrit.wikimedia.org/r/304465 / 06ba5ca383
- Actual removal: https://gerrit.wikimedia.org/r/427274 / 6fe856c4bd79
4: WebStart: global unset $IP
This sanity unset() seems redundant. It's unconditionally re-assigned two lines down. Can it be removed?
7A: Setup: global set $wgProfiler
7B: Setup: include StartProfiler (conditional)
Seems like this could be folded into DefaultSettings.php, with the StartProfiler include moved down a few lines. Should be safe given we don't reference it after DefaultSettings and LocalSettings load.
8: WebStart: include OutputHandler (conditional)
This (conditionally) includes a file that creates additional global functions. Should be safe to merge with GlobalFunctions and just load always. Alternatively, given this is after the autoloader, perhaps better as a class. That way also has the benefit of 1) keeping the private functions really private and 2) still only loading the file when needed.
9A: OutputHandler: handle ValidateAllHtml (conditional)
See also T191670.
10A: Setup: process Profiler
10J: Setup: include UtfNormalUtil
10K: Setup: assert validity of $wgArticlePath
10L: Setup: process mw-config phase2 (more defaults, shortcuts, normalising)
Unsure why this is separate from the earlier "mw-config process" section.
- Patch: TODO
10N: Setup: process singletons phase1/3 (wgMemc, messageMemc, parserMemc)
- Removed $parserMemc in https://gerrit.wikimedia.org/r/436528 / a930bf7d7.
- Follow-up for $wgMemc and $messageMemc: T160813, T243175
Related follow-up work:
- T228895: 3% of load.php spent creating DBLoadBalancerFactory in WebStart.php
- T187154: Performance regression from Apcu/ExtensionRegistry::loadFromQueue on PHP7
- T245940: Hard-deprecate and remove $wgContLang
- T160813: Deprecate and remove $wgMemc in MediaWiki Core and bundled extensions
- T243175: Deprecate and remove $messageMemc