]> git.wh0rd.org - tt-rss.git/commitdiff
output error message on unknown RPC subop
authorAndrew Dolgov <fox@bah.spb.su>
Mon, 20 Aug 2007 14:07:17 +0000 (15:07 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Mon, 20 Aug 2007 14:07:17 +0000 (15:07 +0100)
functions.js
modules/backend-rpc.php

index a33302063ad9e5945d9fc5a9871d0fd84983a748..c99bfae62a7ee4eeb09e8003b32a00d200f2a60b 100644 (file)
@@ -615,24 +615,16 @@ function parse_counters(reply, scheduled_call) {
 
                var feeds_found = 0;
 
-               if (reply.firstChild && reply.firstChild.firstChild) {
-                       debug("<b>wrong element passed to parse_counters, adjusting.</b>");
-                       reply = reply.firstChild;
-               }
+               var elems = reply.getElementsByTagName("counter");
 
-               for (var l = 0; l < reply.childNodes.length; l++) {
-                       if (!reply.childNodes[l] ||
-                               typeof(reply.childNodes[l].getAttribute) == "undefined") {
-                               // where did this come from?
-                               continue;
-                       }
+               for (var l = 0; l < elems.length; l++) {
 
-                       var id = reply.childNodes[l].getAttribute("id");
-                       var t = reply.childNodes[l].getAttribute("type");
-                       var ctr = reply.childNodes[l].getAttribute("counter");
-                       var error = reply.childNodes[l].getAttribute("error");
-                       var has_img = reply.childNodes[l].getAttribute("hi");
-                       var updated = reply.childNodes[l].getAttribute("updated");
+                       var id = elems[l].getAttribute("id");
+                       var t = elems[l].getAttribute("type");
+                       var ctr = elems[l].getAttribute("counter");
+                       var error = elems[l].getAttribute("error");
+                       var has_img = elems[l].getAttribute("hi");
+                       var updated = elems[l].getAttribute("updated");
        
                        if (id == "global-unread") {
                                global_unread = ctr;
index 3a30543dd357eaa82e4fcb5356e0e6e5e5d89dab..6d3ceedfd6a2781ab609add9ec9be94e75dc96cc 100644 (file)
@@ -19,6 +19,7 @@
 
                        print "</rpc-reply>";
 
+                       return;
                }
 
                if ($subop == "getLabelCounters") {
@@ -31,6 +32,8 @@
                        }
                        print "</counters>";
                        print "</rpc-reply>";
+
+                       return;
                }
 
                if ($subop == "getFeedCounters") {
@@ -39,6 +42,8 @@
                        getFeedCounters($link);
                        print "</counters>";
                        print "</rpc-reply>";
+
+                       return;
                }
 
                if ($subop == "getAllCounters") {
@@ -51,6 +56,8 @@
                        print "</counters>";
                        print_runtime_info($link);
                        print "</rpc-reply>";
+
+                       return;
                }
 
                if ($subop == "mark") {
@@ -76,6 +83,7 @@
                        }
                        print "</counters></rpc-reply>";
 
+                       return;
                }
 
                if ($subop == "publ") {
                        }
                        print "</counters></rpc-reply>";
 
+                       return;
                }
 
                if ($subop == "updateFeed") {
 
                        print "</rpc-reply>";
 
+                       return;
                }
 
                /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
                        print "</counters>";
                        print_runtime_info($link);
                        print "</rpc-reply>";
+
+                       return;
                }
 
                if ($subop == "markSelected") {
                        print "</counters>";
                        print_runtime_info($link);
                        print "</rpc-reply>";
+
+                       return;
                }
 
                if ($subop == "publishSelected") {
                        print "</counters>";
                        print_runtime_info($link);
                        print "</rpc-reply>";
+
+                       return;
                }
 
                if ($subop == "sanityCheck") {
 
                        }
                        print "</rpc-reply>";
+
+                       return;
                }               
 
                if ($subop == "globalPurge") {
                        global_purge_old_posts($link, true);
                        print "</rpc-reply>";
 
+                       return;
                }
 
                if ($subop == "getArticleLink") {
                        } else {
                                print "<rpc-reply><error>Article not found</error></rpc-reply>";
                        }
+
+                       return;
                }
 
                if ($subop == "setArticleTags") {
                                <message>$id</message>
                                </rpc-reply>";
 
+                       return;
                }
 
                if ($subop == "regenPubKey") {
 
                        print "</rpc-reply>";
 
+                       return;
                }
 
                if ($subop == "logout") {
                        logout_user();
                        print_error_xml(6);
+                       return;
                }
 
                if ($subop == "completeTags") {
                        }
                        print "</ul>";
 
+                       return;
                }
 
+               print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>