From 9743f0efcd4938aacc95863f17b8ca289fe3d5ec Mon Sep 17 00:00:00 2001 From: wn_ Date: Sat, 23 Mar 2024 15:19:58 +0000 Subject: Support doing a prefs page search via Enter. --- classes/Pref_Feeds.php | 10 ++++++---- classes/Pref_Filters.php | 10 ++++++---- classes/Pref_Users.php | 12 +++++++----- 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'classes') diff --git a/classes/Pref_Feeds.php b/classes/Pref_Feeds.php index 36c9bcbc5..8f6423801 100644 --- a/classes/Pref_Feeds.php +++ b/classes/Pref_Feeds.php @@ -904,10 +904,12 @@ class Pref_Feeds extends Handler_Protected {
- - +
+ + +
diff --git a/classes/Pref_Filters.php b/classes/Pref_Filters.php index 1656e92b8..7a477d7db 100644 --- a/classes/Pref_Filters.php +++ b/classes/Pref_Filters.php @@ -665,10 +665,12 @@ class Pref_Filters extends Handler_Protected {
- - +
+ + +
diff --git a/classes/Pref_Users.php b/classes/Pref_Users.php index 78291592d..9532bded5 100644 --- a/classes/Pref_Users.php +++ b/classes/Pref_Users.php @@ -210,11 +210,13 @@ class Pref_Users extends Handler_Administrative {
- - +
+ + +
-- cgit v1.2.3-54-g00ecf From de00a095387499cdb5c8eb9c0ab721d67bd0b3fa Mon Sep 17 00:00:00 2001 From: wn_ Date: Tue, 26 Mar 2024 16:38:05 +0000 Subject: Make implicit nullable parameters explicitly nullable. This is to address a deprecation planned for PHP 8.4. https://wiki.php.net/rfc/deprecate-implicitly-nullable-types --- classes/Counters.php | 18 +++++++++--------- classes/Feeds.php | 2 +- classes/PluginHost.php | 4 ++-- classes/RSSUtils.php | 2 +- classes/Sanitizer.php | 2 +- classes/TimeHelper.php | 4 ++-- classes/UserHelper.php | 4 ++-- include/controls.php | 4 ++-- include/functions.php | 12 ++++++------ 9 files changed, 26 insertions(+), 26 deletions(-) (limited to 'classes') diff --git a/classes/Counters.php b/classes/Counters.php index 948e6ee1d..b3cba162c 100644 --- a/classes/Counters.php +++ b/classes/Counters.php @@ -15,11 +15,11 @@ class Counters { } /** - * @param array $feed_ids - * @param array $label_ids + * @param array|null $feed_ids + * @param array|null $label_ids * @return array> */ - static function get_conditional(array $feed_ids = null, array $label_ids = null): array { + static function get_conditional(?array $feed_ids = null, ?array $label_ids = null): array { return [ ...self::get_global(), ...self::get_virt(), @@ -52,10 +52,10 @@ class Counters { } /** - * @param array $cat_ids + * @param array|null $cat_ids * @return array> */ - private static function get_cats(array $cat_ids = null): array { + private static function get_cats(?array $cat_ids = null): array { $ret = []; /* Labels category */ @@ -141,10 +141,10 @@ class Counters { } /** - * @param array $feed_ids + * @param array|null $feed_ids * @return array> */ - private static function get_feeds(array $feed_ids = null): array { + private static function get_feeds(?array $feed_ids = null): array { $span = Tracer::start(__METHOD__); $ret = []; @@ -300,10 +300,10 @@ class Counters { } /** - * @param array $label_ids + * @param array|null $label_ids * @return array> */ - static function get_labels(array $label_ids = null): array { + static function get_labels(?array $label_ids = null): array { $span = Tracer::start(__METHOD__); $ret = []; diff --git a/classes/Feeds.php b/classes/Feeds.php index 88128cc48..4d4ca3240 100644 --- a/classes/Feeds.php +++ b/classes/Feeds.php @@ -2127,7 +2127,7 @@ class Feeds extends Handler_Protected { $cat->delete(); } - static function _add_cat(string $title, int $owner_uid, int $parent_cat = null, int $order_id = 0): bool { + static function _add_cat(string $title, int $owner_uid, ?int $parent_cat = null, int $order_id = 0): bool { $cat = ORM::for_table('ttrss_feed_categories') ->where('owner_uid', $owner_uid) diff --git a/classes/PluginHost.php b/classes/PluginHost.php index e39273672..2098be4e6 100644 --- a/classes/PluginHost.php +++ b/classes/PluginHost.php @@ -429,7 +429,7 @@ class PluginHost { /** * @param PluginHost::KIND_* $kind */ - function load_all(int $kind, int $owner_uid = null, bool $skip_init = false): void { + function load_all(int $kind, ?int $owner_uid = null, bool $skip_init = false): void { $span = Tracer::start(__METHOD__); $span->setAttribute('func.args', json_encode(func_get_args())); @@ -447,7 +447,7 @@ class PluginHost { /** * @param PluginHost::KIND_* $kind */ - function load(string $classlist, int $kind, int $owner_uid = null, bool $skip_init = false): void { + function load(string $classlist, int $kind, ?int $owner_uid = null, bool $skip_init = false): void { $span = Tracer::start(__METHOD__); $span->setAttribute('func.args', json_encode(func_get_args())); diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php index a2bd36a75..68cbfd26a 100644 --- a/classes/RSSUtils.php +++ b/classes/RSSUtils.php @@ -1511,7 +1511,7 @@ class RSSUtils { * * @return array> An array of filter action arrays with keys "type" and "param" */ - static function get_article_filters(array $filters, string $title, string $content, string $link, string $author, array $tags, array &$matched_rules = null, array &$matched_filters = null): array { + static function get_article_filters(array $filters, string $title, string $content, string $link, string $author, array $tags, ?array &$matched_rules = null, ?array &$matched_filters = null): array { $span = Tracer::start(__METHOD__); $matches = array(); diff --git a/classes/Sanitizer.php b/classes/Sanitizer.php index a7bea9e5f..2a5b031df 100644 --- a/classes/Sanitizer.php +++ b/classes/Sanitizer.php @@ -62,7 +62,7 @@ class Sanitizer { * * @return false|string The HTML, or false if an error occurred. */ - public static function sanitize(string $str, ?bool $force_remove_images = false, int $owner = null, string $site_url = null, array $highlight_words = null, int $article_id = null) { + public static function sanitize(string $str, ?bool $force_remove_images = false, ?int $owner = null, ?string $site_url = null, ?array $highlight_words = null, ?int $article_id = null) { $span = OpenTelemetry\API\Trace\Span::getCurrent(); $span->addEvent("Sanitizer::sanitize"); diff --git a/classes/TimeHelper.php b/classes/TimeHelper.php index 453ee0cee..f1c437831 100644 --- a/classes/TimeHelper.php +++ b/classes/TimeHelper.php @@ -1,7 +1,7 @@ $attributes */ - function select_feeds_cats(string $name, int $default_id = null, array $attributes = [], - bool $include_all_cats = true, string $root_id = null, int $nest_level = 0, string $id = ""): string { + function select_feeds_cats(string $name, ?int $default_id = null, array $attributes = [], + bool $include_all_cats = true, ?string $root_id = null, int $nest_level = 0, string $id = ""): string { $ret = ""; diff --git a/include/functions.php b/include/functions.php index b1aaf769b..d7d829f29 100644 --- a/include/functions.php +++ b/include/functions.php @@ -41,7 +41,7 @@ * * @deprecated by Prefs::get() */ - function get_pref(string $pref_name, int $owner_uid = null) { + function get_pref(string $pref_name, ?int $owner_uid = null) { return Prefs::get($pref_name, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null); } @@ -50,7 +50,7 @@ * * @deprecated by Prefs::set() */ - function set_pref(string $pref_name, $value, int $owner_uid = null, bool $strip_tags = true): bool { + function set_pref(string $pref_name, $value, ?int $owner_uid = null, bool $strip_tags = true): bool { return Prefs::set($pref_name, $value, $owner_uid ? $owner_uid : $_SESSION["uid"], $_SESSION["profile"] ?? null, $strip_tags); } @@ -212,7 +212,7 @@ * * @return false|string The HTML, or false if an error occurred. */ - function sanitize(string $str, bool $force_remove_images = false, int $owner = null, string $site_url = null, array $highlight_words = null, int $article_id = null) { + function sanitize(string $str, bool $force_remove_images = false, ?int $owner = null, ?string $site_url = null, ?array $highlight_words = null, ?int $article_id = null) { return Sanitizer::sanitize($str, $force_remove_images, $owner, $site_url, $highlight_words, $article_id); } @@ -251,17 +251,17 @@ } /** @deprecated by UserHelper::authenticate() */ - function authenticate_user(string $login = null, string $password = null, bool $check_only = false, string $service = null): bool { + function authenticate_user(?string $login = null, ?string $password = null, bool $check_only = false, ?string $service = null): bool { return UserHelper::authenticate($login, $password, $check_only, $service); } /** @deprecated by TimeHelper::smart_date_time() */ - function smart_date_time(int $timestamp, int $tz_offset = 0, int $owner_uid = null, bool $eta_min = false): string { + function smart_date_time(int $timestamp, int $tz_offset = 0, ?int $owner_uid = null, bool $eta_min = false): string { return TimeHelper::smart_date_time($timestamp, $tz_offset, $owner_uid, $eta_min); } /** @deprecated by TimeHelper::make_local_datetime() */ - function make_local_datetime(string $timestamp, bool $long, int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string { + function make_local_datetime(string $timestamp, bool $long, ?int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string { return TimeHelper::make_local_datetime($timestamp, $long, $owner_uid, $no_smart_dt, $eta_min); } -- cgit v1.2.3-54-g00ecf From ae5e7568f59b9ecbefe0c86ffc7d314fd78d114c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Apr 2024 00:39:37 +0300 Subject: force-set absolute path for local cache if CACHE_DIR config value is relative --- classes/Cache_Local.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/Cache_Local.php b/classes/Cache_Local.php index 8ac634a3e..dd3548111 100644 --- a/classes/Cache_Local.php +++ b/classes/Cache_Local.php @@ -11,7 +11,14 @@ class Cache_Local implements Cache_Adapter { } public function set_dir(string $dir) : void { - $this->dir = Config::get(Config::CACHE_DIR) . "/" . basename(clean($dir)); + $cache_dir = Config::get(Config::CACHE_DIR); + + // use absolute path local to current dir if CACHE_DIR is relative + // TODO: maybe add a special method to Config() for this? + if ($cache_dir[0] != '/') + $cache_dir = dirname(__DIR__) . "/$cache_dir"; + + $this->dir = $cache_dir . "/" . basename(clean($dir)); $this->make_dir(); } -- cgit v1.2.3-54-g00ecf From ac55a15c8423cd8ab1535062db7093bf32618a33 Mon Sep 17 00:00:00 2001 From: wn_ Date: Tue, 16 Apr 2024 14:23:07 +0000 Subject: Switch 2 more implicitly nullable params to explicitly nullable. Missed in https://gitlab.tt-rss.org/tt-rss/tt-rss/-/merge_requests/26 . https://wiki.php.net/rfc/deprecate-implicitly-nullable-types --- classes/Prefs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Prefs.php b/classes/Prefs.php index e315802a9..f778f0f84 100644 --- a/classes/Prefs.php +++ b/classes/Prefs.php @@ -193,14 +193,14 @@ class Prefs { /** * @return array> */ - static function get_all(int $owner_uid, int $profile_id = null) { + static function get_all(int $owner_uid, ?int $profile_id = null) { return self::get_instance()->_get_all($owner_uid, $profile_id); } /** * @return array> */ - private function _get_all(int $owner_uid, int $profile_id = null) { + private function _get_all(int $owner_uid, ?int $profile_id = null) { $rv = []; $ref = new ReflectionClass(get_class($this)); -- cgit v1.2.3-54-g00ecf From 7a5ea2a2b9ea9e1d9ff5134d626c9a0c4a905e0e Mon Sep 17 00:00:00 2001 From: wn_ Date: Wed, 8 May 2024 23:59:25 +0000 Subject: Check 'head' and 'body' when searching HTML for feed links. YouTube, for some reason, puts theirs in 'body'. --- classes/Feeds.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Feeds.php b/classes/Feeds.php index 4d4ca3240..41351fbde 100644 --- a/classes/Feeds.php +++ b/classes/Feeds.php @@ -2097,8 +2097,8 @@ class Feeds extends Handler_Protected { $doc = new DOMDocument(); if (@$doc->loadHTML($content)) { $xpath = new DOMXPath($doc); - $entries = $xpath->query('/html/head/link[@rel="alternate" and '. - '(contains(@type,"rss") or contains(@type,"atom"))]|/html/head/link[@rel="feed"]'); + $entries = $xpath->query('/html/*[self::head or self::body]/link[@rel="alternate" and '. + '(contains(@type,"rss") or contains(@type,"atom"))]|/html/*[self::head or self::body]/link[@rel="feed"]'); foreach ($entries as $entry) { if ($entry->hasAttribute('href')) { -- cgit v1.2.3-54-g00ecf From 5e7713a65818154470c2afab7798ebf65bacadc3 Mon Sep 17 00:00:00 2001 From: wn_ Date: Thu, 16 May 2024 15:48:21 +0000 Subject: Add option to debug feeds in 'Feeds with update errors' dialog. Also, prevent opening that dialog from modifying the URL. --- classes/Feeds.php | 4 ++-- js/CommonDialogs.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Feeds.php b/classes/Feeds.php index 41351fbde..64674b2d2 100644 --- a/classes/Feeds.php +++ b/classes/Feeds.php @@ -453,7 +453,7 @@ class Feeds extends Handler_Protected { if ($num_errors > 0) { $reply['content'] .= "
"; - $reply['content'] .= "" . + $reply['content'] .= "" . __('Some feeds have update errors (click for details)') . ""; } $reply['content'] .= "

"; @@ -603,7 +603,7 @@ class Feeds extends Handler_Protected { if ($num_errors > 0) { $reply['headlines']['content'] .= "
"; - $reply['headlines']['content'] .= "". + $reply['headlines']['content'] .= "". __('Some feeds have update errors (click for details)').""; } $reply['headlines']['content'] .= "

"; diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 989a61539..f666eda36 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -251,6 +251,27 @@ const CommonDialogs = { alert(__("No feeds selected.")); } }, + debugSelected: function() { + const sel_rows = this.getSelectedFeeds(); + + if (sel_rows.length > 0) { + if (confirm(__("Debug selected feeds?"))) { + Notify.progress("Opening debugger for selected feeds...", true); + + for (let i = 0; i < sel_rows.length; i++) { + /* global __csrf_token */ + App.postOpenWindow("backend.php", { + op: "Feeds", + method: "updatedebugger", + feed_id: sel_rows[i], + csrf_token: __csrf_token, + }); + } + } + } else { + alert(__("No feeds selected.")); + } + }, content: `
@@ -290,6 +311,9 @@ const CommonDialogs = { + -- cgit v1.2.3-54-g00ecf