Addshore has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370219 )

Change subject: Split ConfiguredReadOnlyMode into own file
......................................................................

Split ConfiguredReadOnlyMode into own file

Change-Id: I7c12a571bb5ce76c132a738b48b2b82d763a8860
---
M autoload.php
A includes/ConfiguredReadOnlyMode.php
M includes/ReadOnlyMode.php
3 files changed, 74 insertions(+), 73 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/19/370219/1

diff --git a/autoload.php b/autoload.php
index d44a305..508e75b 100644
--- a/autoload.php
+++ b/autoload.php
@@ -291,7 +291,7 @@
        'Config' => __DIR__ . '/includes/config/Config.php',
        'ConfigException' => __DIR__ . '/includes/config/ConfigException.php',
        'ConfigFactory' => __DIR__ . '/includes/config/ConfigFactory.php',
-       'ConfiguredReadOnlyMode' => __DIR__ . '/includes/ReadOnlyMode.php',
+       'ConfiguredReadOnlyMode' => __DIR__ . 
'/includes/ConfiguredReadOnlyMode.php',
        'ConstantDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
        'Content' => __DIR__ . '/includes/content/Content.php',
        'ContentHandler' => __DIR__ . '/includes/content/ContentHandler.php',
diff --git a/includes/ConfiguredReadOnlyMode.php 
b/includes/ConfiguredReadOnlyMode.php
new file mode 100644
index 0000000..af7c7cb
--- /dev/null
+++ b/includes/ConfiguredReadOnlyMode.php
@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * A read-only mode service which does not depend on LoadBalancer.
+ * To obtain an instance, use MediaWikiServices::getConfiguredReadOnlyMode().
+ *
+ * @since 1.29
+ */
+class ConfiguredReadOnlyMode {
+       /** @var Config */
+       private $config;
+
+       /** @var string|bool|null */
+       private $fileReason;
+
+       /** @var string|null */
+       private $overrideReason;
+
+       public function __construct( Config $config ) {
+               $this->config = $config;
+       }
+
+       /**
+        * Check whether the wiki is in read-only mode.
+        *
+        * @return bool
+        */
+       public function isReadOnly() {
+               return $this->getReason() !== false;
+       }
+
+       /**
+        * Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
+        *
+        * @return string|bool String when in read-only mode; false otherwise
+        */
+       public function getReason() {
+               if ( $this->overrideReason !== null ) {
+                       return $this->overrideReason;
+               }
+               $confReason = $this->config->get( 'ReadOnly' );
+               if ( $confReason !== null ) {
+                       return $confReason;
+               }
+               if ( $this->fileReason === null ) {
+                       // Cache for faster access next time
+                       $readOnlyFile = $this->config->get( 'ReadOnlyFile' );
+                       if ( is_file( $readOnlyFile ) && filesize( 
$readOnlyFile ) > 0 ) {
+                               $this->fileReason = file_get_contents( 
$readOnlyFile );
+                       } else {
+                               $this->fileReason = false;
+                       }
+               }
+               return $this->fileReason;
+       }
+
+       /**
+        * Set the read-only mode, which will apply for the remainder of the
+        * request or until a service reset.
+        *
+        * @param string|null $msg
+        */
+       public function setReason( $msg ) {
+               $this->overrideReason = $msg;
+       }
+
+       /**
+        * Clear the cache of the read only file
+        */
+       public function clearCache() {
+               $this->fileReason = null;
+       }
+}
diff --git a/includes/ReadOnlyMode.php b/includes/ReadOnlyMode.php
index 592d495..547c2d5 100644
--- a/includes/ReadOnlyMode.php
+++ b/includes/ReadOnlyMode.php
@@ -66,75 +66,3 @@
                $this->configuredReadOnly->clearCache();
        }
 }
-
-/**
- * A read-only mode service which does not depend on LoadBalancer.
- * To obtain an instance, use MediaWikiServices::getConfiguredReadOnlyMode().
- *
- * @since 1.29
- */
-class ConfiguredReadOnlyMode {
-       /** @var Config */
-       private $config;
-
-       /** @var string|bool|null */
-       private $fileReason;
-
-       /** @var string|null */
-       private $overrideReason;
-
-       public function __construct( Config $config ) {
-               $this->config = $config;
-       }
-
-       /**
-        * Check whether the wiki is in read-only mode.
-        *
-        * @return bool
-        */
-       public function isReadOnly() {
-               return $this->getReason() !== false;
-       }
-
-       /**
-        * Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
-        *
-        * @return string|bool String when in read-only mode; false otherwise
-        */
-       public function getReason() {
-               if ( $this->overrideReason !== null ) {
-                       return $this->overrideReason;
-               }
-               $confReason = $this->config->get( 'ReadOnly' );
-               if ( $confReason !== null ) {
-                       return $confReason;
-               }
-               if ( $this->fileReason === null ) {
-                       // Cache for faster access next time
-                       $readOnlyFile = $this->config->get( 'ReadOnlyFile' );
-                       if ( is_file( $readOnlyFile ) && filesize( 
$readOnlyFile ) > 0 ) {
-                               $this->fileReason = file_get_contents( 
$readOnlyFile );
-                       } else {
-                               $this->fileReason = false;
-                       }
-               }
-               return $this->fileReason;
-       }
-
-       /**
-        * Set the read-only mode, which will apply for the remainder of the
-        * request or until a service reset.
-        *
-        * @param string|null $msg
-        */
-       public function setReason( $msg ) {
-               $this->overrideReason = $msg;
-       }
-
-       /**
-        * Clear the cache of the read only file
-        */
-       public function clearCache() {
-               $this->fileReason = null;
-       }
-}

-- 
To view, visit https://gerrit.wikimedia.org/r/370219
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7c12a571bb5ce76c132a738b48b2b82d763a8860
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to