diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Cache_Local.php | 9 | ||||
-rw-r--r-- | classes/Counters.php | 18 | ||||
-rw-r--r-- | classes/Feeds.php | 10 | ||||
-rw-r--r-- | classes/PluginHost.php | 4 | ||||
-rw-r--r-- | classes/Pref_Feeds.php | 10 | ||||
-rw-r--r-- | classes/Pref_Filters.php | 10 | ||||
-rw-r--r-- | classes/Pref_Users.php | 12 | ||||
-rw-r--r-- | classes/Prefs.php | 4 | ||||
-rw-r--r-- | classes/RSSUtils.php | 2 | ||||
-rw-r--r-- | classes/Sanitizer.php | 2 | ||||
-rw-r--r-- | classes/TimeHelper.php | 4 | ||||
-rw-r--r-- | classes/UserHelper.php | 4 |
12 files changed, 51 insertions, 38 deletions
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(); } 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<int> $feed_ids - * @param array<int> $label_ids + * @param array<int>|null $feed_ids + * @param array<int>|null $label_ids * @return array<int, array<string, int|string>> */ - 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<int> $cat_ids + * @param array<int>|null $cat_ids * @return array<int, array<string, int|string>> */ - 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<int> $feed_ids + * @param array<int>|null $feed_ids * @return array<int, array<string, int|string>> */ - 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<int> $label_ids + * @param array<int>|null $label_ids * @return array<int, array<string, int|string>> */ - 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..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'] .= "<br/>"; - $reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">" . + $reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors(); return false\">" . __('Some feeds have update errors (click for details)') . "</a>"; } $reply['content'] .= "</span></p></div>"; @@ -603,7 +603,7 @@ class Feeds extends Handler_Protected { if ($num_errors > 0) { $reply['headlines']['content'] .= "<br/>"; - $reply['headlines']['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">". + $reply['headlines']['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors(); return false\">". __('Some feeds have update errors (click for details)')."</a>"; } $reply['headlines']['content'] .= "</span></p>"; @@ -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')) { @@ -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/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 { <div dojoType="dijit.layout.BorderContainer" gutters="false"> <div region='top' dojoType="fox.Toolbar"> <div style='float : right'> - <input dojoType="dijit.form.TextBox" id="feed_search" size="20" type="search" - value="<?= htmlspecialchars($feed_search) ?>"> - <button dojoType="dijit.form.Button" onclick="dijit.byId('feedTree').reload()"> - <?= __('Search') ?></button> + <form dojoType="dijit.form.Form" onsubmit="dijit.byId('feedTree').reload(); return false;"> + <input dojoType="dijit.form.TextBox" id="feed_search" size="20" type="search" + value="<?= htmlspecialchars($feed_search) ?>"> + <button dojoType="dijit.form.Button" type="submit"> + <?= __('Search') ?></button> + </form> </div> <div dojoType="fox.form.DropDownButton"> 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 { <div dojoType='fox.Toolbar'> <div style='float : right; padding-right : 4px;'> - <input dojoType="dijit.form.TextBox" id="filter_search" size="20" type="search" - value="<?= htmlspecialchars($filter_search) ?>"> - <button dojoType="dijit.form.Button" onclick="dijit.byId('filterTree').reload()"> - <?= __('Search') ?></button> + <form dojoType="dijit.form.Form" onsubmit="dijit.byId('filterTree').reload(); return false;"> + <input dojoType="dijit.form.TextBox" id="filter_search" size="20" type="search" + value="<?= htmlspecialchars($filter_search) ?>"> + <button dojoType="dijit.form.Button" type="submit"> + <?= __('Search') ?></button> + </form> </div> <div dojoType="fox.form.DropDownButton"> 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 { <div dojoType='fox.Toolbar'> <div style='float : right'> - <input dojoType='dijit.form.TextBox' id='user_search' size='20' type='search' - value="<?= htmlspecialchars($user_search) ?>"> - <button dojoType='dijit.form.Button' onclick='Users.reload()'> - <?= __('Search') ?> - </button> + <form dojoType="dijit.form.Form" onsubmit="Users.reload(); return false;"> + <input dojoType='dijit.form.TextBox' id='user_search' size='20' type='search' + value="<?= htmlspecialchars($user_search) ?>"> + <button dojoType='dijit.form.Button' type='submit'> + <?= __('Search') ?> + </button> + </form> </div> <div dojoType='fox.form.DropDownButton'> 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<int, array<string, bool|int|null|string>> */ - 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<int, array<string, bool|int|null|string>> */ - 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)); 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<int, array<string, string>> 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 @@ <?php class TimeHelper { - static function smart_date_time(int $timestamp, int $tz_offset = 0, int $owner_uid = null, bool $eta_min = false): string { + static function smart_date_time(int $timestamp, int $tz_offset = 0, ?int $owner_uid = null, bool $eta_min = false): string { if (!$owner_uid) $owner_uid = $_SESSION['uid']; if ($eta_min && time() + $tz_offset - $timestamp < 3600) { @@ -21,7 +21,7 @@ class TimeHelper { } } - static function make_local_datetime(?string $timestamp, bool $long, int $owner_uid = null, + static function make_local_datetime(?string $timestamp, bool $long, ?int $owner_uid = null, bool $no_smart_dt = false, bool $eta_min = false): string { if (!$owner_uid) $owner_uid = $_SESSION['uid']; diff --git a/classes/UserHelper.php b/classes/UserHelper.php index b47f2853e..7cc7b3150 100644 --- a/classes/UserHelper.php +++ b/classes/UserHelper.php @@ -58,7 +58,7 @@ class UserHelper { } } - static function authenticate(string $login = null, string $password = null, bool $check_only = false, string $service = null): bool { + static function authenticate(?string $login = null, ?string $password = null, bool $check_only = false, ?string $service = null): bool { if (!Config::get(Config::SINGLE_USER_MODE)) { $user_id = false; $auth_module = false; @@ -130,7 +130,7 @@ class UserHelper { } } - static function load_user_plugins(int $owner_uid, PluginHost $pluginhost = null): void { + static function load_user_plugins(int $owner_uid, ?PluginHost $pluginhost = null): void { if (!$pluginhost) $pluginhost = PluginHost::getInstance(); |