]> git.mxchange.org Git - friendica.git/commitdiff
Changed:
authorRoland Häder <roland@mxchange.org>
Thu, 28 Jul 2022 22:36:07 +0000 (00:36 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 28 Jul 2022 22:38:46 +0000 (00:38 +0200)
- used `$this->getRequestValue($request, 'foo', <bar>)` instead of `$request['foo'] ?? <bar>`
- fixed wrong variable naming
- changed double-quotes to single
- see https://github.com/friendica/friendica/issues/11631#issuecomment-1196410497

21 files changed:
src/Model/Contact.php
src/Module/Api/Friendica/DirectMessages/Search.php
src/Module/Api/Friendica/Group/Delete.php
src/Module/Api/Friendica/Notification/Seen.php
src/Module/Api/GNUSocial/Statusnet/Conversation.php
src/Module/Api/Twitter/Account/RateLimitStatus.php
src/Module/Api/Twitter/DirectMessages/Conversation.php
src/Module/Api/Twitter/DirectMessages/Destroy.php
src/Module/Api/Twitter/DirectMessages/NewDM.php
src/Module/Api/Twitter/DirectMessagesEndpoint.php
src/Module/Api/Twitter/Favorites/Create.php
src/Module/Api/Twitter/Favorites/Destroy.php
src/Module/Api/Twitter/Followers/Ids.php
src/Module/Api/Twitter/Followers/Lists.php
src/Module/Api/Twitter/Friends/Ids.php
src/Module/Api/Twitter/Friends/Lists.php
src/Module/Api/Twitter/Friendships/Destroy.php
src/Module/Api/Twitter/Friendships/Show.php
src/Module/Api/Twitter/Statuses/UserTimeline.php
src/Module/Api/Twitter/Users/Show.php
src/Module/Feed.php

index a6bb882e8652c8ea0496656ba39a310ba8cbe087..3d38005455f338440d34225d36e8dc542034f8e5 100644 (file)
@@ -2969,7 +2969,7 @@ class Contact
 
                $cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
 
-               DI::notification()->deleteForUserByVerb($contact['uid'], Activity::FOLLOW, ['actor-id' => $cdata['public']]);
+               DI::notification()->deleteForUserByVerb($contact['uid'], Activity::FOLLOW, ['actor-id' => $contact['public']]);
        }
 
        /**
index 67f8193f251470fec1f0d071a74cb998344a3968..26d8efaf7834d8ba53d71ea0d16aa8fd0e9f9cf1 100644 (file)
@@ -77,7 +77,7 @@ class Search extends BaseApi
                } else {
                        $ret = [];
                        foreach ($mails as $mail) {
-                               $ret[] = $this->directMessage->createFromMailId($mail['id'], $uid, $request['getText'] ?? '');
+                               $ret[] = $this->directMessage->createFromMailId($mail['id'], $uid, $this->getRequestValue($request, 'getText', ''));
                        }
                        $success = ['success' => true, 'search_results' => $ret];
                }
index d48e9a4f9d49566c3cb0d8453d3ebab07ccad5b0..d263bbbd74f430409077eb9892a4f61369226abe 100644 (file)
@@ -44,7 +44,7 @@ class Delete extends BaseApi
                // params
 
                // error if no gid specified
-               if ($request['gid'] == 0 || $request['name'] == "") {
+               if ($request['gid'] == 0 || $request['name'] == '') {
                        throw new BadRequestException('gid or name not specified');
                }
 
index 7a52a124df97cabbf6b96da082e15b94843f1991..00015d90bc78316801e42fd395ac746667f7ab33 100644 (file)
@@ -47,7 +47,7 @@ class Seen extends BaseApi
                        throw new BadRequestException('Invalid argument count');
                }
 
-               $id = intval($request['id'] ?? 0);
+               $id = intval($this->getRequestValue($request, 'id', 0));
 
                $include_entities = $this->getRequestValue($request, 'include_entities', false);
 
index 65ef9654b860ef6c493b41e0a813b62a235919e9..98d1de14d00179fe6c0f3adc7538cd71a0616831 100644 (file)
@@ -50,7 +50,7 @@ class Conversation extends BaseApi
                $start = max(0, ($page - 1) * $count);
 
                if ($id == 0) {
-                       $id = $request['id'] ?? 0;
+                       $id = $this->getRequestValue($request, 'id', 0);
                }
 
                Logger::info(BaseApi::LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
index c5f052b39456b64950419caae58cb981bc5d1915..739ed04b5d213d8c624bc5cb6a8279c625e6be81 100644 (file)
@@ -34,13 +34,13 @@ class RateLimitStatus extends BaseApi
                if (($this->parameters['extension'] ?? '') == 'xml') {
                        $hash = [
                                'remaining-hits'        => '150',
-                               '@attributes'           => ["type" => "integer"],
+                               '@attributes'           => ['type' => 'integer'],
                                'hourly-limit'          => '150',
-                               '@attributes2'          => ["type" => "integer"],
+                               '@attributes2'          => ['type' => 'integer'],
                                'reset-time'            => DateTimeFormat::utc('now + 1 hour', DateTimeFormat::ATOM),
-                               '@attributes3'          => ["type" => "datetime"],
+                               '@attributes3'          => ['type' => 'datetime'],
                                'reset_time_in_seconds' => strtotime('now + 1 hour'),
-                               '@attributes4'          => ["type" => "integer"],
+                               '@attributes4'          => ['type' => 'integer'],
                        ];
                } else {
                        $hash = [
index ebd4b6bbc46b3da2ad61c497258eae9b081e1c5e..808189c24df8b3b40b7b7df5ab296df1c0d90e9d 100644 (file)
@@ -34,6 +34,6 @@ class Conversation extends DirectMessagesEndpoint
                BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
                $uid = BaseApi::getCurrentUserID();
 
-               $this->getMessages($request, $uid, ["`parent-uri` = ?", $request['uri'] ?? '']);
+               $this->getMessages($request, $uid, ["`parent-uri` = ?", $this->getRequestValue($request, 'uri', '')]);
        }
 }
index 9de09823640b79300d44096ddd6f9fdd5eaefecc..2b95f7a6b68d7bb2590cfa95f789c5dd172723d0 100644 (file)
@@ -55,9 +55,8 @@ class Destroy extends BaseApi
                $id = $this->getRequestValue($request, 'id', 0);
                $id = $this->getRequestValue($this->parameters, 'id', $id);
 
-               $verbose = $this->getRequestValue($request, 'friendica_verbose', false);
-
-               $parenturi = $request['friendica_parenturi'] ?? '';
+               $verbose   = $this->getRequestValue($request, 'friendica_verbose', false);
+               $parenturi = $this->getRequestValue($request, 'friendica_parenturi', '');
 
                // error if no id or parenturi specified (for clients posting parent-uri as well)
                if ($verbose && $id == 0 && $parenturi == "") {
index 7ac82533e843b1f50c81744e446f4e2723ee7ac0..1eaa601953256d753b46be011cf52688b4f194a0 100644 (file)
@@ -63,7 +63,7 @@ class NewDM extends BaseApi
                        return;
                }
 
-               $cid = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, 0);
+               $cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), 0);
                if (empty($cid)) {
                        throw new NotFoundException('Recipient not found');
                }
@@ -86,7 +86,7 @@ class NewDM extends BaseApi
                $id = Mail::send($cdata['user'], $request['text'], $sub, $replyto);
 
                if ($id > -1) {
-                       $ret = $this->directMessage->createFromMailId($id, $uid, $request['getText'] ?? '');
+                       $ret = $this->directMessage->createFromMailId($id, $uid, $this->getRequestValue($request, 'getText', ''));
                } else {
                        $ret = ['error' => $id];
                }
index 28b867889f600a08bebdd17e9cdf45521cb48a03..5505c6c44c201b088562502b6098fc13dac7b539 100644 (file)
@@ -84,7 +84,7 @@ abstract class DirectMessagesEndpoint extends BaseApi
                        $params['order'] = ['id'];
                }
 
-               $cid = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, 0);
+               $cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), 0);
                if (!empty($cid)) {
                        $cdata = Contact::getPublicAndUserContactID($cid, $uid);
                        if (!empty($cdata['user'])) {
@@ -109,7 +109,7 @@ abstract class DirectMessagesEndpoint extends BaseApi
 
                $ret = [];
                foreach ($ids as $id) {
-                       $ret[] = $this->directMessage->createFromMailId($id, $uid, $request['getText'] ?? '');
+                       $ret[] = $this->directMessage->createFromMailId($id, $uid, $this->getRequestValue($request, 'getText', ''));
                }
 
                self::setLinkHeader();
index 6544fe470c7144d66c6549e963f4305c9c6908c9..c81b5af87346a78e8fe9d10dcfbbafa509c091e8 100644 (file)
@@ -37,7 +37,7 @@ class Create extends BaseApi
                self::checkAllowedScope(self::SCOPE_WRITE);
                $uid = self::getCurrentUserID();
 
-               $id = $request['id'] ?? 0;
+               $id = $this->getRequestValue($request, 'id', 0);
 
                if (empty($id)) {
                        throw new BadRequestException('Item id not specified');
index 0d3046afb136a671f96aafef91023dfdcca046fd..c03064e79a11b9bd08241999070615648a4e865e 100644 (file)
@@ -37,7 +37,7 @@ class Destroy extends BaseApi
                self::checkAllowedScope(self::SCOPE_WRITE);
                $uid = self::getCurrentUserID();
 
-               $id = $request['id'] ?? 0;
+               $id = $this->getRequestValue($request, 'id', 0);
 
                if (empty($id)) {
                        throw new BadRequestException('Item id not specified');
index df7120ab62ac1529664a10a39393efb114379937..6acf7c83110607ee7f65955480c51b756e49dc7a 100644 (file)
@@ -37,7 +37,7 @@ class Ids extends ContactEndpoint
                $uid = BaseApi::getCurrentUserID();
 
                // Expected value for user_id parameter: public/user contact id
-               $cid           = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid);
+               $cid           = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid);
                $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);
index 0e9a2aa82a04a71da775a183ecbb75c4806fd8fc..fbae33652f7aaffab5af9076caa10a68c8697b8b 100644 (file)
@@ -37,7 +37,7 @@ class Lists extends ContactEndpoint
                $uid = BaseApi::getCurrentUserID();
 
                // Expected value for user_id parameter: public/user contact id
-               $cid                   = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid);
+               $cid                   = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid);
                $cursor                = $this->getRequestValue($request, 'cursor', -1);
                $skip_status           = $this->getRequestValue($request, 'skip_status', false);
                $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false);
index b5b571a9f06b6691b3346aa0ff444592908ca7a9..a46be8deb9910a759755dd4dcd804cab08ba4f0a 100644 (file)
@@ -37,7 +37,7 @@ class Ids extends ContactEndpoint
                $uid = BaseApi::getCurrentUserID();
 
                // Expected value for user_id parameter: public/user contact id
-               $cid           = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid);
+               $cid           = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid);
                $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);
index 750ba6db6128d93b8f8a1429c39fa2b8b537d45b..304f19db9e4cb1db9185cdbcac076ed672825611 100644 (file)
@@ -37,7 +37,7 @@ class Lists extends ContactEndpoint
                $uid = BaseApi::getCurrentUserID();
 
                // Expected value for user_id parameter: public/user contact id
-               $cid                   = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid);
+               $cid                   = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid);
                $cursor                = $this->getRequestValue($request, 'cursor', -1);
                $skip_status           = $this->getRequestValue($request, 'skip_status', false);
                $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false);
index b730f0663650f69535a75fec6506a8e8ba96e372..d324fc6be4f648e47ef068ded2387010a5fc9592 100644 (file)
@@ -63,7 +63,7 @@ class Destroy extends ContactEndpoint
                        throw new HTTPException\NotFoundException('Error Processing Request');
                }
 
-               $contact_id = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, 0);
+               $contact_id = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), 0);
 
                if (empty($contact_id)) {
                        Logger::notice(BaseApi::LOG_PREFIX . 'No user_id specified', ['module' => 'api', 'action' => 'friendships_destroy']);
index 66605e72650822f47483f75787ebb256dcffa083..c05dc09023172258ce243b925670bd20ed6ce498 100644 (file)
@@ -38,9 +38,8 @@ class Show extends ContactEndpoint
                self::checkAllowedScope(self::SCOPE_READ);
                $uid = BaseApi::getCurrentUserID();
 
-               $source_cid = BaseApi::getContactIDForSearchterm($request['source_screen_name'] ?? '', '', $request['source_id'] ?? 0, $uid);
-
-               $target_cid = BaseApi::getContactIDForSearchterm($request['target_screen_name'] ?? '', '', $request['target_id'] ?? 0, $uid);
+               $source_cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'source_screen_name', ''), '', $this->getRequestValue($request, 'source_id', 0), $uid);
+               $target_cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'target_screen_name', ''), '', $this->getRequestValue($request, 'target_id', 0), $uid);
 
                $source = Contact::getById($source_cid);
                if (empty($source)) {
index 05aa079624923e97cdb64dc3ffd00571cbf64296..a6616636cac1a93f9a204f22dc1c6eb46490f886 100644 (file)
@@ -42,7 +42,7 @@ class UserTimeline extends BaseApi
 
                Logger::info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]);
 
-               $cid              = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid);
+               $cid              = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid);
                $count            = $this->getRequestValue($request, 'count', 20, 1, 100);
                $page             = $this->getRequestValue($request, 'page', 1, 1);
                $since_id         = $this->getRequestValue($request, 'since_id', 0, 0);
index e6bd24d27bd8491545609bf7998137c8f404dcba..27510b93877bebc9ce21a9bb1ae69523e6fc150b 100644 (file)
@@ -38,7 +38,7 @@ class Show extends BaseApi
                $uid = BaseApi::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       $cid = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid);
+                       $cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid);
                } else {
                        $cid = (int)$this->parameters['id'];
                }
index 9acde7bb30c61e8c2654650beca795f318a04672..4c942cd762c1608a0a6a73c62d86e49ca0eaa763 100644 (file)
@@ -45,7 +45,7 @@ class Feed extends BaseModule
 {
        protected function rawContent(array $request = [])
        {
-               $last_update = $request['last_update'] ?? '';
+               $last_update = $this->getRequestValue($request, 'last_update', '');
                $nocache     = !empty($request['nocache']) && local_user();
 
                $type = null;