Make DB handles inherit configured read-only mode
[lhc/web/wiklou.git] / includes / db / Database.php
index 1da85d7..49a53ef 100644 (file)
@@ -927,8 +927,8 @@ abstract class DatabaseBase implements IDatabase {
 
                $isWriteQuery = $this->isWriteQuery( $sql );
                if ( $isWriteQuery ) {
-                       $reason = $this->getLBInfo( 'readOnlyReason' );
-                       if ( is_string( $reason ) ) {
+                       $reason = $this->getReadOnlyReason();
+                       if ( $reason !== false ) {
                                throw new DBReadOnlyError( $this, "Database is read-only: $reason" );
                        }
                        # Set a flag indicating that writes have been done
@@ -4286,6 +4286,16 @@ abstract class DatabaseBase implements IDatabase {
                // no-op
        }
 
+       /**
+        * @return string|bool Reason this DB is read-only or false if it is not
+        * @since 1.27
+        */
+       public function getReadOnlyReason() {
+               $reason = $this->getLBInfo( 'readOnlyReason' );
+
+               return is_string( $reason ) ? $reason : false;
+       }
+
        /**
         * @since 1.19
         * @return string