From eb1b2256a00ece6d802e798ee15ad1f8b55c36f9 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 7 Nov 2021 14:00:47 +0000 Subject: [PATCH] Removed and replaced deprecated functionalities --- include/api.php | 21 +++++++++++---- mod/item.php | 3 ++- mod/settings.php | 8 +++++- src/Content/Text/HTML.php | 10 ------- src/Core/Addon.php | 47 --------------------------------- src/Model/Contact.php | 30 --------------------- src/Model/FileTag.php | 17 ------------ src/Model/Group.php | 42 ----------------------------- src/Model/Notification/Type.php | 8 ------ src/Model/User.php | 20 -------------- src/Object/Image.php | 45 ------------------------------- src/Protocol/OStatus.php | 8 +++--- 12 files changed, 29 insertions(+), 230 deletions(-) diff --git a/include/api.php b/include/api.php index 2495f5d192..062865d439 100644 --- a/include/api.php +++ b/include/api.php @@ -237,9 +237,13 @@ function api_login(App $a) if ($addon_auth['authenticated'] && !empty($addon_auth['user_record'])) { $record = $addon_auth['user_record']; } else { - $user_id = User::authenticate(trim($user), trim($password), true); - if ($user_id !== false) { - $record = DBA::selectFirst('user', [], ['uid' => $user_id]); + try { + $user_id = User::getIdFromPasswordAuthentication(trim($user), trim($password), true); + if ($user_id !== false) { + $record = DBA::selectFirst('user', [], ['uid' => $user_id]); + } + } catch (Exception $ex) { + $record = []; } } @@ -5137,7 +5141,13 @@ function api_friendica_group_delete($type) } // delete group - $ret = Group::removeByName($uid, $name); + $gid = Group::getIdByName($uid, $name); + if (empty($gid)) { + throw new BadRequestException('other API error'); + } + + $ret = Group::remove($gid); + if ($ret) { // return success $success = ['success' => $ret, 'gid' => $gid, 'name' => $name, 'status' => 'deleted', 'wrong users' => []]; @@ -5372,7 +5382,8 @@ function api_friendica_group_update($type) $found = ($user['cid'] == $cid ? true : false); } if (!isset($found) || !$found) { - Group::removeMemberByName($uid, $name, $cid); + $gid = Group::getIdByName($uid, $name); + Group::removeMember($gid, $cid); } } diff --git a/mod/item.php b/mod/item.php index 1309dce47e..da3eb16c30 100644 --- a/mod/item.php +++ b/mod/item.php @@ -352,7 +352,8 @@ function item_post(App $a) { $filedas = FileTag::fileToArray($categories); } - $categories = FileTag::listToFile(trim($_REQUEST['category'] ?? ''), 'category'); + $list_array = explode(',', trim($_REQUEST['category'] ?? '')); + $categories = FileTag::arrayToFile($list_array, 'category'); if (!empty($filedas) && is_array($filedas)) { // append the fileas stuff to the new categories list diff --git a/mod/settings.php b/mod/settings.php index b1b8abd94e..e42760358c 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -308,7 +308,13 @@ function settings_post(App $a) if ($email != $user['email']) { // check for the correct password - if (!User::authenticate(intval(local_user()), $_POST['mpassword'])) { + try { + $authenticated = User::getIdFromPasswordAuthentication(intval(local_user()), $_POST['mpassword']); + } catch (Exception $ex) { + $authenticated = false; + } + + if (!$authenticated) { $err .= DI::l10n()->t('Wrong Password.'); $email = $user['email']; } diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index e1caca48ae..f4462199ea 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -784,16 +784,6 @@ class HTML return $text; } - /** - * return div element with class 'clear' - * @return string - * @deprecated - */ - public static function clearDiv() - { - return '
'; - } - /** * Loader for infinite scrolling * diff --git a/src/Core/Addon.php b/src/Core/Addon.php index 7b3c86a656..357c02bcb6 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -320,51 +320,4 @@ class Addon return $visible_addons; } - - /** - * Shim of Hook::register left for backward compatibility purpose. - * - * @see Hook::register - * @deprecated since version 2018.12 - * @param string $hook the name of the hook - * @param string $file the name of the file that hooks into - * @param string $function the name of the function that the hook will call - * @param int $priority A priority (defaults to 0) - * @return mixed|bool - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - */ - public static function registerHook($hook, $file, $function, $priority = 0) - { - return Hook::register($hook, $file, $function, $priority); - } - - /** - * Shim of Hook::unregister left for backward compatibility purpose. - * - * @see Hook::unregister - * @deprecated since version 2018.12 - * @param string $hook the name of the hook - * @param string $file the name of the file that hooks into - * @param string $function the name of the function that the hook called - * @return boolean - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - */ - public static function unregisterHook($hook, $file, $function) - { - return Hook::unregister($hook, $file, $function); - } - - /** - * Shim of Hook::callAll left for backward-compatibility purpose. - * - * @see Hook::callAll - * @deprecated since version 2018.12 - * @param string $name of the hook to call - * @param string|array &$data to transmit to the callback handler - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - */ - public static function callHooks($name, &$data = null) - { - Hook::callAll($name, $data); - } } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 03cd09fc5a..8d7799f636 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -57,36 +57,6 @@ class Contact const DEFAULT_AVATAR_THUMB = '/images/person-80.jpg'; const DEFAULT_AVATAR_MICRO = '/images/person-48.jpg'; - /** - * @deprecated since version 2019.03 - * @see User::PAGE_FLAGS_NORMAL - */ - const PAGE_NORMAL = User::PAGE_FLAGS_NORMAL; - /** - * @deprecated since version 2019.03 - * @see User::PAGE_FLAGS_SOAPBOX - */ - const PAGE_SOAPBOX = User::PAGE_FLAGS_SOAPBOX; - /** - * @deprecated since version 2019.03 - * @see User::PAGE_FLAGS_COMMUNITY - */ - const PAGE_COMMUNITY = User::PAGE_FLAGS_COMMUNITY; - /** - * @deprecated since version 2019.03 - * @see User::PAGE_FLAGS_FREELOVE - */ - const PAGE_FREELOVE = User::PAGE_FLAGS_FREELOVE; - /** - * @deprecated since version 2019.03 - * @see User::PAGE_FLAGS_BLOG - */ - const PAGE_BLOG = User::PAGE_FLAGS_BLOG; - /** - * @deprecated since version 2019.03 - * @see User::PAGE_FLAGS_PRVGROUP - */ - const PAGE_PRVGROUP = User::PAGE_FLAGS_PRVGROUP; /** * @} */ diff --git a/src/Model/FileTag.php b/src/Model/FileTag.php index 324a78fa6f..d459237e75 100644 --- a/src/Model/FileTag.php +++ b/src/Model/FileTag.php @@ -114,21 +114,4 @@ class FileTag return $return; } - - /** - * Get file tags from list - * - * ex. given music,video return