From: Alan Date: Wed, 23 Feb 2022 07:44:49 +0000 (+0800) Subject: only test read only on postgress X-Git-Url: http://git.roojs.org/?p=pear;a=commitdiff_plain;h=f01d9fe83100a88fd8d92c4bec7f8c44e915429d only test read only on postgress --- diff --git a/DB/pgsql.php b/DB/pgsql.php index 1b32ef8e..5a25d4e0 100644 --- a/DB/pgsql.php +++ b/DB/pgsql.php @@ -1019,9 +1019,11 @@ class DB_pgsql extends DB_common WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid AND f.attrelid = a.adrelid AND f.attname = '$field_name' AND $tableWhere AND f.attnum = a.adnum"); - $row = @pg_fetch_row($result, 0); - $num = preg_replace("/'(.*)'::\w+/", "\\1", $row[0]); - $flags .= 'default_' . rawurlencode($num) . ' '; + if ($result && @pg_numrows($result) > 0 ) { + $row = @pg_fetch_row($result, 0); + $num = preg_replace("/'(.*)'::\w+/", "\\1", $row[0]); + $flags .= 'default_' . rawurlencode($num) . ' '; + } } } else { $flags = ''; diff --git a/HTML/FlexyFramework.php b/HTML/FlexyFramework.php index b9297b7a..d9a243aa 100755 --- a/HTML/FlexyFramework.php +++ b/HTML/FlexyFramework.php @@ -915,11 +915,15 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1] Please check the value given to HTML_FlexyFramework, or run with debug on!

".$err->toString()); } - $res = $err->query("SELECT @@global.read_only as ro"); + // only applies to mysql... - $row = is_a($res, 'DB_Error') ? false : $res->fetchRow(DB_FETCHMODE_ASSOC); - if (!$row || (!empty($row['ro']) && empty($options['skip-read-only-check']))) { - $this->fatalError("Database is configured to be read-only - please check database
".$err->toString()); + if (preg_match('/^mysql/', $this->database)) { + $res = $err->query("SELECT @@global.read_only as ro"); + + $row = is_a($res, 'DB_Error') ? false : $res->fetchRow(DB_FETCHMODE_ASSOC); + if (!$row || (!empty($row['ro']) && empty($options['skip-read-only-check']))) { + $this->fatalError("Database is configured to be read-only - please check database
".$err->toString()); + } } // reset dont die! $options['dont_die'] = $dd ;