1
0
Fork 0

Merge pull request #11792 from Quix0r/fixes/get-request-value

Wrong variable name fixed (maybe copy-paste mistake) + used method instead of direct array access
This commit is contained in:
Hypolite Petovan 2022-07-28 21:17:34 -04:00 committed by GitHub
commit a20d05ba39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 28 additions and 30 deletions

View file

@ -2969,7 +2969,7 @@ class Contact
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']); $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']]);
} }
/** /**

View file

@ -77,7 +77,7 @@ class Search extends BaseApi
} else { } else {
$ret = []; $ret = [];
foreach ($mails as $mail) { 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]; $success = ['success' => true, 'search_results' => $ret];
} }

View file

@ -44,7 +44,7 @@ class Delete extends BaseApi
// params // params
// error if no gid specified // 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'); throw new BadRequestException('gid or name not specified');
} }

View file

@ -47,7 +47,7 @@ class Seen extends BaseApi
throw new BadRequestException('Invalid argument count'); 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); $include_entities = $this->getRequestValue($request, 'include_entities', false);

View file

@ -50,7 +50,7 @@ class Conversation extends BaseApi
$start = max(0, ($page - 1) * $count); $start = max(0, ($page - 1) * $count);
if ($id == 0) { 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]); Logger::info(BaseApi::LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);

View file

@ -34,13 +34,13 @@ class RateLimitStatus extends BaseApi
if (($this->parameters['extension'] ?? '') == 'xml') { if (($this->parameters['extension'] ?? '') == 'xml') {
$hash = [ $hash = [
'remaining-hits' => '150', 'remaining-hits' => '150',
'@attributes' => ["type" => "integer"], '@attributes' => ['type' => 'integer'],
'hourly-limit' => '150', 'hourly-limit' => '150',
'@attributes2' => ["type" => "integer"], '@attributes2' => ['type' => 'integer'],
'reset-time' => DateTimeFormat::utc('now + 1 hour', DateTimeFormat::ATOM), 'reset-time' => DateTimeFormat::utc('now + 1 hour', DateTimeFormat::ATOM),
'@attributes3' => ["type" => "datetime"], '@attributes3' => ['type' => 'datetime'],
'reset_time_in_seconds' => strtotime('now + 1 hour'), 'reset_time_in_seconds' => strtotime('now + 1 hour'),
'@attributes4' => ["type" => "integer"], '@attributes4' => ['type' => 'integer'],
]; ];
} else { } else {
$hash = [ $hash = [

View file

@ -34,6 +34,6 @@ class Conversation extends DirectMessagesEndpoint
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
$this->getMessages($request, $uid, ["`parent-uri` = ?", $request['uri'] ?? '']); $this->getMessages($request, $uid, ["`parent-uri` = ?", $this->getRequestValue($request, 'uri', '')]);
} }
} }

View file

@ -55,9 +55,8 @@ class Destroy extends BaseApi
$id = $this->getRequestValue($request, 'id', 0); $id = $this->getRequestValue($request, 'id', 0);
$id = $this->getRequestValue($this->parameters, 'id', $id); $id = $this->getRequestValue($this->parameters, 'id', $id);
$verbose = $this->getRequestValue($request, 'friendica_verbose', false); $verbose = $this->getRequestValue($request, 'friendica_verbose', false);
$parenturi = $this->getRequestValue($request, 'friendica_parenturi', '');
$parenturi = $request['friendica_parenturi'] ?? '';
// error if no id or parenturi specified (for clients posting parent-uri as well) // error if no id or parenturi specified (for clients posting parent-uri as well)
if ($verbose && $id == 0 && $parenturi == "") { if ($verbose && $id == 0 && $parenturi == "") {

View file

@ -63,7 +63,7 @@ class NewDM extends BaseApi
return; 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)) { if (empty($cid)) {
throw new NotFoundException('Recipient not found'); throw new NotFoundException('Recipient not found');
} }
@ -86,7 +86,7 @@ class NewDM extends BaseApi
$id = Mail::send($cdata['user'], $request['text'], $sub, $replyto); $id = Mail::send($cdata['user'], $request['text'], $sub, $replyto);
if ($id > -1) { if ($id > -1) {
$ret = $this->directMessage->createFromMailId($id, $uid, $request['getText'] ?? ''); $ret = $this->directMessage->createFromMailId($id, $uid, $this->getRequestValue($request, 'getText', ''));
} else { } else {
$ret = ['error' => $id]; $ret = ['error' => $id];
} }

View file

@ -84,7 +84,7 @@ abstract class DirectMessagesEndpoint extends BaseApi
$params['order'] = ['id']; $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)) { if (!empty($cid)) {
$cdata = Contact::getPublicAndUserContactID($cid, $uid); $cdata = Contact::getPublicAndUserContactID($cid, $uid);
if (!empty($cdata['user'])) { if (!empty($cdata['user'])) {
@ -109,7 +109,7 @@ abstract class DirectMessagesEndpoint extends BaseApi
$ret = []; $ret = [];
foreach ($ids as $id) { foreach ($ids as $id) {
$ret[] = $this->directMessage->createFromMailId($id, $uid, $request['getText'] ?? ''); $ret[] = $this->directMessage->createFromMailId($id, $uid, $this->getRequestValue($request, 'getText', ''));
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -37,7 +37,7 @@ class Create extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE); self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID(); $uid = self::getCurrentUserID();
$id = $request['id'] ?? 0; $id = $this->getRequestValue($request, 'id', 0);
if (empty($id)) { if (empty($id)) {
throw new BadRequestException('Item id not specified'); throw new BadRequestException('Item id not specified');

View file

@ -37,7 +37,7 @@ class Destroy extends BaseApi
self::checkAllowedScope(self::SCOPE_WRITE); self::checkAllowedScope(self::SCOPE_WRITE);
$uid = self::getCurrentUserID(); $uid = self::getCurrentUserID();
$id = $request['id'] ?? 0; $id = $this->getRequestValue($request, 'id', 0);
if (empty($id)) { if (empty($id)) {
throw new BadRequestException('Item id not specified'); throw new BadRequestException('Item id not specified');

View file

@ -37,7 +37,7 @@ class Ids extends ContactEndpoint
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id // 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); $cursor = $this->getRequestValue($request, 'cursor', -1);
$stringify_ids = $this->getRequestValue($request, 'stringify_ids', false); $stringify_ids = $this->getRequestValue($request, 'stringify_ids', false);
$count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT);

View file

@ -37,7 +37,7 @@ class Lists extends ContactEndpoint
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id // 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); $cursor = $this->getRequestValue($request, 'cursor', -1);
$skip_status = $this->getRequestValue($request, 'skip_status', false); $skip_status = $this->getRequestValue($request, 'skip_status', false);
$include_user_entities = $this->getRequestValue($request, 'include_user_entities', false); $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false);

View file

@ -37,7 +37,7 @@ class Ids extends ContactEndpoint
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id // 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); $cursor = $this->getRequestValue($request, 'cursor', -1);
$stringify_ids = $this->getRequestValue($request, 'stringify_ids', false); $stringify_ids = $this->getRequestValue($request, 'stringify_ids', false);
$count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT);

View file

@ -37,7 +37,7 @@ class Lists extends ContactEndpoint
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
// Expected value for user_id parameter: public/user contact id // 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); $cursor = $this->getRequestValue($request, 'cursor', -1);
$skip_status = $this->getRequestValue($request, 'skip_status', false); $skip_status = $this->getRequestValue($request, 'skip_status', false);
$include_user_entities = $this->getRequestValue($request, 'include_user_entities', false); $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false);

View file

@ -63,7 +63,7 @@ class Destroy extends ContactEndpoint
throw new HTTPException\NotFoundException('Error Processing Request'); 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)) { if (empty($contact_id)) {
Logger::notice(BaseApi::LOG_PREFIX . 'No user_id specified', ['module' => 'api', 'action' => 'friendships_destroy']); Logger::notice(BaseApi::LOG_PREFIX . 'No user_id specified', ['module' => 'api', 'action' => 'friendships_destroy']);

View file

@ -38,9 +38,8 @@ class Show extends ContactEndpoint
self::checkAllowedScope(self::SCOPE_READ); self::checkAllowedScope(self::SCOPE_READ);
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
$source_cid = BaseApi::getContactIDForSearchterm($request['source_screen_name'] ?? '', '', $request['source_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);
$target_cid = BaseApi::getContactIDForSearchterm($request['target_screen_name'] ?? '', '', $request['target_id'] ?? 0, $uid);
$source = Contact::getById($source_cid); $source = Contact::getById($source_cid);
if (empty($source)) { if (empty($source)) {

View file

@ -42,7 +42,7 @@ class UserTimeline extends BaseApi
Logger::info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]); 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); $count = $this->getRequestValue($request, 'count', 20, 1, 100);
$page = $this->getRequestValue($request, 'page', 1, 1); $page = $this->getRequestValue($request, 'page', 1, 1);
$since_id = $this->getRequestValue($request, 'since_id', 0, 0); $since_id = $this->getRequestValue($request, 'since_id', 0, 0);

View file

@ -38,7 +38,7 @@ class Show extends BaseApi
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
if (empty($this->parameters['id'])) { 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 { } else {
$cid = (int)$this->parameters['id']; $cid = (int)$this->parameters['id'];
} }

View file

@ -45,7 +45,7 @@ class Feed extends BaseModule
{ {
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$last_update = $request['last_update'] ?? ''; $last_update = $this->getRequestValue($request, 'last_update', '');
$nocache = !empty($request['nocache']) && local_user(); $nocache = !empty($request['nocache']) && local_user();
$type = null; $type = null;