reason = $reason; $this->reasonFile = $reasonFile; } /** * Check whether the site is in read-only mode. * * @return bool */ public function isReadOnly(): bool { return $this->getReason() !== false; } /** * @return string|false String when in read-only mode; false otherwise */ public function getReason() { if ( $this->reason !== null ) { return $this->reason; } if ( $this->reasonFile === null ) { return false; } // Try the reason file if ( is_file( $this->reasonFile ) && filesize( $this->reasonFile ) > 0 ) { $this->reason = file_get_contents( $this->reasonFile ); } // No need to try the reason file again $this->reasonFile = null; return $this->reason ?? false; } /** * Set the read-only mode, which will apply for the remainder of the * request or until a service reset. * * @param string|false|null $msg */ public function setReason( $msg ): void { $this->reason = $msg; } } class_alias( ConfiguredReadOnlyMode::class, 'ConfiguredReadOnlyMode' );