X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=docs%2Finjection.txt;h=2badea98cbf7895a0170ad3418ee79e0593b163e;hb=c3bbadcc8315eb3ff26bf07243a4989f8ec260be;hp=e0466c44a55fbd11da80e942ac3d9af865120c15;hpb=9ee6461287f5d2d6fae719ec62ae6465e0a3809d;p=lhc%2Fweb%2Fwiklou.git diff --git a/docs/injection.txt b/docs/injection.txt index e0466c44a5..2badea98cb 100644 --- a/docs/injection.txt +++ b/docs/injection.txt @@ -60,6 +60,27 @@ MediaWikiServices::getInstance() should ideally be accessed only in "static entry points" such as hook handler functions. See "Migration" below. +== Service Reset == + +Services get their configuration injected, and changes to global +configuration variables will not have any effect on services that were already +instantiated. This would typically be the case for low level services like +the ConfigFactory or the ObjectCacheManager, which are used during extension +registration. To address this issue, Setup.php resets the global service +locator instance by calling MediaWikiServices::resetGlobalInstance() once +configuration and extension registration is complete. + +Note that "unmanaged" legacy services services that manage their own singleton +must not keep references to services managed by MediaWikiServices, to allow a +clean reset. After the global MediaWikiServices instance got reset, any such +references would be stale, and using a stale service will result in an error. + +Services should either have all dependencies injected and be themselves managed +by MediaWikiServices, or they should use the Service Locator pattern, accessing +service instances via the global MediaWikiServices instance state when needed. +This ensures that no stale service references remain after a reset. + + == Configuration == When the default MediaWikiServices instance is created, a Config object is