Add IDatabase::isReadOnly() method
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 20 Oct 2015 23:42:02 +0000 (16:42 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 20 Oct 2015 23:48:18 +0000 (16:48 -0700)
Also made getReadOnlyReason() protected as it has no outside
callers and is not part of IDatabase.

Change-Id: If6694a19df038af645a97f701397a536570d1b42

includes/db/DBConnRef.php
includes/db/Database.php
includes/db/IDatabase.php

index 5a8fe92..53e9a50 100644 (file)
@@ -513,6 +513,10 @@ class DBConnRef implements IDatabase {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
 
+       public function isReadOnly() {
+               return $this->__call( __FUNCTION__, func_get_args() );
+       }
+
        /**
         * Clean up the connection when out of scope
         */
index 49a53ef..2f135a4 100644 (file)
@@ -4286,11 +4286,14 @@ abstract class DatabaseBase implements IDatabase {
                // no-op
        }
 
+       public function isReadOnly() {
+               return ( $this->getReadOnlyReason() !== false );
+       }
+
        /**
         * @return string|bool Reason this DB is read-only or false if it is not
-        * @since 1.27
         */
-       public function getReadOnlyReason() {
+       protected function getReadOnlyReason() {
                $reason = $this->getLBInfo( 'readOnlyReason' );
 
                return is_string( $reason ) ? $reason : false;
index ba3c1dd..d110583 100644 (file)
@@ -1511,4 +1511,10 @@ interface IDatabase {
         *   restore the initial value
         */
        public function setBigSelects( $value = true );
+
+       /**
+        * @return bool Whether this DB is read-only
+        * @since 1.27
+        */
+       public function isReadOnly();
 }