mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-14 15:45:55 +00:00
proper handling of failed sanity check in parse_counters + weird getAttribute workaround
This commit is contained in:
15
backend.php
15
backend.php
@@ -53,6 +53,8 @@
|
|||||||
pg_query("set client_encoding = 'utf-8'");
|
pg_query("set client_encoding = 'utf-8'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sanity_check($link)) { return; }
|
||||||
|
|
||||||
$fetch = $_GET["fetch"];
|
$fetch = $_GET["fetch"];
|
||||||
|
|
||||||
setcookie("ttrss_icons_url", ICONS_URL);
|
setcookie("ttrss_icons_url", ICONS_URL);
|
||||||
@@ -717,18 +719,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "sanityCheck") {
|
if ($subop == "sanityCheck") {
|
||||||
|
sanity_check();
|
||||||
$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 ($subop == "globalPurge") {
|
if ($subop == "globalPurge") {
|
||||||
|
|||||||
@@ -358,6 +358,11 @@ if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') {
|
|||||||
function parse_counters(reply, f_document, title_obj) {
|
function parse_counters(reply, f_document, title_obj) {
|
||||||
try {
|
try {
|
||||||
for (var l = 0; l < reply.childNodes.length; l++) {
|
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 id = reply.childNodes[l].getAttribute("id");
|
||||||
var t = reply.childNodes[l].getAttribute("type");
|
var t = reply.childNodes[l].getAttribute("type");
|
||||||
var ctr = reply.childNodes[l].getAttribute("counter");
|
var ctr = reply.childNodes[l].getAttribute("counter");
|
||||||
|
|||||||
@@ -859,4 +859,24 @@
|
|||||||
else
|
else
|
||||||
return "even";
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user