summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2005-12-22 13:51:12 +0100
committerAndrew Dolgov <[email protected]>2005-12-22 13:51:12 +0100
commit6043fb7e201b85e6677680f33660d53abfac1756 (patch)
tree22c9e48a8b24def8dbc06c035668a993434b7eeb
parent59b7764387a7e47ad4526ebdcf71a3cf2da75a2d (diff)
proper handling of failed sanity check in parse_counters + weird getAttribute workaround
-rw-r--r--backend.php15
-rw-r--r--functions.js5
-rw-r--r--functions.php20
3 files changed, 28 insertions, 12 deletions
diff --git a/backend.php b/backend.php
index f0078888d..31595230d 100644
--- a/backend.php
+++ b/backend.php
@@ -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);
@@ -717,18 +719,7 @@
}
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") {
diff --git a/functions.js b/functions.js
index 01f1a1448..b17e8927e 100644
--- a/functions.js
+++ b/functions.js
@@ -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");
diff --git a/functions.php b/functions.php
index 80fed8e3b..d34e133ae 100644
--- a/functions.php
+++ b/functions.php
@@ -859,4 +859,24 @@
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;
+ }
+ }
+
?>