]> git.wh0rd.org Git - tt-rss.git/commitdiff
proper handling of failed sanity check in parse_counters + weird getAttribute workaround
authorAndrew Dolgov <fox@bah.spb.su>
Thu, 22 Dec 2005 12:51:12 +0000 (13:51 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Thu, 22 Dec 2005 12:51:12 +0000 (13:51 +0100)
backend.php
functions.js
functions.php

index f0078888dd0685ab7420b62ea0c82ef6069f6279..31595230d35ccfce7163d3777906beb3664d04d9 100644 (file)
@@ -53,6 +53,8 @@
                pg_query("set client_encoding = 'utf-8'");
        }
 
+       if (!sanity_check($link)) { return; }
+
        $fetch = $_GET["fetch"];
 
        setcookie("ttrss_icons_url", ICONS_URL);
                }
 
                if ($subop == "sanityCheck") {
-
-                       $error_code = 0;
-
-                       $result = db_query($link, "SELECT schema_version FROM ttrss_version");
-
-                       $schema_version = db_fetch_result($result, 0, "schema_version");
-
-                       if ($schema_version != SCHEMA_VERSION) {
-                               $error_code = 5;
-                       }
-
-                       print "<error error-code='$error_code'/>";
+                       sanity_check();
                }
 
                if ($subop == "globalPurge") {
index 01f1a144879198a899217f928b9db7c6b4970b1f..b17e8927e70c120f51cf1251ce4577979a34aff9 100644 (file)
@@ -358,6 +358,11 @@ if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') {
 function parse_counters(reply, f_document, title_obj) {
        try {
                for (var l = 0; l < reply.childNodes.length; l++) {
+                       if (!reply.childNodes[l] || !reply.childNodes[l].getAttribute) {
+                               // where did this come from?
+                               continue;
+                       }
+
                        var id = reply.childNodes[l].getAttribute("id");
                        var t = reply.childNodes[l].getAttribute("type");
                        var ctr = reply.childNodes[l].getAttribute("counter");
index 80fed8e3b3ac74bc1b2b5fd1420cedb04b41f5bf..d34e133aede74f05fd97bebb9b549fbd308d299f 100644 (file)
                else
                        return "even";
        }
+
+       function sanity_check($link) {
+       
+               $error_code = 0;
+               $result = db_query($link, "SELECT schema_version FROM ttrss_version");
+               $schema_version = db_fetch_result($result, 0, "schema_version");
+
+               if ($schema_version != SCHEMA_VERSION) {
+                       $error_code = 5;
+               }
+
+               print "<error error-code='$error_code'/>";
+
+               if ($error_code != 0) {
+                       return false;
+               } else {
+                       return true;
+               }
+       }
+
 ?>