Switch from null to false as the default for missing bool params.

This commit is contained in:
wn_ 2021-11-18 18:23:44 +00:00
parent cd71292610
commit d532eb773b
5 changed files with 24 additions and 24 deletions

View File

@ -103,7 +103,7 @@ class API extends Handler {
function getUnread(): bool {
$feed_id = clean($_REQUEST["feed_id"] ?? "");
$is_cat = self::_param_to_bool($_REQUEST["is_cat"] ?? null);
$is_cat = self::_param_to_bool($_REQUEST["is_cat"] ?? false);
if ($feed_id) {
return $this->_wrap(self::STATUS_OK, array("unread" => getFeedUnread($feed_id, $is_cat)));
@ -119,10 +119,10 @@ class API extends Handler {
function getFeeds(): bool {
$cat_id = (int) clean($_REQUEST["cat_id"]);
$unread_only = self::_param_to_bool($_REQUEST["unread_only"] ?? null);
$unread_only = self::_param_to_bool($_REQUEST["unread_only"] ?? false);
$limit = (int) clean($_REQUEST["limit"] ?? 0);
$offset = (int) clean($_REQUEST["offset"] ?? 0);
$include_nested = self::_param_to_bool($_REQUEST["include_nested"] ?? null);
$include_nested = self::_param_to_bool($_REQUEST["include_nested"] ?? false);
$feeds = $this->_api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested);
@ -130,9 +130,9 @@ class API extends Handler {
}
function getCategories(): bool {
$unread_only = self::_param_to_bool($_REQUEST["unread_only"] ?? null);
$enable_nested = self::_param_to_bool($_REQUEST["enable_nested"] ?? null);
$include_empty = self::_param_to_bool($_REQUEST["include_empty"] ?? null);
$unread_only = self::_param_to_bool($_REQUEST["unread_only"] ?? false);
$enable_nested = self::_param_to_bool($_REQUEST["enable_nested"] ?? false);
$include_empty = self::_param_to_bool($_REQUEST["include_empty"] ?? false);
// TODO do not return empty categories, return Uncategorized and standard virtual cats
@ -197,20 +197,20 @@ class API extends Handler {
$offset = (int)clean($_REQUEST["skip"] ?? 0);
$filter = clean($_REQUEST["filter"] ?? "");
$is_cat = self::_param_to_bool($_REQUEST["is_cat"] ?? null);
$show_excerpt = self::_param_to_bool($_REQUEST["show_excerpt"] ?? null);
$show_content = self::_param_to_bool($_REQUEST["show_content"] ?? null);
$is_cat = self::_param_to_bool($_REQUEST["is_cat"] ?? false);
$show_excerpt = self::_param_to_bool($_REQUEST["show_excerpt"] ?? false);
$show_content = self::_param_to_bool($_REQUEST["show_content"] ?? false);
/* all_articles, unread, adaptive, marked, updated */
$view_mode = clean($_REQUEST["view_mode"] ?? null);
$include_attachments = self::_param_to_bool($_REQUEST["include_attachments"] ?? null);
$view_mode = clean($_REQUEST["view_mode"] ?? false);
$include_attachments = self::_param_to_bool($_REQUEST["include_attachments"] ?? false);
$since_id = (int)clean($_REQUEST["since_id"] ?? 0);
$include_nested = self::_param_to_bool($_REQUEST["include_nested"] ?? null);
$include_nested = self::_param_to_bool($_REQUEST["include_nested"] ?? false);
$sanitize_content = self::_param_to_bool($_REQUEST["sanitize"] ?? true);
$force_update = self::_param_to_bool($_REQUEST["force_update"] ?? null);
$has_sandbox = self::_param_to_bool($_REQUEST["has_sandbox"] ?? null);
$force_update = self::_param_to_bool($_REQUEST["force_update"] ?? false);
$has_sandbox = self::_param_to_bool($_REQUEST["has_sandbox"] ?? false);
$excerpt_length = (int)clean($_REQUEST["excerpt_length"] ?? 0);
$check_first_id = (int)clean($_REQUEST["check_first_id"] ?? 0);
$include_header = self::_param_to_bool($_REQUEST["include_header"] ?? null);
$include_header = self::_param_to_bool($_REQUEST["include_header"] ?? false);
$_SESSION['hasSandbox'] = $has_sandbox;
@ -409,7 +409,7 @@ class API extends Handler {
function catchupFeed(): bool {
$feed_id = clean($_REQUEST["feed_id"]);
$is_cat = self::_param_to_bool($_REQUEST["is_cat"] ?? null);
$is_cat = self::_param_to_bool($_REQUEST["is_cat"] ?? false);
$mode = clean($_REQUEST["mode"] ?? "");
if (!in_array($mode, ["all", "1day", "1week", "2week"]))

View File

@ -456,7 +456,7 @@ class Feeds extends Handler_Protected {
$method = $_REQUEST["m"] ?? "";
$view_mode = $_REQUEST["view_mode"] ?? "";
$limit = 30;
$cat_view = self::_param_to_bool($_REQUEST["cat"] ?? null);
$cat_view = self::_param_to_bool($_REQUEST["cat"] ?? false);
$next_unread_feed = $_REQUEST["nuf"] ?? 0;
$offset = (int) ($_REQUEST["skip"] ?? 0);
$order_by = $_REQUEST["order_by"] ?? "";

View File

@ -307,7 +307,7 @@ class Handler_Public extends Handler {
function rss(): void {
$feed = clean($_REQUEST["id"]);
$key = clean($_REQUEST["key"]);
$is_cat = self::_param_to_bool($_REQUEST["is_cat"] ?? null);
$is_cat = self::_param_to_bool($_REQUEST["is_cat"] ?? false);
$limit = (int)clean($_REQUEST["limit"] ?? 0);
$offset = (int)clean($_REQUEST["offset"] ?? 0);

View File

@ -47,7 +47,7 @@ class Pref_Feeds extends Handler_Protected {
$search = "";
// first one is set by API
$show_empty_cats = self::_param_to_bool($_REQUEST['force_show_empty'] ?? null) ||
$show_empty_cats = self::_param_to_bool($_REQUEST['force_show_empty'] ?? false) ||
(clean($_REQUEST['mode'] ?? 0) != 2 && !$search);
$items = [];
@ -208,7 +208,7 @@ class Pref_Feeds extends Handler_Protected {
}
if ($enable_cats) {
$show_empty_cats = self::_param_to_bool($_REQUEST['force_show_empty'] ?? null) ||
$show_empty_cats = self::_param_to_bool($_REQUEST['force_show_empty'] ?? false) ||
(clean($_REQUEST['mode'] ?? 0) != 2 && !$search);
$feed_categories = ORM::for_table('ttrss_feed_categories')
@ -1260,7 +1260,7 @@ class Pref_Feeds extends Handler_Protected {
function regenFeedKey(): void {
$feed_id = clean($_REQUEST['id']);
$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? null);
$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? false);
$new_key = Feeds::_update_access_key($feed_id, $is_cat, $_SESSION["uid"]);
@ -1269,7 +1269,7 @@ class Pref_Feeds extends Handler_Protected {
function getSharedURL(): void {
$feed_id = clean($_REQUEST['id']);
$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? null);
$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? false);
$search = clean($_REQUEST['search']);
$link = Config::get_self_url() . "/public.php?" . http_build_query([

View File

@ -173,7 +173,7 @@ class RPC extends Handler_Protected {
}
function sanityCheck(): void {
$_SESSION["hasSandbox"] = self::_param_to_bool($_REQUEST["hasSandbox"] ?? null);
$_SESSION["hasSandbox"] = self::_param_to_bool($_REQUEST["hasSandbox"] ?? false);
$_SESSION["clientTzOffset"] = clean($_REQUEST["clientTzOffset"]);
$client_location = $_REQUEST["clientLocation"];
@ -225,7 +225,7 @@ class RPC extends Handler_Protected {
function catchupFeed(): void {
$feed_id = clean($_REQUEST['feed_id']);
$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? null);
$is_cat = self::_param_to_bool($_REQUEST['is_cat'] ?? false);
$mode = clean($_REQUEST['mode'] ?? '');
$search_query = clean($_REQUEST['search_query']);
$search_lang = clean($_REQUEST['search_lang']);