fix readonly check for framework2
authorAlan <alan@roojs.com>
Wed, 19 Jul 2023 04:02:06 +0000 (12:02 +0800)
committerAlan <alan@roojs.com>
Wed, 19 Jul 2023 04:02:06 +0000 (12:02 +0800)
HTML/FlexyFramework2.php

index 4b34e3f..c8c20b7 100644 (file)
@@ -872,6 +872,20 @@ class HTML_FlexyFramework2 {
                      <BR> ".$e->getMessage());
         }
         
+          
+         if (preg_match('/^mysql/', $this->database)) {
+            $res = $x->PDO()->query("SELECT @@global.read_only as ro");
+           
+            $row = !is_a($res, 'PDOStatement') ? false : $res->fetch(PDO::FETCH_ASSOC);
+            
+           
+            if (!$row || !empty($row['ro'])) {
+                if (empty($options['skip-read-only-check'])) {
+                    $this->fatalError("Database is configured to be read-only - please check database<BR>");
+                }
+                $this->database_is_readonly = true;
+            }
+        }
         
         
     }