From 8727fb3ba8a28da48c71bdd39166b9aeb3c3d986 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 8 Jan 2024 22:46:13 +0000 Subject: [PATCH] Clean up some unused variables. This is essentially https://gitlab.tt-rss.org/wn/tt-rss/-/commit/1ccc0c8c1af04dd9654b585c6d07e3a75d944a0c without the renames and some other things related to Psalm. --- backend.php | 2 -- classes/API.php | 14 -------------- classes/Article.php | 2 +- classes/Db_Migrations.php | 2 +- classes/DiskCache.php | 2 +- classes/FeedParser.php | 1 - classes/Feeds.php | 11 ++--------- classes/Mailer.php | 2 +- classes/OPML.php | 4 ---- classes/Pref_Prefs.php | 7 ++----- classes/Prefs.php | 2 -- classes/RSSUtils.php | 5 ++--- classes/UserHelper.php | 1 - include/sessions.php | 2 +- index.php | 2 +- plugins/af_psql_trgm/init.php | 2 +- public.php | 2 -- update.php | 3 --- 18 files changed, 13 insertions(+), 53 deletions(-) diff --git a/backend.php b/backend.php index 44d4284c3..5aceb46dc 100644 --- a/backend.php +++ b/backend.php @@ -32,8 +32,6 @@ startup_gettext(); - $script_started = microtime(true); - if (!init_plugins()) { return; } diff --git a/classes/API.php b/classes/API.php index 3a3ae0e63..45820f300 100644 --- a/classes/API.php +++ b/classes/API.php @@ -691,20 +691,6 @@ class API extends Handler { } } - $params = array( - "feed" => $feed_id, - "limit" => $limit, - "view_mode" => $view_mode, - "cat_view" => $is_cat, - "search" => $search, - "override_order" => $order, - "offset" => $offset, - "since_id" => $since_id, - "include_children" => $include_nested, - "check_first_id" => $check_first_id, - "skip_first_id_check" => $skip_first_id_check - ); - $qfh_ret = []; if (!$is_cat && is_numeric($feed_id) && $feed_id < PLUGIN_FEED_BASE_INDEX && $feed_id > LABEL_BASE_INDEX) { diff --git a/classes/Article.php b/classes/Article.php index 0b446479b..c496ea131 100644 --- a/classes/Article.php +++ b/classes/Article.php @@ -606,7 +606,7 @@ class Article extends Handler_Protected { foreach ($elems as $e) { if ($e->nodeName == "iframe") { $matches = []; - if ($rrr = preg_match("/\/embed\/([\w-]+)/", $e->getAttribute("src"), $matches)) { + if (preg_match("/\/embed\/([\w-]+)/", $e->getAttribute("src"), $matches)) { $article_image = "https://img.youtube.com/vi/" . $matches[1] . "/hqdefault.jpg"; $article_stream = "https://youtu.be/" . $matches[1]; $article_kind = Article::ARTICLE_KIND_YOUTUBE; diff --git a/classes/Db_Migrations.php b/classes/Db_Migrations.php index d63736987..c2a8c326d 100644 --- a/classes/Db_Migrations.php +++ b/classes/Db_Migrations.php @@ -35,7 +35,7 @@ class Db_Migrations { $sth = $this->pdo->query("SELECT * FROM {$this->migrations_table}"); - if ($res = $sth->fetch()) { + if ($sth->fetch()) { $sth = $this->pdo->prepare("UPDATE {$this->migrations_table} SET schema_version = ?"); } else { $sth = $this->pdo->prepare("INSERT INTO {$this->migrations_table} (schema_version) VALUES (?)"); diff --git a/classes/DiskCache.php b/classes/DiskCache.php index 290fbd9c3..196eed02d 100644 --- a/classes/DiskCache.php +++ b/classes/DiskCache.php @@ -206,7 +206,7 @@ class DiskCache implements Cache_Adapter { } public function __construct(string $dir) { - foreach (PluginHost::getInstance()->get_plugins() as $n => $p) { + foreach (PluginHost::getInstance()->get_plugins() as $p) { if (implements_interface($p, "Cache_Adapter")) { /** @var Cache_Adapter $p */ diff --git a/classes/FeedParser.php b/classes/FeedParser.php index 4b9c63f56..729d77206 100644 --- a/classes/FeedParser.php +++ b/classes/FeedParser.php @@ -52,7 +52,6 @@ class FeedParser { } function init() : void { - $root = $this->doc->firstChild; $xpath = new DOMXPath($this->doc); $xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom'); $xpath->registerNamespace('atom03', 'http://purl.org/atom/ns#'); diff --git a/classes/Feeds.php b/classes/Feeds.php index c673f0bd7..88128cc48 100644 --- a/classes/Feeds.php +++ b/classes/Feeds.php @@ -1132,8 +1132,6 @@ class Feeds extends Handler_Protected { return ["code" => 8]; } - $pdo = Db::pdo(); - $url = UrlHelper::validate($url); if (!$url) return ["code" => 2]; @@ -1277,8 +1275,6 @@ class Feeds extends Handler_Protected { */ static function _find_by_title(string $title, bool $cat = false, int $owner_uid = 0) { - $res = false; - if ($cat) { $res = ORM::for_table('ttrss_feed_categories') ->where('owner_uid', $owner_uid ? $owner_uid : $_SESSION['uid']) @@ -1735,7 +1731,6 @@ class Feeds extends Handler_Protected { $vfeed_query_part = $override_vfeed; } - $feed_title = ""; $feed_site_url = ""; $last_error = ""; $last_updated = ""; @@ -2157,7 +2152,7 @@ class Feeds extends Handler_Protected { } static function _clear_access_keys(int $owner_uid): void { - $key = ORM::for_table('ttrss_access_keys') + ORM::for_table('ttrss_access_keys') ->where('owner_uid', $owner_uid) ->delete_many(); } @@ -2168,7 +2163,7 @@ class Feeds extends Handler_Protected { * @see Handler_Public#generate_syndicated_feed() */ static function _update_access_key(string $feed_id, bool $is_cat, int $owner_uid): ?string { - $key = ORM::for_table('ttrss_access_keys') + ORM::for_table('ttrss_access_keys') ->where('owner_uid', $owner_uid) ->where('feed_id', $feed_id) ->where('is_cat', $is_cat) @@ -2212,8 +2207,6 @@ class Feeds extends Handler_Protected { if (!$purge_interval) $purge_interval = self::_get_purge_interval($feed_id); $pdo = Db::pdo(); - - $owner_uid = false; $rows_deleted = 0; $sth = $pdo->prepare("SELECT owner_uid FROM ttrss_feeds WHERE id = ?"); diff --git a/classes/Mailer.php b/classes/Mailer.php index ac5c641eb..569b6cee2 100644 --- a/classes/Mailer.php +++ b/classes/Mailer.php @@ -12,7 +12,7 @@ class Mailer { $to_address = $params["to_address"]; $subject = $params["subject"]; $message = $params["message"]; - $message_html = $params["message_html"] ?? ""; + // $message_html = $params["message_html"] ?? ""; $from_name = $params["from_name"] ?? Config::get(Config::SMTP_FROM_NAME); $from_address = $params["from_address"] ?? Config::get(Config::SMTP_FROM_ADDRESS); $additional_headers = $params["headers"] ?? []; diff --git a/classes/OPML.php b/classes/OPML.php index b9f5f2eab..6b95a89db 100644 --- a/classes/OPML.php +++ b/classes/OPML.php @@ -612,8 +612,6 @@ class OPML extends Handler_Protected { function opml_import(int $owner_uid, string $filename = "") { if (!$owner_uid) return; - $doc = false; - if (!$filename) { if ($_FILES['opml_file']['error'] != 0) { print_error(T_sprintf("Upload failed with error code %d", @@ -644,8 +642,6 @@ class OPML extends Handler_Protected { return false; } - $loaded = false; - $doc = new DOMDocument(); if (version_compare(PHP_VERSION, '8.0.0', '<')) { diff --git a/classes/Pref_Prefs.php b/classes/Pref_Prefs.php index c9eb89631..6985c49e4 100644 --- a/classes/Pref_Prefs.php +++ b/classes/Pref_Prefs.php @@ -1223,13 +1223,10 @@ class Pref_Prefs extends Handler_Protected { $proc = proc_open("git clone " . escapeshellarg($plugin['clone_url']) . " " . $tmp_dir, $descriptorspec, $pipes, sys_get_temp_dir()); - $status = 0; - if (is_resource($proc)) { $rv["stdout"] = stream_get_contents($pipes[1]); $rv["stderr"] = stream_get_contents($pipes[2]); - $status = proc_close($proc); - $rv["git_status"] = $status; + $rv["git_status"] = proc_close($proc); // yeah I know about mysterious RC = -1 if (file_exists("$tmp_dir/init.php")) { @@ -1546,7 +1543,7 @@ class Pref_Prefs extends Handler_Protected { } function deleteAppPasswords(): void { - $passwords = ORM::for_table('ttrss_app_passwords') + ORM::for_table('ttrss_app_passwords') ->where('owner_uid', $_SESSION['uid']) ->where_in('id', $_REQUEST['ids'] ?? []) ->delete_many(); diff --git a/classes/Prefs.php b/classes/Prefs.php index 6dc8a1342..c5cf16598 100644 --- a/classes/Prefs.php +++ b/classes/Prefs.php @@ -260,8 +260,6 @@ class Prefs { list ($def_val, $type_hint) = self::_DEFAULTS[$pref_name]; - $cached_value = $this->_get_cache($pref_name, $owner_uid, $profile_id); - if ($this->_is_cached($pref_name, $owner_uid, $profile_id)) { $cached_value = $this->_get_cache($pref_name, $owner_uid, $profile_id); return Config::cast_to($cached_value, $type_hint); diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php index ea3c074ab..751e1d9c7 100644 --- a/classes/RSSUtils.php +++ b/classes/RSSUtils.php @@ -873,7 +873,7 @@ class RSSUtils { $pdo->commit(); - $entry_obj = ORM::for_table('ttrss_entries') + ORM::for_table('ttrss_entries') ->find_one($base_entry_id) ->set('date_updated', Db::NOW()) ->save(); @@ -1028,7 +1028,7 @@ class RSSUtils { WHERE guid IN (?, ?, ?)"); $csth->execute([$entry_guid, $entry_guid_hashed, $entry_guid_hashed_compat]); - if (!$row = $csth->fetch()) { + if (!$csth->fetch()) { Debug::log("base guid [$entry_guid or $entry_guid_hashed] not found, creating...", Debug::LOG_VERBOSE); @@ -1746,7 +1746,6 @@ class RSSUtils { /** migrates favicons from legacy storage in feed-icons/ to cache/feed-icons/using new naming (sans .ico suffix) */ static function migrate_feed_icons() : void { $old_dir = Config::get(Config::ICONS_DIR); - $new_dir = Config::get(Config::CACHE_DIR) . '/feed-icons'; $dh = opendir($old_dir); diff --git a/classes/UserHelper.php b/classes/UserHelper.php index 4d9f30548..b47f2853e 100644 --- a/classes/UserHelper.php +++ b/classes/UserHelper.php @@ -250,7 +250,6 @@ class UserHelper { static function reset_password(int $uid, bool $format_output = false, string $new_password = ""): void { $user = ORM::for_table('ttrss_users')->find_one($uid); - $message = ""; if ($user) { diff --git a/include/sessions.php b/include/sessions.php index 48afd0a8b..605ca9325 100644 --- a/include/sessions.php +++ b/include/sessions.php @@ -93,7 +93,7 @@ $sth = \Db::pdo()->prepare("SELECT id FROM ttrss_sessions WHERE id=?"); $sth->execute([$id]); - if ($row = $sth->fetch()) { + if ($sth->fetch()) { $sth = \Db::pdo()->prepare("UPDATE ttrss_sessions SET data=?, expire=? WHERE id=?"); $sth->execute([$data, $expire, $id]); } else { diff --git a/index.php b/index.php index e9f85264e..bcd50f854 100644 --- a/index.php +++ b/index.php @@ -45,7 +45,7 @@