Automatically detect READ_ONLY mode for MySQL/MariaDB
[lhc/web/wiklou.git] / includes / db / DatabaseMysqlBase.php
index 02a8d30..a6f8c31 100644 (file)
@@ -885,6 +885,13 @@ abstract class DatabaseMysqlBase extends Database {
                }
        }
 
+       public function serverIsReadOnly() {
+               $res = $this->query( "SHOW GLOBAL VARIABLES LIKE 'read_only'", __METHOD__ );
+               $row = $this->fetchObject( $res );
+
+               return $row ? ( strtolower( $row->Value ) === 'on' ) : false;
+       }
+
        /**
         * @param string $index
         * @return string