From 344d514857f0e18976ee6d88a891188b472c6273 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 16 Jan 2022 16:40:13 +0000 Subject: [PATCH] Replaced "filter_input" with the new request value function --- .../Api/Twitter/Account/UpdateProfile.php | 2 +- .../Twitter/Account/UpdateProfileImage.php | 2 +- .../Api/Twitter/Account/VerifyCredentials.php | 2 +- src/Module/Api/Twitter/Blocks/Ids.php | 17 ++++++------- src/Module/Api/Twitter/Blocks/Lists.php | 19 ++++++-------- .../Api/Twitter/DirectMessages/Destroy.php | 4 +-- src/Module/Api/Twitter/Followers/Ids.php | 23 ++++++++--------- src/Module/Api/Twitter/Followers/Lists.php | 25 ++++++++----------- src/Module/Api/Twitter/Friends/Ids.php | 23 ++++++++--------- src/Module/Api/Twitter/Friends/Lists.php | 25 ++++++++----------- .../Api/Twitter/Friendships/Incoming.php | 17 ++++++------- 11 files changed, 69 insertions(+), 90 deletions(-) diff --git a/src/Module/Api/Twitter/Account/UpdateProfile.php b/src/Module/Api/Twitter/Account/UpdateProfile.php index 70cac42a2..06ebf3db1 100644 --- a/src/Module/Api/Twitter/Account/UpdateProfile.php +++ b/src/Module/Api/Twitter/Account/UpdateProfile.php @@ -56,7 +56,7 @@ class UpdateProfile extends BaseApi Profile::publishUpdate($uid); - $skip_status = filter_var($request['skip_status'] ?? false, FILTER_VALIDATE_BOOLEAN); + $skip_status = $this->getRequestValue($request, 'skip_status', false); $user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray(); diff --git a/src/Module/Api/Twitter/Account/UpdateProfileImage.php b/src/Module/Api/Twitter/Account/UpdateProfileImage.php index 909c4c29e..02194316b 100644 --- a/src/Module/Api/Twitter/Account/UpdateProfileImage.php +++ b/src/Module/Api/Twitter/Account/UpdateProfileImage.php @@ -57,7 +57,7 @@ class UpdateProfileImage extends BaseApi } // output for client - $skip_status = filter_var($request['skip_status'] ?? false, FILTER_VALIDATE_BOOLEAN); + $skip_status = $this->getRequestValue($request, 'skip_status', false); $user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray(); diff --git a/src/Module/Api/Twitter/Account/VerifyCredentials.php b/src/Module/Api/Twitter/Account/VerifyCredentials.php index 181c20dfb..af9c2a6f7 100644 --- a/src/Module/Api/Twitter/Account/VerifyCredentials.php +++ b/src/Module/Api/Twitter/Account/VerifyCredentials.php @@ -37,7 +37,7 @@ class VerifyCredentials extends BaseApi BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); - $skip_status = filter_var($request['skip_status'] ?? false, FILTER_VALIDATE_BOOLEAN); + $skip_status = $this->getRequestValue($request, 'skip_status', false); $user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray(); diff --git a/src/Module/Api/Twitter/Blocks/Ids.php b/src/Module/Api/Twitter/Blocks/Ids.php index e411fc507..d687b85a5 100644 --- a/src/Module/Api/Twitter/Blocks/Ids.php +++ b/src/Module/Api/Twitter/Blocks/Ids.php @@ -37,17 +37,14 @@ class Ids extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]); - $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [ - 'default' => self::DEFAULT_COUNT, - 'min_range' => 1, - 'max_range' => self::MAX_COUNT, - ]]); + $cursor = $this->getRequestValue($request, 'cursor', -1); + $stringify_ids = $this->getRequestValue($request, 'stringify_ids', false); + $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); + // Friendica-specific - $since_id = filter_input(INPUT_GET, 'since_id', FILTER_VALIDATE_INT); - $max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT); - $min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT); + $since_id = $this->getRequestValue($request, 'since_id', 0, 0); + $max_id = $this->getRequestValue($request, 'max_id', 0, 0); + $min_id = $this->getRequestValue($request, 'min_id', 0, 0); $params = ['order' => ['cid' => true], 'limit' => $count]; diff --git a/src/Module/Api/Twitter/Blocks/Lists.php b/src/Module/Api/Twitter/Blocks/Lists.php index da7b00f43..823336c08 100644 --- a/src/Module/Api/Twitter/Blocks/Lists.php +++ b/src/Module/Api/Twitter/Blocks/Lists.php @@ -37,18 +37,15 @@ class Lists extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]); - $skip_status = filter_input(INPUT_GET, 'skip_status' , FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $include_user_entities = filter_input(INPUT_GET, 'include_user_entities', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [ - 'default' => self::DEFAULT_COUNT, - 'min_range' => 1, - 'max_range' => self::MAX_COUNT, - ]]); + $cursor = $this->getRequestValue($request, 'cursor', -1); + $skip_status = $this->getRequestValue($request, 'skip_status', false); + $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false); + $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); + // Friendica-specific - $since_id = filter_input(INPUT_GET, 'since_id', FILTER_VALIDATE_INT); - $max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT); - $min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT); + $since_id = $this->getRequestValue($request, 'since_id', 0, 0); + $max_id = $this->getRequestValue($request, 'max_id', 0, 0); + $min_id = $this->getRequestValue($request, 'min_id', 0, 0); $params = ['order' => ['cid' => true], 'limit' => $count]; diff --git a/src/Module/Api/Twitter/DirectMessages/Destroy.php b/src/Module/Api/Twitter/DirectMessages/Destroy.php index 9f9c4de30..3100ff345 100644 --- a/src/Module/Api/Twitter/DirectMessages/Destroy.php +++ b/src/Module/Api/Twitter/DirectMessages/Destroy.php @@ -52,8 +52,8 @@ class Destroy extends BaseApi BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE); $uid = BaseApi::getCurrentUserID(); - $id = filter_var($request['id'] ?? 0, FILTER_VALIDATE_INT); - $verbose = filter_var($request['friendica_verbose'] ?? false, FILTER_VALIDATE_BOOLEAN); + $id = $this->getRequestValue($request, 'id', 0); + $verbose = $this->getRequestValue($request, 'friendica_verbose', false); $parenturi = $request['friendica_parenturi'] ?? ''; diff --git a/src/Module/Api/Twitter/Followers/Ids.php b/src/Module/Api/Twitter/Followers/Ids.php index a618304b2..d03b547ac 100644 --- a/src/Module/Api/Twitter/Followers/Ids.php +++ b/src/Module/Api/Twitter/Followers/Ids.php @@ -37,20 +37,17 @@ class Ids extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT); - $screen_name = filter_input(INPUT_GET, 'screen_name'); - $profile_url = filter_input(INPUT_GET, 'profile_url'); - $cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]); - $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [ - 'default' => self::DEFAULT_COUNT, - 'min_range' => 1, - 'max_range' => self::MAX_COUNT, - ]]); + $contact_id = $this->getRequestValue($request, 'user_id', 0); + $screen_name = $this->getRequestValue($request, 'screen_name', ''); + $profile_url = $this->getRequestValue($request, 'profile_url', ''); + $cursor = $this->getRequestValue($request, 'cursor', -1); + $stringify_ids = $this->getRequestValue($request, 'stringify_ids', false); + $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); + // Friendica-specific - $since_id = filter_input(INPUT_GET, 'since_id' , FILTER_VALIDATE_INT); - $max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT); - $min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT); + $since_id = $this->getRequestValue($request, 'since_id', 0, 0); + $max_id = $this->getRequestValue($request, 'max_id', 0, 0); + $min_id = $this->getRequestValue($request, 'min_id', 0, 0); $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); diff --git a/src/Module/Api/Twitter/Followers/Lists.php b/src/Module/Api/Twitter/Followers/Lists.php index a60226d05..0aca285a1 100644 --- a/src/Module/Api/Twitter/Followers/Lists.php +++ b/src/Module/Api/Twitter/Followers/Lists.php @@ -37,21 +37,18 @@ class Lists extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT); - $screen_name = filter_input(INPUT_GET, 'screen_name'); - $profile_url = filter_input(INPUT_GET, 'profile_url'); - $cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]); - $skip_status = filter_input(INPUT_GET, 'skip_status' , FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $include_user_entities = filter_input(INPUT_GET, 'include_user_entities', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [ - 'default' => self::DEFAULT_COUNT, - 'min_range' => 1, - 'max_range' => self::MAX_COUNT, - ]]); + $contact_id = $this->getRequestValue($request, 'user_id', 0); + $screen_name = $this->getRequestValue($request, 'screen_name', ''); + $profile_url = $this->getRequestValue($request, 'profile_url', ''); + $cursor = $this->getRequestValue($request, 'cursor', -1); + $skip_status = $this->getRequestValue($request, 'skip_status', false); + $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false); + $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); + // Friendica-specific - $since_id = filter_input(INPUT_GET, 'since_id', FILTER_VALIDATE_INT); - $max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT); - $min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT); + $since_id = $this->getRequestValue($request, 'since_id', 0, 0); + $max_id = $this->getRequestValue($request, 'max_id', 0, 0); + $min_id = $this->getRequestValue($request, 'min_id', 0, 0); $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); diff --git a/src/Module/Api/Twitter/Friends/Ids.php b/src/Module/Api/Twitter/Friends/Ids.php index d810ceeb4..c874432e1 100644 --- a/src/Module/Api/Twitter/Friends/Ids.php +++ b/src/Module/Api/Twitter/Friends/Ids.php @@ -37,20 +37,17 @@ class Ids extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT); - $screen_name = filter_input(INPUT_GET, 'screen_name'); - $profile_url = filter_input(INPUT_GET, 'profile_url'); - $cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]); - $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [ - 'default' => self::DEFAULT_COUNT, - 'min_range' => 1, - 'max_range' => self::MAX_COUNT, - ]]); + $contact_id = $this->getRequestValue($request, 'user_id', 0); + $screen_name = $this->getRequestValue($request, 'screen_name', ''); + $profile_url = $this->getRequestValue($request, 'profile_url', ''); + $cursor = $this->getRequestValue($request, 'cursor', -1); + $stringify_ids = $this->getRequestValue($request, 'stringify_ids', false); + $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); + // Friendica-specific - $since_id = filter_input(INPUT_GET, 'since_id' , FILTER_VALIDATE_INT); - $max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT); - $min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT); + $since_id = $this->getRequestValue($request, 'since_id', 0, 0); + $max_id = $this->getRequestValue($request, 'max_id', 0, 0); + $min_id = $this->getRequestValue($request, 'min_id', 0, 0); $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); diff --git a/src/Module/Api/Twitter/Friends/Lists.php b/src/Module/Api/Twitter/Friends/Lists.php index dc2c26166..65dcec8ec 100644 --- a/src/Module/Api/Twitter/Friends/Lists.php +++ b/src/Module/Api/Twitter/Friends/Lists.php @@ -37,21 +37,18 @@ class Lists extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $contact_id = filter_input(INPUT_GET, 'user_id' , FILTER_VALIDATE_INT); - $screen_name = filter_input(INPUT_GET, 'screen_name'); - $profile_url = filter_input(INPUT_GET, 'profile_url'); - $cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]); - $skip_status = filter_input(INPUT_GET, 'skip_status' , FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $include_user_entities = filter_input(INPUT_GET, 'include_user_entities', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [ - 'default' => self::DEFAULT_COUNT, - 'min_range' => 1, - 'max_range' => self::MAX_COUNT, - ]]); + $contact_id = $this->getRequestValue($request, 'user_id', 0); + $screen_name = $this->getRequestValue($request, 'screen_name', ''); + $profile_url = $this->getRequestValue($request, 'profile_url', ''); + $cursor = $this->getRequestValue($request, 'cursor', -1); + $skip_status = $this->getRequestValue($request, 'skip_status', false); + $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false); + $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); + // Friendica-specific - $since_id = filter_input(INPUT_GET, 'since_id', FILTER_VALIDATE_INT); - $max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT); - $min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT); + $since_id = $this->getRequestValue($request, 'since_id', 0, 0); + $max_id = $this->getRequestValue($request, 'max_id', 0, 0); + $min_id = $this->getRequestValue($request, 'min_id', 0, 0); $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); diff --git a/src/Module/Api/Twitter/Friendships/Incoming.php b/src/Module/Api/Twitter/Friendships/Incoming.php index 315ef0033..378159c3c 100644 --- a/src/Module/Api/Twitter/Friendships/Incoming.php +++ b/src/Module/Api/Twitter/Friendships/Incoming.php @@ -37,17 +37,14 @@ class Incoming extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $cursor = filter_input(INPUT_GET, 'cursor' , FILTER_VALIDATE_INT, ['options' => ['default' => -1]]); - $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [ - 'default' => self::DEFAULT_COUNT, - 'min_range' => 1, - 'max_range' => self::MAX_COUNT, - ]]); + $cursor = $this->getRequestValue($request, 'cursor', -1); + $stringify_ids = $this->getRequestValue($request, 'stringify_ids', false); + $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); + // Friendica-specific - $since_id = filter_input(INPUT_GET, 'since_id', FILTER_VALIDATE_INT); - $max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT); - $min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT); + $since_id = $this->getRequestValue($request, 'since_id', 0, 0); + $max_id = $this->getRequestValue($request, 'max_id', 0, 0); + $min_id = $this->getRequestValue($request, 'min_id', 0, 0); $params = ['order' => ['cid' => true], 'limit' => $count];