54 if ( !isset( self::$instances[
$domain] ) ) {
56 self::$instances[
$domain]->initFromGlobals();
59 return self::$instances[
$domain];
66 self::$instances = [];
84 protected function register(
array $configs ) {
85 foreach ( $configs as $config ) {
87 if ( !isset( $config[
'name'] ) ) {
88 throw new Exception(
"Cannot register a lock manager with no name." );
90 $name = $config[
'name'];
91 if ( !isset( $config[
'class'] ) ) {
92 throw new Exception(
"Cannot register lock manager `{$name}` with no class." );
94 $class = $config[
'class'];
95 unset( $config[
'class'] );
96 $this->managers[
$name] = [
112 if ( !isset( $this->managers[$name] ) ) {
113 throw new Exception(
"No lock manager defined with the name `$name`." );
116 if ( !isset( $this->managers[$name][
'instance'] ) ) {
117 $class = $this->managers[
$name][
'class'];
118 $config = $this->managers[
$name][
'config'];
119 if ( $class === DBLockManager::class ) {
120 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
121 $lb = $lbFactory->newMainLB( $config[
'domain'] );
122 $dbw = $lb->getLazyConnectionRef(
DB_MASTER, [], $config[
'domain'] );
124 $config[
'dbServers'][
'localDBMaster'] = $dbw;
125 $config[
'srvCache'] = ObjectCache::getLocalServerInstance(
'hash' );
127 $config[
'logger'] = LoggerFactory::getInstance(
'LockManager' );
129 $this->managers[
$name][
'instance'] =
new $class( $config );
132 return $this->managers[
$name][
'instance'];
143 if ( !isset( $this->managers[$name] ) ) {
144 throw new Exception(
"No lock manager defined with the name `$name`." );
146 $class = $this->managers[
$name][
'class'];
148 return [
'class' => $class ] + $this->managers[
$name][
'config'];
158 return isset( $this->managers[
'default'] )
159 ? $this->
get(
'default' )
172 return isset( $this->managers[
'default'] )
173 ? $this->
get(
'default' )
174 : $this->
get(
'fsLockManager' );
$wgLockManagers
Array of configuration arrays for each lock manager.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Class to handle file lock manager registration.
getDefault()
Get the default lock manager configured for the site.
config( $name)
Get the config array for a lock manager object with a given name.
static LockManagerGroup[] $instances
(domain => LockManagerGroup)
initFromGlobals()
Register lock managers from the global variables.
getAny()
Get the default lock manager configured for the site or at least some other effective configured lock...
static singleton( $domain=false)
static destroySingletons()
Destroy the singleton instances.
array $managers
Array of (name => ('class' => ..., 'config' => ..., 'instance' => ...))
Simple version of LockManager that does nothing.
Allows to change the fields on the form that will be generated $name
processing should stop and the error should be shown to the user * false
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))