diff --git a/CHANGELOG.md b/CHANGELOG.md index facd5b78c..ca9bd0bd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Fixed HTTP 500 while cron running in server-side [\#1321](https://github.com/torrentpier/torrentpier/pull/1321) ([belomaxorka](https://github.com/belomaxorka)) - Sending debug errors to us 🌚 via Telegram bot [\#1323](https://github.com/torrentpier/torrentpier/pull/1323) ([belomaxorka](https://github.com/belomaxorka)) - Minor improvements [\#1306](https://github.com/torrentpier/torrentpier/pull/1306), [\#1307](https://github.com/torrentpier/torrentpier/pull/1307), [\#1308](https://github.com/torrentpier/torrentpier/pull/1308), [\#1315](https://github.com/torrentpier/torrentpier/pull/1315) ([belomaxorka](https://github.com/belomaxorka)) +- Some bugfixes [\#1326](https://github.com/torrentpier/torrentpier/pull/1326) ([belomaxorka](https://github.com/belomaxorka)) - Updated deps [\#1304](https://github.com/torrentpier/torrentpier/pull/1304), [\#1305](https://github.com/torrentpier/torrentpier/pull/1305) ([belomaxorka](https://github.com/belomaxorka)) ## [v2.4.0](https://github.com/torrentpier/torrentpier/tree/v2.4.0) (2024-01-01) diff --git a/library/attach_mod/includes/functions_admin.php b/library/attach_mod/includes/functions_admin.php index 340efb6fb..5f5f0a05b 100644 --- a/library/attach_mod/includes/functions_admin.php +++ b/library/attach_mod/includes/functions_admin.php @@ -245,25 +245,3 @@ function search_attachments($order_by, &$total_rows) return $attachments; } - -/** - * Perform limit statement on arrays - * - * @param $array - * @param $start - * @param $pagelimit - * @return array - */ -function limit_array($array, $start, $pagelimit) -{ - // array from start - start+pagelimit - $limit = (count($array) < ($start + $pagelimit)) ? count($array) : $start + $pagelimit; - - $limit_array = []; - - for ($i = $start; $i < $limit; $i++) { - $limit_array[] = $array[$i]; - } - - return $limit_array; -} diff --git a/library/includes/functions.php b/library/includes/functions.php index f1bd17224..19ce6f4ef 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -269,6 +269,11 @@ function auth($type, $forum_id, $ug_data, array $f_access = [], $group_perm = UG $auth = $auth_fields = $u_access = []; $add_auth_type_desc = ($forum_id != AUTH_LIST_ALL); + // Check forum existence + if ($add_auth_type_desc && !forum_exists($forum_id)) { + return []; + } + // // Get $auth_fields // @@ -304,7 +309,7 @@ function auth($type, $forum_id, $ug_data, array $f_access = [], $group_perm = UG } if (empty($f_access)) { - return []; + trigger_error(__FUNCTION__ . '(): empty $f_access', E_USER_ERROR); } // diff --git a/src/Legacy/Common/User.php b/src/Legacy/Common/User.php index 2c3821c92..de4b818d9 100644 --- a/src/Legacy/Common/User.php +++ b/src/Legacy/Common/User.php @@ -727,9 +727,9 @@ class User * @param $auth_type * @param string $return_as * - * @return array|bool|string + * @return array|string */ - public function get_excluded_forums($auth_type, $return_as = 'csv') + public function get_excluded_forums($auth_type, string $return_as = 'csv') { $excluded = []; @@ -754,14 +754,13 @@ class User } } - switch ($return_as) { - case 'csv': - return implode(',', $excluded); - case 'array': - return $excluded; - case 'flip': - return array_flip(explode(',', $excluded)); - } + return match ($return_as) { + 'csv' => implode(',', $excluded), + 'flip_csv' => implode(',', array_flip($excluded)), + 'array' => $excluded, + 'flip' => array_flip($excluded), + default => [], + }; } /**