MediaWiki REL1_35
ReadOnlyMode Class Reference

A service class for fetching the wiki's current read-only mode. More...

Collaboration diagram for ReadOnlyMode:

Public Member Functions

 __construct (ConfiguredReadOnlyMode $cro, ILoadBalancer $loadBalancer)
 
 getReason ()
 Check if the site is in read-only mode and return the message if so.
 
 isReadOnly ()
 Check whether the wiki is in read-only mode.
 
 setReason ( $msg)
 Set the read-only mode, which will apply for the remainder of the request or until a service reset.
 

Private Attributes

ConfiguredReadOnlyMode $configuredReadOnly
 
ILoadBalancer $loadBalancer
 

Detailed Description

A service class for fetching the wiki's current read-only mode.

To obtain an instance, use MediaWikiServices::getInstance()->getReadOnlyMode().

Since
1.29

Definition at line 11 of file ReadOnlyMode.php.

Constructor & Destructor Documentation

◆ __construct()

ReadOnlyMode::__construct ( ConfiguredReadOnlyMode  $cro,
ILoadBalancer  $loadBalancer 
)

Definition at line 18 of file ReadOnlyMode.php.

Member Function Documentation

◆ getReason()

ReadOnlyMode::getReason ( )

Check if the site is in read-only mode and return the message if so.

This checks the configuration and registered DB load balancers for read-only mode. This may result in DB connection being made.

Returns
string|bool String when in read-only mode; false otherwise

Definition at line 40 of file ReadOnlyMode.php.

Referenced by isReadOnly().

◆ isReadOnly()

ReadOnlyMode::isReadOnly ( )

Check whether the wiki is in read-only mode.

Returns
bool

Definition at line 28 of file ReadOnlyMode.php.

References getReason().

◆ setReason()

ReadOnlyMode::setReason (   $msg)

Set the read-only mode, which will apply for the remainder of the request or until a service reset.

Parameters
string | null$msg

Definition at line 58 of file ReadOnlyMode.php.

Member Data Documentation

◆ $configuredReadOnly

ConfiguredReadOnlyMode ReadOnlyMode::$configuredReadOnly
private

Definition at line 13 of file ReadOnlyMode.php.

◆ $loadBalancer

ILoadBalancer ReadOnlyMode::$loadBalancer
private

Definition at line 16 of file ReadOnlyMode.php.


The documentation for this class was generated from the following file: