44 public function __construct( $domain, array $lockManagerConfigs ) {
47 foreach ( $lockManagerConfigs as $config ) {
48 $config[
'domain'] = $this->domain;
49 if ( !isset( $config[
'name'] ) ) {
50 throw new Exception(
"Cannot register a lock manager with no name." );
52 $name = $config[
'name'];
53 if ( !isset( $config[
'class'] ) ) {
54 throw new Exception(
"Cannot register lock manager `{$name}` with no class." );
56 $class = $config[
'class'];
57 unset( $config[
'class'] );
58 $this->managers[$name] = [
73 public function get( $name ) {
74 if ( !isset( $this->managers[$name] ) ) {
75 throw new Exception(
"No lock manager defined with the name `$name`." );
78 if ( !isset( $this->managers[$name][
'instance'] ) ) {
79 $class = $this->managers[$name][
'class'];
80 '@phan-var string $class';
81 $config = $this->managers[$name][
'config'];
82 $config[
'logger'] = LoggerFactory::getInstance(
'LockManager' );
84 $this->managers[$name][
'instance'] =
new $class( $config );
87 return $this->managers[$name][
'instance'];
98 if ( !isset( $this->managers[$name] ) ) {
99 throw new Exception(
"No lock manager defined with the name `$name`." );
101 $class = $this->managers[$name][
'class'];
103 return [
'class' => $class ] + $this->managers[$name][
'config'];
117 return isset( $this->managers[
'default'] )
118 ? $this->
get(
'default' )
135 return isset( $this->managers[
'default'] )
136 ? $this->
get(
'default' )
137 : $this->
get(
'fsLockManager' );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Class to handle file lock manager registration.
getDefault()
Get the default lock manager configured for the site.
__construct( $domain, array $lockManagerConfigs)
Do not call this directly.
string $domain
domain (usually wiki ID)
config( $name)
Get the config array for a lock manager object with a given name.
getAny()
Get the default lock manager configured for the site or at least some other effective configured lock...
array $managers
Array of (name => ('class' => ..., 'config' => ..., 'instance' => ...))
Simple version of LockManager that only does lock reference counting.