]> git.wh0rd.org Git - tt-rss.git/commitdiff
fix various issues reported by static analysis
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Wed, 26 Apr 2017 12:29:22 +0000 (15:29 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Wed, 26 Apr 2017 12:29:22 +0000 (15:29 +0300)
update gitlab-ci config

20 files changed:
.gitlab-ci.yml
classes/api.php
classes/article.php
classes/auth/base.php
classes/db/prefs.php
classes/feeds.php
classes/logger/syslog.php
classes/opml.php
classes/plugin.php
classes/pluginhost.php
classes/pref/filters.php
classes/pref/users.php
classes/rpc.php
include/errorhandler.php
include/functions.php
include/functions2.php
include/rssfuncs.php
include/sanity_check.php
include/sessions.php
update.php

index 4f146016cd344c7df6fef80a402f50360590a0e6..d19f7b85205454c3caf6c111629e9de05a7fb6a4 100644 (file)
@@ -11,6 +11,6 @@ jobs:
   when: manual\r
   stage: test\r
   script:\r
-    - phpmd include text utils/gitlab-ci/phpmd-ruleset.xml \r
-    - phpmd classes text utils/gitlab-ci/phpmd-ruleset.xml \r
-\r
+    - phpmd include text utils/gitlab-ci/phpmd-ruleset.xml\r
+    - phpmd classes text utils/gitlab-ci/phpmd-ruleset.xml\r
+    - FILES=$(ls -dm *.php | sed "s/ //g") && phpmd $FILES text utils/gitlab-ci/phpmd-ruleset.xml\r
index c43a78ebee686b81939ab95b3ea828b5a734a969..895ea52615a9e84bac0751a6467a16b812194d69 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 class API extends Handler {
 
        const API_LEVEL  = 14;
@@ -309,7 +308,7 @@ class API extends Handler {
                                                get_feed_access_key(-2, false);
 
                                        $p = new pubsubhubbub\publisher\Publisher(PUBSUBHUBBUB_HUB);
-                                       $pubsub_result = $p->publish_update($rss_link);
+                                       $p->publish_update($rss_link);
                                }
                        }
 
@@ -418,7 +417,7 @@ class API extends Handler {
                $feed_id = (int) $this->dbh->escape_string($_REQUEST["feed_id"]);
 
                if (!ini_get("open_basedir")) {
-                       update_rss_feed($feed_id, true);
+                       update_rss_feed($feed_id);
                }
 
                $this->wrap(self::STATUS_OK, array("status" => "OK"));
@@ -658,6 +657,9 @@ class API extends Handler {
                return $feeds;
        }
 
+       /**
+        * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+        */
        static function api_get_headlines($feed_id, $limit, $offset,
                                $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
                                $include_attachments, $since_id,
@@ -677,7 +679,7 @@ class API extends Handler {
 
                                        if (!$cache_images && time() - $last_updated > 120) {
                                                include "rssfuncs.php";
-                                               update_rss_feed($feed_id, true, true);
+                                               update_rss_feed($feed_id, true);
                                        } else {
                                                db_query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
                                                        WHERE id = '$feed_id'");
index 4126843af6d36b5d8e1c32b2038da09312c7f0a1..2e7a05e0bb1db7e125242adcef0b9182e5895d52 100644 (file)
@@ -361,7 +361,7 @@ class Article extends Handler_Protected {
                                $labels = get_article_labels($id, $_SESSION["uid"]);
 
                                array_push($reply["info-for-headlines"],
-                               array("id" => $id, "labels" => format_article_labels($labels, $id)));
+                               array("id" => $id, "labels" => format_article_labels($labels)));
 
                        }
                }
index 69acd0985c6ceb87a173eafa2983a411589a07ff..26b6e4ab7bd120f96c28fb04e87d987dc06bf45c 100644 (file)
@@ -6,10 +6,16 @@ class Auth_Base {
                $this->dbh = Db::get();
        }
 
+       /**
+        * @SuppressWarnings(unused)
+        */
        function check_password($owner_uid, $password) {
                return false;
        }
 
+       /**
+        * @SuppressWarnings(unused)
+        */
        function authenticate($login, $password) {
                return false;
        }
index 3e92bb89b59073766e61eadf28dac6af0d3826e8..0d4ebc2d2506aa3fdeca93263f71be69fdf93259 100644 (file)
@@ -23,8 +23,6 @@ class Db_Prefs {
        }
 
        function cache() {
-               $profile = false;
-
                $user_id = $_SESSION["uid"];
                @$profile = $_SESSION["profile"];
 
@@ -129,7 +127,6 @@ class Db_Prefs {
                        @$profile = $_SESSION["profile"];
                } else {
                        $user_id = sprintf("%d", $user_id);
-                       $prefs_cache = false;
                }
 
                if ($profile) {
index 48c4ad1992c3e0de606569bdd9224e2b741fb957..4c4972d76d3d17ca4f74fa924f1d31bdb69a5551 100755 (executable)
@@ -13,7 +13,7 @@ class Feeds extends Handler_Protected {
 
        private function format_headline_subtoolbar($feed_site_url, $feed_title,
                        $feed_id, $is_cat, $search,
-                       $view_mode, $error, $feed_last_updated) {
+                       $error, $feed_last_updated) {
 
                $catchup_sel_link = "catchupSelection()";
 
@@ -153,7 +153,7 @@ class Feeds extends Handler_Protected {
        }
 
        private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
-                                       $next_unread_feed, $offset, $vgr_last_feed = false,
+                                       $offset, $vgr_last_feed = false,
                                        $override_order = false, $include_children = false, $check_first_id = false,
                                        $skip_first_id_check = false) {
 
@@ -203,7 +203,7 @@ class Feeds extends Handler_Protected {
 
                                        if (!$cache_images && time() - $last_updated > 120) {
                                                include "rssfuncs.php";
-                                               update_rss_feed($feed, true, true);
+                                               update_rss_feed($feed, true);
                                        } else {
                                                $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
                                                                WHERE id = '$feed'");
@@ -306,7 +306,7 @@ class Feeds extends Handler_Protected {
 
                $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
                        $feed_title,
-                       $feed, $cat_view, $search, $view_mode,
+                       $feed, $cat_view, $search,
                        $last_error, $last_updated);
 
                $headlines_count = is_numeric($result) ? 0 : $this->dbh->num_rows($result);
@@ -361,7 +361,7 @@ class Feeds extends Handler_Protected {
                                if (!is_array($labels)) $labels = get_article_labels($id);
 
                                $labels_str = "<span class=\"HLLCTR-$id\">";
-                               $labels_str .= format_article_labels($labels, $id);
+                               $labels_str .= format_article_labels($labels);
                                $labels_str .= "</span>";
 
                                if (count($topmost_article_ids) < 3) {
@@ -937,7 +937,7 @@ class Feeds extends Handler_Protected {
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
 
                $ret = $this->format_headlines_list($feed, $method,
-                       $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
+                       $view_mode, $limit, $cat_view, $offset,
                        $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check);
 
                //$topmost_article_ids = $ret[0];
@@ -1231,7 +1231,7 @@ class Feeds extends Handler_Protected {
 
                if ($do_update) {
                        include "rssfuncs.php";
-                       update_rss_feed($feed_id, true, true);
+                       update_rss_feed($feed_id, true);
                }
 
                ?></pre>
index b8b5260a04c68f63ebfa6949794139d1a2e97464..04416060134575c136c69553cdcf6d7fda6ea08e 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 class Logger_Syslog {
 
+       /**
+        * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+        */
        function log_error($errno, $errstr, $file, $line, $context) {
 
                switch ($errno) {
index 04516dde42339bb4a15d57150930de38158d317d..0ad5ddf3c1dcc2787357742ada305ca4a77ab207 100644 (file)
@@ -251,7 +251,7 @@ class Opml extends Handler_Protected {
 
        // Import
 
-       private function opml_import_feed($doc, $node, $cat_id, $owner_uid) {
+       private function opml_import_feed($node, $cat_id, $owner_uid) {
                $attrs = $node->attributes;
 
                $feed_title = $this->dbh->escape_string(mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250));
@@ -284,7 +284,7 @@ class Opml extends Handler_Protected {
                }
        }
 
-       private function opml_import_label($doc, $node, $owner_uid) {
+       private function opml_import_label($node, $owner_uid) {
                $attrs = $node->attributes;
                $label_name = $this->dbh->escape_string($attrs->getNamedItem('label-name')->nodeValue);
 
@@ -301,7 +301,7 @@ class Opml extends Handler_Protected {
                }
        }
 
-       private function opml_import_preference($doc, $node, $owner_uid) {
+       private function opml_import_preference($node) {
                $attrs = $node->attributes;
                $pref_name = $this->dbh->escape_string($attrs->getNamedItem('pref-name')->nodeValue);
 
@@ -315,7 +315,7 @@ class Opml extends Handler_Protected {
                }
        }
 
-       private function opml_import_filter($doc, $node, $owner_uid) {
+       private function opml_import_filter($node) {
                $attrs = $node->attributes;
 
                $filter_type = $this->dbh->escape_string($attrs->getNamedItem('filter-type')->nodeValue);
@@ -386,8 +386,6 @@ class Opml extends Handler_Protected {
        }
 
        private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
-               $body = $doc->getElementsByTagName('body');
-
                $default_cat_id = (int) get_feed_category('Imported feeds', false);
 
                if ($root_node) {
@@ -442,16 +440,16 @@ class Opml extends Handler_Protected {
 
                                        switch ($cat_title) {
                                        case "tt-rss-prefs":
-                                               $this->opml_import_preference($doc, $node, $owner_uid);
+                                               $this->opml_import_preference($node);
                                                break;
                                        case "tt-rss-labels":
-                                               $this->opml_import_label($doc, $node, $owner_uid);
+                                               $this->opml_import_label($node, $owner_uid);
                                                break;
                                        case "tt-rss-filters":
-                                               $this->opml_import_filter($doc, $node, $owner_uid);
+                                               $this->opml_import_filter($node);
                                                break;
                                        default:
-                                               $this->opml_import_feed($doc, $node, $dst_cat_id, $owner_uid);
+                                               $this->opml_import_feed($node, $dst_cat_id, $owner_uid);
                                        }
                                }
                        }
@@ -461,19 +459,14 @@ class Opml extends Handler_Protected {
        function opml_import($owner_uid) {
                if (!$owner_uid) return;
 
-               $debug = isset($_REQUEST["debug"]);
                $doc = false;
 
-#              if ($debug) $doc = DOMDocument::load("/tmp/test.opml");
-
                if ($_FILES['opml_file']['error'] != 0) {
                        print_error(T_sprintf("Upload failed with error code %d",
                                $_FILES['opml_file']['error']));
                        return;
                }
 
-               $tmp_file = false;
-
                if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
                        $tmp_file = tempnam(CACHE_DIR . '/upload', 'opml');
 
index 09204098bb411314157dd71c7b38bb9f80e1a979..5041de0c42878119960fce5200f53e842360f906 100644 (file)
@@ -22,6 +22,9 @@ class Plugin {
                return array();
        }
 
+       /**
+        * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+        */
        function is_public_method($method) {
                return false;
        }
index 3c2d7931e3e1044a59e08b05f96b1f96f67515db..48ef43e0a0036ca8d1026aee5d44a9b8bab38d4e 100644 (file)
@@ -288,7 +288,7 @@ class PluginHost {
                }
        }
 
-       function load_data($force = false) {
+       function load_data() {
                if ($this->owner_uid)  {
                        $result = $this->dbh->query("SELECT name, content FROM ttrss_plugin_storage
                                WHERE owner_uid = '".$this->owner_uid."'");
index 5629f530cb44422088951be1029e834c28e2a602..f3836d8e1f6d42ed42a4492662673c55b1be3356 100755 (executable)
@@ -130,7 +130,7 @@ class Pref_Filters extends Handler_Protected {
                        while ($line = db_fetch_assoc($result)) {
 
                                $rc = get_article_filters(array($filter), $line['title'], $line['content'], $line['link'],
-                                       false, $line['author'], explode(",", $line['tag_cache']));
+                                       $line['author'], explode(",", $line['tag_cache']));
 
                                if (count($rc) > 0) {
 
index f211a8f2fd34bb7d55c1ddf874df3cf8db3b2287..215f05646c9ad2522e2d8ae57ff71e3dc9065aed 100644 (file)
@@ -251,7 +251,6 @@ class Pref_Users extends Handler_Protected {
 
                        $login = db_fetch_result($result, 0, "login");
                        $email = db_fetch_result($result, 0, "email");
-                       $salt = db_fetch_result($result, 0, "salt");
 
                        $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
                        $tmp_user_pwd = make_password(8);
index ca8ce39adb876fac9b3e454ae65c07a50d04cd43..008ed876ab7e14948ccffba2079ba63eeab6b594 100755 (executable)
@@ -453,7 +453,7 @@ class RPC extends Handler_Protected {
                $search_query = $this->dbh->escape_string($_REQUEST['search_query']);
                $search_lang = $this->dbh->escape_string($_REQUEST['search_lang']);
 
-               catchup_feed($feed_id, $is_cat, false, false, $mode, [$search_query, $search_lang]);
+               catchup_feed($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]);
 
                print json_encode(array("message" => "UPDATE_COUNTERS"));
        }
index f757b68d1cbbb3ae2a0111c9daa29ff101940239..bb2fbaee37dacd7f485167cf6aaae6a9a267e592 100644 (file)
@@ -32,8 +32,6 @@ function format_backtrace($trace) {
 }
 
 function ttrss_error_handler($errno, $errstr, $file, $line, $context) {
-       global $logger;
-
        if (error_reporting() == 0 || !$errno) return false;
 
        $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1);
@@ -46,7 +44,6 @@ function ttrss_error_handler($errno, $errstr, $file, $line, $context) {
 }
 
 function ttrss_fatal_handler() {
-       global $logger;
        global $last_query;
 
        $error = error_get_last();
index 526750574446b646fba26f72fa12357b8486573f..baeaa03abee1e30a9779deb5b67db76331d9c2c5 100644 (file)
                }
        }
 
-       function catchup_feed($feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all', $search = false) {
+       function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) {
 
                if (!$owner_uid) $owner_uid = $_SESSION['uid'];
 
 
                global $fetch_last_error;
                global $fetch_last_error_content;
-               global $fetch_last_error_code;
 
                require_once "include/rssfuncs.php";
 
 
        // TODO: less dumb splitting
        require_once "functions2.php";
-
-?>
index 844693654801a59fa0261ebba433830590d58c21..f9ee8245f2bfd4df85eae76532420ea5836bfc82 100644 (file)
                }
        } // function encrypt_password
 
-       function load_filters($feed_id, $owner_uid, $action_id = false) {
+       function load_filters($feed_id, $owner_uid) {
                $filters = array();
 
                $cat_id = (int)getFeedCategory($feed_id);
                return true;
        }
 
-       function format_tags_string($tags, $id) {
+       function format_tags_string($tags) {
                if (!is_array($tags) || count($tags) == 0) {
                        return __("no tags");
                } else {
                }
        }
 
-       function format_article_labels($labels, $id) {
+       function format_article_labels($labels) {
 
                if (!is_array($labels)) return '';
 
                return false;
        }
 
+       /**
+        * @SuppressWarnings(unused)
+        */
        function error_json($code) {
                require_once "errors.php";
 
index 1eea3df3a5626c9a316b6077f1d52d098e9a7f25..645d06f895470fc0ec534d3f71b505b98cf85184 100644 (file)
 
        }
 
-
-       /**
-        * Update a feed batch.
-        * Used by daemons to update n feeds by run.
-        * Only update feed needing a update, and not being processed
-        * by another process.
-        *
-        * @param mixed $link Database link
-        * @param integer $limit Maximum number of feeds in update batch. Default to DAEMON_FEED_LIMIT.
-        * @param boolean $from_http Set to true if you call this function from http to disable cli specific code.
-        * @param boolean $debug Set to false to disable debug output. Default to true.
-        * @return void
-        */
-       function update_daemon_common($limit = DAEMON_FEED_LIMIT, $from_http = false, $debug = true) {
+       function update_daemon_common($limit = DAEMON_FEED_LIMIT, $debug = true) {
                // Process all other feeds using last_updated and interval parameters
 
                $schema_version = get_schema_version();
                        ORDER BY ttrss_feeds.id $query_limit");
 
                        if (db_num_rows($tmp_result) > 0) {
-                               $rss = false;
-
                                while ($tline = db_fetch_assoc($tmp_result)) {
                                        if($debug) _debug(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]);
 
                                                array_push($batch_owners, $tline["owner_uid"]);
 
                                        $fstarted = microtime(true);
-                                       $rss = update_rss_feed($tline["id"], true, false);
+                                       update_rss_feed($tline["id"], true, false);
                                        _debug_suppress(false);
 
                                        _debug(sprintf("    %.4f (sec)", microtime(true) - $fstarted));
 
                return $nf;
 
-       } // function update_daemon_common
+       }
 
        // this is used when subscribing
        function set_basic_feed_info($feed) {
                }
        }
 
-       // ignore_daemon is not used
-       function update_rss_feed($feed, $ignore_daemon = false, $no_cache = false, $rss = false) {
+       /**
+         * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+       */
+       function update_rss_feed($feed, $no_cache = false) {
 
                $debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
 
                $pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
                $pluginhost->load_data();
 
-               if ($rss && is_object($rss) && get_class($rss) == "FeedParser") {
-                       _debug("using previously initialized parser object");
-               } else {
-                       $rss_hash = false;
+               $rss_hash = false;
 
-                       $force_refetch = isset($_REQUEST["force_refetch"]);
-                       $feed_data = "";
+               $force_refetch = isset($_REQUEST["force_refetch"]);
+               $feed_data = "";
 
-                       foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) {
-                               $feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, 0, $auth_login, $auth_pass);
-                       }
-
-                       // try cache
-                       if (!$feed_data &&
-                               file_exists($cache_filename) &&
-                               is_readable($cache_filename) &&
-                               !$auth_login && !$auth_pass &&
-                               filemtime($cache_filename) > time() - 30) {
+               foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) {
+                       $feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, 0, $auth_login, $auth_pass);
+               }
 
-                               _debug("using local cache [$cache_filename].", $debug_enabled);
+               // try cache
+               if (!$feed_data &&
+                       file_exists($cache_filename) &&
+                       is_readable($cache_filename) &&
+                       !$auth_login && !$auth_pass &&
+                       filemtime($cache_filename) > time() - 30) {
 
-                               @$feed_data = file_get_contents($cache_filename);
+                       _debug("using local cache [$cache_filename].", $debug_enabled);
 
-                               if ($feed_data) {
-                                       $rss_hash = sha1($feed_data);
-                               }
+                       @$feed_data = file_get_contents($cache_filename);
 
-                       } else {
-                               _debug("local cache will not be used for this feed", $debug_enabled);
+                       if ($feed_data) {
+                               $rss_hash = sha1($feed_data);
                        }
 
-                       // fetch feed from source
-                       if (!$feed_data) {
-                               _debug("fetching [$fetch_url]...", $debug_enabled);
+               } else {
+                       _debug("local cache will not be used for this feed", $debug_enabled);
+               }
 
-                               if (ini_get("open_basedir") && function_exists("curl_init")) {
-                                       _debug("not using CURL due to open_basedir restrictions");
-                               }
+               // fetch feed from source
+               if (!$feed_data) {
+                       _debug("fetching [$fetch_url]...", $debug_enabled);
 
-                               $feed_data = fetch_file_contents($fetch_url, false,
-                                       $auth_login, $auth_pass, false,
-                                       $no_cache ? FEED_FETCH_NO_CACHE_TIMEOUT : FEED_FETCH_TIMEOUT,
-                                       0);
+                       if (ini_get("open_basedir") && function_exists("curl_init")) {
+                               _debug("not using CURL due to open_basedir restrictions");
+                       }
 
-                               global $fetch_curl_used;
+                       $feed_data = fetch_file_contents($fetch_url, false,
+                               $auth_login, $auth_pass, false,
+                               $no_cache ? FEED_FETCH_NO_CACHE_TIMEOUT : FEED_FETCH_TIMEOUT,
+                               0);
 
-                               if (!$fetch_curl_used) {
-                                       $tmp = @gzdecode($feed_data);
+                       global $fetch_curl_used;
 
-                                       if ($tmp) $feed_data = $tmp;
-                               }
+                       if (!$fetch_curl_used) {
+                               $tmp = @gzdecode($feed_data);
 
-                               $feed_data = trim($feed_data);
+                               if ($tmp) $feed_data = $tmp;
+                       }
 
-                               _debug("fetch done.", $debug_enabled);
+                       $feed_data = trim($feed_data);
 
-                               // cache vanilla feed data for re-use
-                               if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/simplepie")) {
-                                       $new_rss_hash = sha1($feed_data);
+                       _debug("fetch done.", $debug_enabled);
 
-                                       if ($new_rss_hash != $rss_hash) {
-                                               _debug("saving $cache_filename", $debug_enabled);
-                                               @file_put_contents($cache_filename, $feed_data);
-                                       }
+                       // cache vanilla feed data for re-use
+                       if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/simplepie")) {
+                               $new_rss_hash = sha1($feed_data);
+
+                               if ($new_rss_hash != $rss_hash) {
+                                       _debug("saving $cache_filename", $debug_enabled);
+                                       @file_put_contents($cache_filename, $feed_data);
                                }
                        }
+               }
 
-                       if (!$feed_data) {
-                               global $fetch_last_error;
-                               global $fetch_last_error_code;
+               if (!$feed_data) {
+                       global $fetch_last_error;
+                       global $fetch_last_error_code;
 
-                               _debug("unable to fetch: $fetch_last_error [$fetch_last_error_code]", $debug_enabled);
+                       _debug("unable to fetch: $fetch_last_error [$fetch_last_error_code]", $debug_enabled);
 
-                               $error_escaped = '';
+                       $error_escaped = '';
 
-                               // If-Modified-Since
-                               if ($fetch_last_error_code != 304) {
-                                       $error_escaped = db_escape_string($fetch_last_error);
-                               } else {
-                                       _debug("source claims data not modified, nothing to do.", $debug_enabled);
-                               }
+                       // If-Modified-Since
+                       if ($fetch_last_error_code != 304) {
+                               $error_escaped = db_escape_string($fetch_last_error);
+                       } else {
+                               _debug("source claims data not modified, nothing to do.", $debug_enabled);
+                       }
 
-                               db_query(
-                                       "UPDATE ttrss_feeds SET last_error = '$error_escaped',
-                                               last_updated = NOW() WHERE id = '$feed'");
+                       db_query(
+                               "UPDATE ttrss_feeds SET last_error = '$error_escaped',
+                                       last_updated = NOW() WHERE id = '$feed'");
 
-                               return;
-                       }
+                       return;
                }
 
                foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) {
                                $matched_rules = array();
 
                                $article_filters = get_article_filters($filters, $article["title"],
-                                       $article["content"], $article["link"], 0, $article["author"],
+                                       $article["content"], $article["link"], $article["author"],
                                        $article["tags"], $matched_rules);
 
                                if ($debug_enabled) {
                                last_updated = NOW() WHERE id = '$feed'");
 
                        unset($rss);
+                       return;
                }
 
                _debug("done", $debug_enabled);
 
-               return $rss;
+               return true;
        }
 
        function cache_enclosures($enclosures, $site_url, $debug) {
                return $params;
        }
 
-       function get_article_filters($filters, $title, $content, $link, $timestamp, $author, $tags, &$matched_rules = false) {
+       function get_article_filters($filters, $title, $content, $link, $author, $tags, &$matched_rules = false) {
                $matches = array();
 
                foreach ($filters as $filter) {
                        mb_strtolower(strip_tags($title), 'utf-8'));
        }
 
-       /* function verify_feed_xml($feed_data) {
-               libxml_use_internal_errors(true);
-               $doc = new DOMDocument();
-               $doc->loadXML($feed_data);
-               $error = libxml_get_last_error();
-               libxml_clear_errors();
-               return $error;
-       } */
-
        function cleanup_counters_cache($debug) {
                $result = db_query("DELETE FROM ttrss_counters_cache
                        WHERE feed_id > 0 AND
                                ttrss_cat_counters_cache.owner_uid = ttrss_feed_categories.owner_uid) = 0");
                $crows = db_affected_rows($result);
 
-               _debug("Removed $frows (feeds) $crows (cats) orphaned counter cache entries.");
+               if ($debug) _debug("Removed $frows (feeds) $crows (cats) orphaned counter cache entries.");
        }
 
        function housekeeping_user($owner_uid) {
index f1181f88c0d69bc7f3a5b3e9c89bd6e8fd512b6b..3b3e281ec7932c07f16630df73f8c52d51a41ff3 100755 (executable)
@@ -1,6 +1,5 @@
 <?php
-       /*
-        * WARNING!
+       /* WARNING!
         *
         * If you modify this file, you are ON YOUR OWN!
         *
@@ -21,6 +20,9 @@
                return $url_path;
        }
 
+       /**
+        * @SuppressWarnings(PHPMD.UnusedLocalVariable)
+        */
        function initial_sanity_check() {
 
                $errors = array();
index 1ed9be5504bd2fb1021c713a4b9c285c8ef0f0a5..e955c70b26087cf7d7ca0bd413095c8121c23638 100644 (file)
@@ -23,7 +23,7 @@
        ini_set("session.gc_maxlifetime", $session_expire);
        ini_set("session.cookie_lifetime", min(0, SESSION_COOKIE_LIFETIME));
 
-       function session_get_schema_version($nocache = false) {
+       function session_get_schema_version() {
                global $schema_version;
 
                if (!$schema_version) {
@@ -39,7 +39,7 @@
        function validate_session() {
                if (SINGLE_USER_MODE) return true;
 
-               if (isset($_SESSION["ref_schema_version"]) && $_SESSION["ref_schema_version"] != session_get_schema_version(true)) {
+               if (isset($_SESSION["ref_schema_version"]) && $_SESSION["ref_schema_version"] != session_get_schema_version()) {
                        $_SESSION["login_error_msg"] =
                                __("Session failed to validate (schema version changed)");
                        return false;
@@ -72,7 +72,9 @@
                return true;
        }
 
-
+       /**
+        * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+        */
        function ttrss_open ($s, $n) {
                return true;
        }
                return true;
        }
 
+       /**
+        * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+        */
        function ttrss_gc ($expire) {
                Db::get()->query("DELETE FROM ttrss_sessions WHERE expire < " . time());
 
index 23289f1d1fe539c6c285594c871b9e2f84311790..2245ea02c90ddb27cb948a8017b40a714728e025 100755 (executable)
 
                $_REQUEST['xdebug'] = 1;
 
-               $rc = is_object(update_rss_feed($feed)) ? 0 : 1;
+               $rc = update_rss_feed($feed) != false ? 0 : 1;
 
                exit($rc);
        }