summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-09 08:47:41 +0300
committerAndrew Dolgov <[email protected]>2021-02-09 08:47:41 +0300
commitaba028a37539f830f7298dd516d3e27973c2151c (patch)
tree4f4456f26f2d29456becfc4c19876091d23c8d2d
parentf6f0f216641c2e47f429a05f0d5e2c39d0cd8f89 (diff)
api: fix some php8 warnings (3)
-rw-r--r--api/index.php10
-rwxr-xr-xclasses/api.php26
2 files changed, 18 insertions, 18 deletions
diff --git a/api/index.php b/api/index.php
index 8e85919c6..77552af46 100644
--- a/api/index.php
+++ b/api/index.php
@@ -41,11 +41,11 @@
}
} else {
// Accept JSON only
- $input = json_decode($input, true);
+ $input = json_decode((string)$input, true);
$_REQUEST = $input;
}
- if ($_REQUEST["sid"]) {
+ if (!empty($_REQUEST["sid"])) {
session_id($_REQUEST["sid"]);
@session_start();
} else if (defined('_API_DEBUG_HTTP_ENABLED')) {
@@ -56,7 +56,7 @@
if (!init_plugins()) return;
- if ($_SESSION["uid"]) {
+ if (!empty($_SESSION["uid"])) {
if (!validate_session()) {
header("Content-Type: text/json");
@@ -67,7 +67,7 @@
return;
}
- UserHelper::load_user_plugins( $_SESSION["uid"]);
+ UserHelper::load_user_plugins($_SESSION["uid"]);
}
$method = strtolower($_REQUEST["op"]);
@@ -77,7 +77,7 @@
if ($handler->before($method)) {
if ($method && method_exists($handler, $method)) {
$handler->$method();
- } else if (method_exists($handler, 'index')) {
+ } else /* if (method_exists($handler, 'index')) */ {
$handler->index($method);
}
$handler->after();
diff --git a/classes/api.php b/classes/api.php
index 4dd92be88..2f07e9ead 100755
--- a/classes/api.php
+++ b/classes/api.php
@@ -16,12 +16,12 @@ class API extends Handler {
if (parent::before($method)) {
header("Content-Type: text/json");
- if (!$_SESSION["uid"] && $method != "login" && $method != "isloggedin") {
+ if (empty($_SESSION["uid"]) && $method != "login" && $method != "isloggedin") {
$this->wrap(self::STATUS_ERR, array("error" => 'NOT_LOGGED_IN'));
return false;
}
- if ($_SESSION["uid"] && $method != "logout" && !get_pref('ENABLE_API_ACCESS')) {
+ if (!empty($_SESSION["uid"]) && $method != "logout" && !get_pref('ENABLE_API_ACCESS')) {
$this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED'));
return false;
}
@@ -120,7 +120,7 @@ class API extends Handler {
$unread_only = self::param_to_bool(clean($_REQUEST["unread_only"] ?? 0));
$limit = (int) clean($_REQUEST["limit"] ?? 0);
$offset = (int) clean($_REQUEST["offset"] ?? 0);
- $include_nested = self::param_to_bool(clean($_REQUEST["include_nested"]));
+ $include_nested = self::param_to_bool(clean($_REQUEST["include_nested"] ?? false));
$feeds = $this->api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested);
@@ -128,9 +128,9 @@ class API extends Handler {
}
function getCategories() {
- $unread_only = self::param_to_bool(clean($_REQUEST["unread_only"]));
- $enable_nested = self::param_to_bool(clean($_REQUEST["enable_nested"]));
- $include_empty = self::param_to_bool(clean($_REQUEST['include_empty']));
+ $unread_only = self::param_to_bool(clean($_REQUEST["unread_only"] ?? false));
+ $enable_nested = self::param_to_bool(clean($_REQUEST["enable_nested"] ?? false));
+ $include_empty = self::param_to_bool(clean($_REQUEST['include_empty'] ?? false));
// TODO do not return empty categories, return Uncategorized and standard virtual cats
@@ -195,7 +195,7 @@ class API extends Handler {
if (!$limit || $limit >= 200) $limit = 200;
$offset = (int)clean($_REQUEST["skip"]);
- $filter = clean($_REQUEST["filter"]);
+ $filter = clean($_REQUEST["filter"] ?? "");
$is_cat = self::param_to_bool(clean($_REQUEST["is_cat"]));
$show_excerpt = self::param_to_bool(clean($_REQUEST["show_excerpt"]));
$show_content = self::param_to_bool(clean($_REQUEST["show_content"]));
@@ -206,11 +206,11 @@ class API extends Handler {
$include_nested = self::param_to_bool(clean($_REQUEST["include_nested"]));
$sanitize_content = !isset($_REQUEST["sanitize"]) ||
self::param_to_bool($_REQUEST["sanitize"]);
- $force_update = self::param_to_bool(clean($_REQUEST["force_update"]));
- $has_sandbox = self::param_to_bool(clean($_REQUEST["has_sandbox"]));
- $excerpt_length = (int)clean($_REQUEST["excerpt_length"]);
- $check_first_id = (int)clean($_REQUEST["check_first_id"]);
- $include_header = self::param_to_bool(clean($_REQUEST["include_header"]));
+ $force_update = self::param_to_bool(clean($_REQUEST["force_update"] ?? false));
+ $has_sandbox = self::param_to_bool(clean($_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(clean($_REQUEST["include_header"] ?? false));
$_SESSION['hasSandbox'] = $has_sandbox;
@@ -218,7 +218,7 @@ class API extends Handler {
/* do not rely on params below */
- $search = clean($_REQUEST["search"]);
+ $search = clean($_REQUEST["search"] ?? "");
list($headlines, $headlines_header) = $this->api_get_headlines($feed_id, $limit, $offset,
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order,