1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 08:25:55 +00:00

initial WIP for php8; bump php version requirement to 7.0

This commit is contained in:
Andrew Dolgov
2021-02-05 23:41:32 +03:00
parent b4cbc792cc
commit 403dca154c
28 changed files with 145 additions and 144 deletions

View File

@@ -42,14 +42,14 @@ class Pref_Feeds extends Handler_Protected {
private function get_category_items($cat_id) {
if (clean($_REQUEST['mode']) != 2)
$search = $_SESSION["prefs_feed_search"];
if (clean($_REQUEST['mode'] ?? 0) != 2)
$search = $_SESSION["prefs_feed_search"] ?? "";
else
$search = "";
// first one is set by API
$show_empty_cats = clean($_REQUEST['force_show_empty']) ||
(clean($_REQUEST['mode']) != 2 && !$search);
$show_empty_cats = clean($_REQUEST['force_show_empty'] ?? false) ||
(clean($_REQUEST['mode'] ?? 0) != 2 && !$search);
$items = array();
@@ -117,8 +117,8 @@ class Pref_Feeds extends Handler_Protected {
function makefeedtree() {
if (clean($_REQUEST['mode']) != 2)
$search = $_SESSION["prefs_feed_search"];
if (clean($_REQUEST['mode'] ?? 0) != 2)
$search = $_SESSION["prefs_feed_search"] ?? "";
else
$search = "";
@@ -131,7 +131,7 @@ class Pref_Feeds extends Handler_Protected {
$enable_cats = get_pref('ENABLE_FEED_CATS');
if (clean($_REQUEST['mode']) == 2) {
if (clean($_REQUEST['mode'] ?? 0) == 2) {
if ($enable_cats) {
$cat = $this->feedlist_init_cat(-1);
@@ -208,8 +208,8 @@ class Pref_Feeds extends Handler_Protected {
}
if ($enable_cats) {
$show_empty_cats = clean($_REQUEST['force_show_empty']) ||
(clean($_REQUEST['mode']) != 2 && !$search);
$show_empty_cats = clean($_REQUEST['force_show_empty'] ?? false) ||
(clean($_REQUEST['mode'] ?? 0) != 2 && !$search);
$sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories
WHERE owner_uid = ? AND parent_cat IS NULL ORDER BY order_id, title");
@@ -320,7 +320,7 @@ class Pref_Feeds extends Handler_Protected {
$fl['identifier'] = 'id';
$fl['label'] = 'name';
if (clean($_REQUEST['mode']) != 2) {
if (clean($_REQUEST['mode'] ?? 0) != 2) {
$fl['items'] = array($root);
} else {
$fl['items'] = $root['items'];
@@ -551,11 +551,9 @@ class Pref_Feeds extends Handler_Protected {
regExp='^(http|https)://.*' style='width : 300px'
name='feed_url' value=\"$feed_url\">";
$last_error = $row["last_error"];
if ($last_error) {
if (!empty($row["last_error"])) {
print "&nbsp;<i class=\"material-icons\"
title=\"".htmlspecialchars($last_error)."\">error</i>";
title=\"".htmlspecialchars($row["last_error"])."\">error</i>";
}
print "</fieldset>";
@@ -996,16 +994,16 @@ class Pref_Feeds extends Handler_Protected {
function editsaveops($batch) {
$feed_title = trim(clean($_POST["title"]));
$feed_url = trim(clean($_POST["feed_url"]));
$site_url = trim(clean($_POST["site_url"]));
$feed_title = clean($_POST["title"]);
$feed_url = clean($_POST["feed_url"]);
$site_url = clean($_POST["site_url"]);
$upd_intl = (int) clean($_POST["update_interval"]);
$purge_intl = (int) clean($_POST["purge_interval"]);
$feed_id = (int) clean($_POST["id"]); /* editSave */
$feed_ids = explode(",", clean($_POST["ids"])); /* batchEditSave */
$cat_id = (int) clean($_POST["cat_id"]);
$auth_login = trim(clean($_POST["auth_login"]));
$auth_pass = trim(clean($_POST["auth_pass"]));
$auth_login = clean($_POST["auth_login"]);
$auth_pass = clean($_POST["auth_pass"]);
$private = checkbox_to_sql_bool(clean($_POST["private"]));
$include_in_digest = checkbox_to_sql_bool(
clean($_POST["include_in_digest"]));
@@ -1019,7 +1017,7 @@ class Pref_Feeds extends Handler_Protected {
$mark_unread_on_update = checkbox_to_sql_bool(
clean($_POST["mark_unread_on_update"]));
$feed_language = trim(clean($_POST["feed_language"]));
$feed_language = clean($_POST["feed_language"]);
if (!$batch) {
if (clean($_POST["need_auth"]) !== 'on') {
@@ -1193,7 +1191,7 @@ class Pref_Feeds extends Handler_Protected {
}
function addCat() {
$feed_cat = trim(clean($_REQUEST["cat"]));
$feed_cat = clean($_REQUEST["cat"]);
Feeds::add_feed_category($feed_cat);
}
@@ -1228,12 +1226,12 @@ class Pref_Feeds extends Handler_Protected {
onclick=\"dijit.byId('feedTree').showInactiveFeeds()\">" .
__("Inactive feeds") . "</button>";
$feed_search = clean($_REQUEST["search"]);
$feed_search = clean($_REQUEST["search"] ?? "");
if (array_key_exists("search", $_REQUEST)) {
$_SESSION["prefs_feed_search"] = $feed_search;
} else {
$feed_search = $_SESSION["prefs_feed_search"];
$feed_search = $_SESSION["prefs_feed_search"] ?? "";
}
print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
@@ -1689,7 +1687,7 @@ class Pref_Feeds extends Handler_Protected {
$cat_id = clean($_REQUEST['cat']);
$feeds = explode("\n", clean($_REQUEST['feeds']));
$login = clean($_REQUEST['login']);
$pass = trim(clean($_REQUEST['pass']));
$pass = clean($_REQUEST['pass']);
$csth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
WHERE feed_url = ? AND owner_uid = ?");
@@ -1756,8 +1754,8 @@ class Pref_Feeds extends Handler_Protected {
private function calculate_children_count($cat) {
$c = 0;
foreach ($cat['items'] as $child) {
if ($child['type'] == 'category') {
foreach ($cat['items'] ?? [] as $child) {
if ($child['type'] ?? '' == 'category') {
$c += $this->calculate_children_count($child);
} else {
$c += 1;

View File

@@ -599,9 +599,9 @@ class Pref_Filters extends Handler_Protected {
function editSave() {
$filter_id = clean($_REQUEST["id"]);
$enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"]));
$enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"] ?? false));
$match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"]));
$inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"]));
$inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"] ?? false));
$title = clean($_REQUEST["title"]);
$this->pdo->beginTransaction();
@@ -638,8 +638,8 @@ class Pref_Filters extends Handler_Protected {
$sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_actions WHERE filter_id = ?");
$sth->execute([$filter_id]);
if (!is_array(clean($_REQUEST["rule"]))) $_REQUEST["rule"] = [];
if (!is_array(clean($_REQUEST["action"]))) $_REQUEST["action"] = [];
if (!is_array(clean($_REQUEST["rule"] ?? ""))) $_REQUEST["rule"] = [];
if (!is_array(clean($_REQUEST["action"] ?? ""))) $_REQUEST["action"] = [];
if ($filter_id) {
/* create rules */

View File

@@ -166,7 +166,7 @@ class Pref_Labels extends Handler_Protected {
function save() {
$id = clean($_REQUEST["id"]);
$caption = trim(clean($_REQUEST["caption"]));
$caption = clean($_REQUEST["caption"]);
$this->pdo->beginTransaction();

View File

@@ -321,7 +321,7 @@ class Pref_Prefs extends Handler_Protected {
print "<input dojoType='dijit.form.ValidationTextBox' name='email' required='1' value='$email'>";
print "</fieldset>";
if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) {
if (!SINGLE_USER_MODE && !empty($_SESSION["hide_hello"])) {
$access_level = $row["access_level"];
print "<fieldset>";
@@ -595,7 +595,7 @@ class Pref_Prefs extends Handler_Protected {
print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
$profile = $_SESSION["profile"];
$profile = $_SESSION["profile"] ?? null;
if ($profile) {
print_notice(__("Some preferences are only available in default profile."));
@@ -916,7 +916,7 @@ class Pref_Prefs extends Handler_Protected {
foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
$about = $plugin->about();
if ($about[3]) {
if ($about[3] ?? false) {
if (in_array($name, $system_enabled)) {
$checked = "checked='1'";
} else {
@@ -930,7 +930,7 @@ class Pref_Prefs extends Handler_Protected {
dojoType='dijit.form.CheckBox' $checked type='checkbox'>
".htmlspecialchars($about[1]). "</label>";
if (@$about[4]) {
if ($about[4] ?? false) {
print "<button dojoType='dijit.form.Button' class='alt-info'
onclick='window.open(\"".htmlspecialchars($about[4])."\")'>
<i class='material-icons'>open_in_new</i> ".__("More info...")."</button>";
@@ -950,7 +950,7 @@ class Pref_Prefs extends Handler_Protected {
foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
$about = $plugin->about();
if (!$about[3]) {
if ($about[3] ?? false) {
$checked = "";
$disabled = "";
@@ -976,7 +976,7 @@ class Pref_Prefs extends Handler_Protected {
}
}
if (@$about[4]) {
if ($about[4] ?? false) {
print " <button dojoType='dijit.form.Button' class='alt-info'
onclick='window.open(\"".htmlspecialchars($about[4])."\")'>
<i class='material-icons'>open_in_new</i> ".__("More info...")."</button>";

View File

@@ -191,10 +191,10 @@ class Pref_Users extends Handler_Protected {
}
function editSave() {
$login = trim(clean($_REQUEST["login"]));
$login = clean($_REQUEST["login"]);
$uid = clean($_REQUEST["id"]);
$access_level = (int) clean($_REQUEST["access_level"]);
$email = trim(clean($_REQUEST["email"]));
$email = clean($_REQUEST["email"]);
$password = clean($_REQUEST["password"]);
if ($password) {
@@ -230,7 +230,7 @@ class Pref_Users extends Handler_Protected {
}
function add() {
$login = trim(clean($_REQUEST["login"]));
$login = clean($_REQUEST["login"]);
$tmp_user_pwd = make_password();
$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
$pwd_hash = encrypt_password($tmp_user_pwd, $salt, true);
@@ -315,7 +315,7 @@ class Pref_Users extends Handler_Protected {
print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
print "<div dojoType='fox.Toolbar'>";
$user_search = trim(clean($_REQUEST["search"]));
$user_search = clean($_REQUEST["search"] ?? "");
if (array_key_exists("search", $_REQUEST)) {
$_SESSION["prefs_user_search"] = $user_search;
@@ -330,7 +330,7 @@ class Pref_Users extends Handler_Protected {
__('Search')."</button>
</div>";
$sort = clean($_REQUEST["sort"]);
$sort = clean($_REQUEST["sort"] ?? "");
if (!$sort || $sort == "undefined") {
$sort = "login";