]> git.wh0rd.org - tt-rss.git/commitdiff
block mysql versions where true is undefined in sanity_check
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 13 Aug 2006 04:46:40 +0000 (05:46 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 13 Aug 2006 04:46:40 +0000 (05:46 +0100)
db.php
errors.php
functions.php

diff --git a/db.php b/db.php
index 55768f3f66364909b06eb06d346a20138c863e59..7766c0563a8f27ccc2ba6284169f90961bd2a762 100644 (file)
--- a/db.php
+++ b/db.php
@@ -55,19 +55,23 @@ function db_escape_string_2($s, $link) {
        }
 }
 
-function db_query($link, $query) {
+function db_query($link, $query, $die_on_error = true) {
        if (DB_TYPE == "pgsql") {
                $result = pg_query($link, $query);
                if (!$result) {
                        $query = htmlspecialchars($query); // just in case
-                       die("Query <i>$query</i> failed: " . pg_last_error($link));                     
+                       if ($die_on_error) {
+                               die("Query <i>$query</i> failed: " . pg_last_error($link));                     
+                       }
                }
                return $result;
        } else if (DB_TYPE == "mysql") {
                $result = mysql_query($query, $link);
                if (!$result) {
                        $query = htmlspecialchars($query);
-                       die("Query <i>$query</i> failed: " . mysql_error($link));
+                       if ($die_on_error) {
+                               die("Query <i>$query</i> failed: " . mysql_error($link));
+                       }
                }
                return $result;
        }
index 556af08829b1e74bd3c0dd06c84ae9a7b2c36813..603ef7056fd0201ba165c7a85e6ea93e83bd6a4f 100644 (file)
@@ -22,4 +22,7 @@
        $ERRORS[8] = "Denied. Your access level is insufficient to access this page.";
 
        $ERRORS[9] = "Configuration check failed";
+
+       $ERRORS[10] = "Your version of MySQL is not currently supported. Please see 
+               official site for more information.";
 ?>
index d1212499ba5a4e461dc5341eb8d41b7f348baf1c..a46061bda64bc10ebaf2235c0d73c9ee6ba0d882 100644 (file)
 
        function sanity_check($link) {
 
+               error_reporting(0);
+
                $error_code = 0;
                $result = db_query($link, "SELECT schema_version FROM ttrss_version");
                $schema_version = db_fetch_result($result, 0, "schema_version");
                        $error_code = 5;
                }
 
+               if (DB_TYPE == "mysql") {
+                       $result = db_query($link, "SELECT true", false);
+                       if (db_num_rows($result) != 1) {
+                               $error_code = 10;
+                       }
+               }
+
+               error_reporting (DEFAULT_ERROR_LEVEL);
+
                if ($error_code != 0) {
-                       print_error_xml(5);
+                       print_error_xml($error_code);
                        return false;
                } else {
                        return true;