From 8f8142df29fbc43fc277b268524560ef93e70b64 Mon Sep 17 00:00:00 2001 From: sam302psu Date: Tue, 2 Mar 2021 17:36:57 +0300 Subject: [PATCH 1/2] Fix undefined array key warnings when using iOS app Use coalesce operator and empty string/default value to fix undefined array key warnings filling up logs when using iOS app to access api. --- classes/api.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/api.php b/classes/api.php index 991682191..7a11fbd19 100755 --- a/classes/api.php +++ b/classes/api.php @@ -98,8 +98,8 @@ class API extends Handler { } function getUnread() { - $feed_id = clean($_REQUEST["feed_id"]); - $is_cat = clean($_REQUEST["is_cat"]); + $feed_id = clean($_REQUEST["feed_id"] ?? ""); + $is_cat = clean($_REQUEST["is_cat"] ?? ""); if ($feed_id) { $this->_wrap(self::STATUS_OK, array("unread" => getFeedUnread($feed_id, $is_cat))); @@ -188,15 +188,15 @@ class API extends Handler { if (is_numeric($feed_id)) $feed_id = (int) $feed_id; - $limit = (int)clean($_REQUEST["limit"]); + $limit = (int)clean($_REQUEST["limit"] ?? ""); if (!$limit || $limit >= 200) $limit = 200; - $offset = (int)clean($_REQUEST["skip"]); + $offset = (int)clean($_REQUEST["skip"] ?? ""); $filter = clean($_REQUEST["filter"] ?? ""); $is_cat = self::_param_to_bool(clean($_REQUEST["is_cat"] ?? false)); $show_excerpt = self::_param_to_bool(clean($_REQUEST["show_excerpt"] ?? false)); - $show_content = self::_param_to_bool(clean($_REQUEST["show_content"])); + $show_content = self::_param_to_bool(clean($_REQUEST["show_content"] ?? false)); /* all_articles, unread, adaptive, marked, updated */ $view_mode = clean($_REQUEST["view_mode"] ?? null); $include_attachments = self::_param_to_bool(clean($_REQUEST["include_attachments"] ?? false)); From 57fdf032e95a4af1904827fc1a0234127e040455 Mon Sep 17 00:00:00 2001 From: sam302psu Date: Tue, 2 Mar 2021 18:44:13 +0300 Subject: [PATCH 2/2] changed skip and limit to coalesce to 0 instead of "" --- classes/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/api.php b/classes/api.php index 7a11fbd19..952c97166 100755 --- a/classes/api.php +++ b/classes/api.php @@ -188,11 +188,11 @@ class API extends Handler { if (is_numeric($feed_id)) $feed_id = (int) $feed_id; - $limit = (int)clean($_REQUEST["limit"] ?? ""); + $limit = (int)clean($_REQUEST["limit"] ?? 0 ); if (!$limit || $limit >= 200) $limit = 200; - $offset = (int)clean($_REQUEST["skip"] ?? ""); + $offset = (int)clean($_REQUEST["skip"] ?? 0); $filter = clean($_REQUEST["filter"] ?? ""); $is_cat = self::_param_to_bool(clean($_REQUEST["is_cat"] ?? false)); $show_excerpt = self::_param_to_bool(clean($_REQUEST["show_excerpt"] ?? false));