diff options
Diffstat (limited to 'classes/feeds.php')
| -rwxr-xr-x | classes/feeds.php | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/classes/feeds.php b/classes/feeds.php index 2015f2435..194a41c98 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -20,7 +20,7 @@ class Feeds extends Handler_Protected { $feed_id, $is_cat, $search, $error, $feed_last_updated) { - if ($is_cat) $cat_q = "&is_cat=$is_cat"; + $cat_q = $is_cat ? "&is_cat=$is_cat" : ""; if ($search) { $search_q = "&q=$search"; @@ -31,7 +31,7 @@ class Feeds extends Handler_Protected { $reply = ""; $rss_link = htmlspecialchars(get_self_url_prefix() . - "/public.php?op=rss&id=$feed_id$cat_q$search_q"); + "/public.php?op=rss&id=${feed_id}${cat_q}${search_q}"); $reply .= "<span class='left'>"; @@ -115,10 +115,9 @@ class Feeds extends Handler_Protected { $this->mark_timestamp("init"); - $reply = array(); - - $rgba_cache = array(); - $topmost_article_ids = array(); + $reply = []; + $rgba_cache = []; + $topmost_article_ids = []; if (!$offset) $offset = 0; if ($method == "undefined") $method = ""; @@ -147,13 +146,15 @@ class Feeds extends Handler_Protected { } } - @$search = $_REQUEST["query"]; - @$search_language = $_REQUEST["search_language"]; // PGSQL only + $search = $_REQUEST["query"] ?? ""; + $search_language = $_REQUEST["search_language"] ?? ""; // PGSQL only if ($search) { $disable_cache = true; } + $qfh_ret = []; + if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { $handler = PluginHost::getInstance()->get_feed_handler( PluginHost::feed_to_pfeed_id($feed)); @@ -220,19 +221,19 @@ class Feeds extends Handler_Protected { $feed, $cat_view, $search, $last_error, $last_updated); + $reply['content'] = []; + if ($offset == 0) { foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) { $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret); } } - $reply['content'] = []; - $this->mark_timestamp("object header"); $headlines_count = 0; - if (is_object($result)) { + if ($result instanceof PDOStatement) { while ($line = $result->fetch(PDO::FETCH_ASSOC)) { $this->mark_timestamp("article start: " . $line["id"] . " " . $line["title"]); @@ -274,7 +275,7 @@ class Feeds extends Handler_Protected { $label_cache = json_decode($label_cache, true); if ($label_cache) { - if ($label_cache["no-labels"] == 1) + if ($label_cache["no-labels"] ?? false == 1) $labels = array(); else $labels = $label_cache; @@ -295,7 +296,7 @@ class Feeds extends Handler_Protected { $this->mark_timestamp(" labels"); - if (!$line["feed_title"]) $line["feed_title"] = ""; + $line["feed_title"] = $line["feed_title"] ?? ""; $line["buttons_left"] = ""; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { @@ -363,7 +364,7 @@ class Feeds extends Handler_Protected { else $tags = false; - $line["tags_str"] = Article::format_tags_string($tags, $id); + $line["tags_str"] = Article::format_tags_string($tags); $this->mark_timestamp(" tags"); @@ -374,7 +375,7 @@ class Feeds extends Handler_Protected { } //setting feed headline background color, needs to change text color based on dark/light - $fav_color = $line['favicon_avg_color']; + $fav_color = $line['favicon_avg_color'] ?? false; $this->mark_timestamp(" pre-color"); @@ -410,7 +411,7 @@ class Feeds extends Handler_Protected { if (!$headlines_count) { - if (is_object($result)) { + if ($result instanceof PDOStatement) { if ($query_error_override) { $message = $query_error_override; @@ -483,14 +484,14 @@ class Feeds extends Handler_Protected { $reply = array(); $feed = $_REQUEST["feed"]; - $method = $_REQUEST["m"]; + $method = $_REQUEST["m"] ?? ""; $view_mode = $_REQUEST["view_mode"]; $limit = 30; - @$cat_view = $_REQUEST["cat"] == "true"; - @$next_unread_feed = $_REQUEST["nuf"]; - @$offset = $_REQUEST["skip"]; + $cat_view = $_REQUEST["cat"] == "true"; + $next_unread_feed = $_REQUEST["nuf"] ?? 0; + $offset = $_REQUEST["skip"] ?? 0; $order_by = $_REQUEST["order_by"]; - $check_first_id = $_REQUEST["fid"]; + $check_first_id = $_REQUEST["fid"] ?? 0; if (is_numeric($feed)) $feed = (int) $feed; @@ -564,7 +565,7 @@ class Feeds extends Handler_Protected { else $reply['headlines']['id'] = $next_unread_feed; - $reply['headlines']['is_cat'] = (bool) $cat_view; + $reply['headlines']['is_cat'] = $cat_view; $reply['headlines-info'] = ["count" => (int) $headlines_count, "disable_cache" => (bool) $disable_cache]; @@ -772,7 +773,7 @@ class Feeds extends Handler_Protected { Debug::set_loglevel($xdebug); $feed_id = (int)$_REQUEST["feed_id"]; - @$do_update = $_REQUEST["action"] == "do_update"; + $do_update = ($_REQUEST["action"] ?? "") == "do_update"; $csrf_token = $_POST["csrf_token"]; $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); @@ -1087,7 +1088,7 @@ class Feeds extends Handler_Protected { } else if ($n_feed >= 0) { if ($n_feed != 0) { - $match_part = "feed_id = " . (int)$n_feed; + $match_part = sprintf("feed_id = %d", $n_feed); } else { $match_part = "feed_id IS NULL"; } @@ -1794,7 +1795,7 @@ class Feeds extends Handler_Protected { $sanity_interval_qpart $first_id_query_strategy_part ORDER BY $order_by LIMIT 1"; - if ($_REQUEST["debug"]) { + if (!empty($_REQUEST["debug"])) { print "\n*** FIRST ID QUERY ***\n$query\n"; } @@ -1846,7 +1847,7 @@ class Feeds extends Handler_Protected { //if ($_REQUEST["debug"]) print $query; - if ($_REQUEST["debug"]) { + if (!empty($_REQUEST["debug"])) { print "\n*** HEADLINES QUERY ***\n$query\n"; } @@ -1902,7 +1903,7 @@ class Feeds extends Handler_Protected { //if ($_REQUEST["debug"]) print $query; - if ($_REQUEST["debug"]) { + if (!empty($_REQUEST["debug"])) { print "\n*** TAGS QUERY ***\n$query\n"; } @@ -2370,10 +2371,9 @@ class Feeds extends Handler_Protected { function mark_timestamp($label) { - if (!$_REQUEST['timestamps']) + if (empty($_REQUEST['timestamps'])) return; - if (!$this->viewfeed_timestamp) $this->viewfeed_timestamp = hrtime(true); if (!$this->viewfeed_timestamp_last) $this->viewfeed_timestamp_last = hrtime(true); |