Merge pull request #10961 from annando/deprecated

Removed and replaced deprecated functionalities
This commit is contained in:
Hypolite Petovan 2021-11-07 10:53:17 -05:00 committed by GitHub
commit 8d550ad4e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 22 additions and 229 deletions

View file

@ -237,9 +237,11 @@ 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) {
try {
$user_id = User::getIdFromPasswordAuthentication(trim($user), trim($password), true);
$record = DBA::selectFirst('user', [], ['uid' => $user_id]);
} catch (Exception $ex) {
$record = [];
}
}
@ -5137,7 +5139,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 +5380,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);
}
}

View file

@ -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

View file

@ -308,7 +308,9 @@ function settings_post(App $a)
if ($email != $user['email']) {
// check for the correct password
if (!User::authenticate(intval(local_user()), $_POST['mpassword'])) {
try {
User::getIdFromPasswordAuthentication(local_user(), $_POST['mpassword']);
} catch (Exception $ex) {
$err .= DI::l10n()->t('Wrong Password.');
$email = $user['email'];
}

View file

@ -784,16 +784,6 @@ class HTML
return $text;
}
/**
* return div element with class 'clear'
* @return string
* @deprecated
*/
public static function clearDiv()
{
return '<div class="clear"></div>';
}
/**
* Loader for infinite scrolling
*

View file

@ -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);
}
}

View file

@ -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;
/**
* @}
*/

View file

@ -114,21 +114,4 @@ class FileTag
return $return;
}
/**
* Get file tags from list
*
* ex. given music,video return <music><video> or [music][video]
* @param string $list A comma delimited list of tags.
* @param string $type Optional file type.
*
* @return string A list of file tags.
* @deprecated since 2019.06 use arrayToFile() instead
*/
public static function listToFile(string $list, string $type = 'file')
{
$list_array = explode(',', $list);
return self::arrayToFile($list_array, $type);
}
}

View file

@ -251,28 +251,6 @@ class Group
return $return;
}
/**
* Mark a group as deleted based on its name
*
* @param int $uid
* @param string $name
* @return bool
* @throws \Exception
* @deprecated Use Group::remove instead
*
*/
public static function removeByName($uid, $name)
{
$return = false;
if (!empty($uid) && !empty($name)) {
$gid = self::getIdByName($uid, $name);
$return = self::remove($gid);
}
return $return;
}
/**
* Adds a contact to a group
*
@ -317,26 +295,6 @@ class Group
return $return;
}
/**
* Removes a contact from a group based on its name
*
* @param int $uid
* @param string $name
* @param int $cid
* @return boolean
* @throws \Exception
* @deprecated Use Group::removeMember instead
*
*/
public static function removeMemberByName($uid, $name, $cid)
{
$gid = self::getIdByName($uid, $name);
$return = self::removeMember($gid, $cid);
return $return;
}
/**
* Returns the combined list of contact ids from a group id list
*

View file

@ -38,16 +38,8 @@ class Type
const MAIL = 16;
/** @var int Notification about a friend suggestion */
const SUGGEST = 32;
/** @var int Unknown Notification
* @deprecated
*/
const PROFILE = 64;
/** @var int Notification about being tagged in a post */
const TAG_SELF = 128;
/** @var int Notification about being tagged
* @deprecated
*/
const TAG_SHARE = 256;
/** @var int Notification about getting poked/prodded/etc. */
const POKE = 512;
/** @var int Notification about either a contact had posted something directly or the contact is a mentioned forum */

View file

@ -499,26 +499,6 @@ class User
return $default_group;
}
/**
* Authenticate a user with a clear text password
*
* @param mixed $user_info
* @param string $password
* @param bool $third_party
* @return int|boolean
* @deprecated since version 3.6
* @see User::getIdFromPasswordAuthentication()
*/
public static function authenticate($user_info, $password, $third_party = false)
{
try {
return self::getIdFromPasswordAuthentication($user_info, $password, $third_party);
} catch (Exception $ex) {
return false;
}
}
/**
* Authenticate a user with a clear text password
*

View file

@ -685,49 +685,4 @@ class Image
return $string;
}
/**
* supported mimetypes and corresponding file extensions
*
* @return array
* @deprecated in version 2019.12 please use Util\Images::supportedTypes() instead.
*/
public static function supportedTypes()
{
return Images::supportedTypes();
}
/**
* Maps Mime types to Imagick formats
*
* @return array With with image formats (mime type as key)
* @deprecated in version 2019.12 please use Util\Images::getFormatsMap() instead.
*/
public static function getFormatsMap()
{
return Images::getFormatsMap();
}
/**
* @param string $url url
* @return array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @deprecated in version 2019.12 please use Util\Images::getInfoFromURLCached() instead.
*/
public static function getInfoFromURL($url)
{
return Images::getInfoFromURLCached($url);
}
/**
* @param integer $width width
* @param integer $height height
* @param integer $max max
* @return array
* @deprecated in version 2019.12 please use Util\Images::getScalingDimensions() instead.
*/
public static function getScalingDimensions($width, $height, $max)
{
return Images::getScalingDimensions($width, $height, $max);
}
}

View file

@ -865,8 +865,8 @@ class OStatus
private static function fetchSelf($self, array &$item)
{
$condition = ['item-uri' => $self, 'protocol' => [Conversation::PARCEL_DFRN,
Conversation::PARCEL_DIASPORA_DFRN, Conversation::PARCEL_LEGACY_DFRN,
Conversation::PARCEL_LOCAL_DFRN, Conversation::PARCEL_DIRECT, Conversation::PARCEL_SALMON]];
Conversation::PARCEL_DIASPORA_DFRN, Conversation::PARCEL_LOCAL_DFRN,
Conversation::PARCEL_DIRECT, Conversation::PARCEL_SALMON]];
if (DBA::exists('conversation', $condition)) {
Logger::info('Conversation '.$item['uri'].' is already stored.');
return;
@ -905,8 +905,8 @@ class OStatus
private static function fetchRelated($related, $related_uri, $importer)
{
$condition = ['item-uri' => $related_uri, 'protocol' => [Conversation::PARCEL_DFRN,
Conversation::PARCEL_DIASPORA_DFRN, Conversation::PARCEL_LEGACY_DFRN,
Conversation::PARCEL_LOCAL_DFRN, Conversation::PARCEL_DIRECT, Conversation::PARCEL_SALMON]];
Conversation::PARCEL_DIASPORA_DFRN, Conversation::PARCEL_LOCAL_DFRN,
Conversation::PARCEL_DIRECT, Conversation::PARCEL_SALMON]];
$conversation = DBA::selectFirst('conversation', ['source', 'protocol'], $condition);
if (DBA::isResult($conversation)) {
$stored = true;