X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FServiceWiring.php;h=83847d80ae407a32a3d5001a37259b663bcb9f57;hb=c96b4e13235351b03f2da790cc97de53ff86e4f7;hp=4cd3d851740f793253fd88acc22378ddbf91775f;hpb=2aed14b6867314ef9f08d09cc2dc502f7dddb050;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 4cd3d85174..83847d80ae 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -27,6 +27,13 @@ * For every service that MediaWiki core requires, an instantiator must be defined in * this file. * + * Note that, ideally, all information used to instantiate service objects should come + * from configuration. Information derived from the current request is acceptable, but + * only where there is no feasible alternative. It is preferred that such information + * (like the client IP, the acting user's identity, requested title, etc) be passed to + * the service object's methods as parameters. This makes the flow of information more + * obvious, and makes it easier to understand the behavior of services. + * * @note As of version 1.27, MediaWiki is only beginning to use dependency injection. * The services defined here do not yet fully represent all services used by core, * much of the code still relies on global state for this accessing services. @@ -200,10 +207,7 @@ return [ ); $class = MWLBFactory::getLBFactoryClass( $lbConf ); - $instance = new $class( $lbConf ); - MWLBFactory::setSchemaAliases( $instance, $mainConfig->get( 'DBtype' ) ); - - return $instance; + return new $class( $lbConf ); }, 'EventRelayerGroup' => function ( MediaWikiServices $services ) : EventRelayerGroup { @@ -267,6 +271,8 @@ return [ if ( defined( 'MW_NO_SESSION' ) ) { return $services->getLinkRendererFactory()->create(); } else { + // Normally information from the current request would not be passed in here; + // this is an exception. (See also the class documentation.) return $services->getLinkRendererFactory()->createForUser( RequestContext::getMain()->getUser() ); @@ -784,7 +790,8 @@ return [ $services->getDBLoadBalancer(), $services->getCommentStore(), $services->getActorMigration(), - $services->getWatchedItemStore() + $services->getWatchedItemStore(), + $services->getPermissionManager() ); },