MediaWiki REL1_37
ConfiguredReadOnlyMode.php
Go to the documentation of this file.
1<?php
2
11 private $reason;
12
14 private $reasonFile;
15
23 public function __construct( $reason, $reasonFile = null ) {
24 $this->reason = $reason;
25 $this->reasonFile = $reasonFile;
26 }
27
33 public function isReadOnly() {
34 return $this->getReason() !== false;
35 }
36
42 public function getReason() {
43 if ( $this->reason !== null ) {
44 return $this->reason;
45 }
46 if ( $this->reasonFile === null ) {
47 return false;
48 }
49 // Try the reason file
50 if ( is_file( $this->reasonFile ) && filesize( $this->reasonFile ) > 0 ) {
51 $this->reason = file_get_contents( $this->reasonFile );
52 }
53 // No need to try the reason file again
54 $this->reasonFile = null;
55 return $this->reason ?? false;
56 }
57
64 public function setReason( $msg ) {
65 $this->reason = $msg;
66 }
67}
A read-only mode service which does not depend on LoadBalancer.
getReason()
Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
__construct( $reason, $reasonFile=null)
setReason( $msg)
Set the read-only mode, which will apply for the remainder of the request or until a service reset.
isReadOnly()
Check whether the wiki is in read-only mode.