MediaWiki  1.34.0
ReadOnlyMode.php
Go to the documentation of this file.
1 <?php
2 
4 
11 class ReadOnlyMode {
14 
16  private $loadBalancer;
17 
19  $this->configuredReadOnly = $cro;
20  $this->loadBalancer = $loadBalancer;
21  }
22 
28  public function isReadOnly() {
29  return $this->getReason() !== false;
30  }
31 
40  public function getReason() {
41  $reason = $this->configuredReadOnly->getReason();
42  if ( $reason !== false ) {
43  return $reason;
44  }
45  $reason = $this->loadBalancer->getReadOnlyReason();
46  if ( $reason !== false && $reason !== null ) {
47  return $reason;
48  }
49  return false;
50  }
51 
58  public function setReason( $msg ) {
59  $this->configuredReadOnly->setReason( $msg );
60  }
61 }
ReadOnlyMode\isReadOnly
isReadOnly()
Check whether the wiki is in read-only mode.
Definition: ReadOnlyMode.php:28
ReadOnlyMode\__construct
__construct(ConfiguredReadOnlyMode $cro, ILoadBalancer $loadBalancer)
Definition: ReadOnlyMode.php:18
ReadOnlyMode
A service class for fetching the wiki's current read-only mode.
Definition: ReadOnlyMode.php:11
ConfiguredReadOnlyMode
A read-only mode service which does not depend on LoadBalancer.
Definition: ConfiguredReadOnlyMode.php:9
ReadOnlyMode\setReason
setReason( $msg)
Set the read-only mode, which will apply for the remainder of the request or until a service reset.
Definition: ReadOnlyMode.php:58
ReadOnlyMode\getReason
getReason()
Check if the site is in read-only mode and return the message if so.
Definition: ReadOnlyMode.php:40
ReadOnlyMode\$configuredReadOnly
ConfiguredReadOnlyMode $configuredReadOnly
Definition: ReadOnlyMode.php:13
ReadOnlyMode\$loadBalancer
ILoadBalancer $loadBalancer
Definition: ReadOnlyMode.php:16
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81