Improved handling of boolean input values
This commit is contained in:
parent
e6108668e3
commit
7b68a5956e
13 changed files with 18 additions and 18 deletions
|
@ -65,7 +65,7 @@ class Seen extends BaseApi
|
|||
if ($Notify->otype === Notification\ObjectType::ITEM) {
|
||||
$item = Post::selectFirstForUser($uid, [], ['id' => $Notify->iid, 'uid' => $uid]);
|
||||
if (DBA::isResult($item)) {
|
||||
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
// we found the item, return it to the user
|
||||
$ret = [DI::twitterStatus()->createFromUriId($item['uri-id'], $item['uid'], $include_entities)->toArray()];
|
||||
|
|
|
@ -41,15 +41,15 @@ class Conversation extends BaseApi
|
|||
|
||||
// params
|
||||
$id = $this->parameters['id'] ?? 0;
|
||||
$since_id = $_REQUEST['since_id'] ?? 0;
|
||||
$max_id = $_REQUEST['max_id'] ?? 0;
|
||||
$count = $_REQUEST['count'] ?? 20;
|
||||
$page = $_REQUEST['page'] ?? 1;
|
||||
$since_id = $request['since_id'] ?? 0;
|
||||
$max_id = $request['max_id'] ?? 0;
|
||||
$count = $request['count'] ?? 20;
|
||||
$page = $request['page'] ?? 1;
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
if ($id == 0) {
|
||||
$id = $_REQUEST['id'] ?? 0;
|
||||
$id = $request['id'] ?? 0;
|
||||
}
|
||||
|
||||
Logger::info(BaseApi::LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
|
||||
|
@ -82,7 +82,7 @@ class Conversation extends BaseApi
|
|||
throw new BadRequestException("There is no status with id $id.");
|
||||
}
|
||||
|
||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -56,7 +56,7 @@ class UpdateProfile extends BaseApi
|
|||
|
||||
Profile::publishUpdate($uid);
|
||||
|
||||
$skip_status = $request['skip_status'] ?? false;
|
||||
$skip_status = filter_var($request['skip_status'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray();
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class VerifyCredentials extends BaseApi
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
$skip_status = $_REQUEST['skip_status'] ?? false;
|
||||
$skip_status = filter_var($request['skip_status'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray();
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class Statuses extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$items = [];
|
||||
while ($status = $this->dba->fetch($statuses)) {
|
||||
|
|
|
@ -115,7 +115,7 @@ class Tweets extends BaseApi
|
|||
|
||||
$statuses = $statuses ?: Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -50,7 +50,7 @@ class Destroy extends BaseApi
|
|||
|
||||
$this->logger->notice('API: api_statuses_destroy: ' . $id);
|
||||
|
||||
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = DI::twitterStatus()->createFromItemId($id, $uid, $include_entities)->toArray();
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class HomeTimeline extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
$idarray = [];
|
||||
|
|
|
@ -72,7 +72,7 @@ class Mentions extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -58,7 +58,7 @@ class NetworkPublicTimeline extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
|
||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -78,7 +78,7 @@ class PublicTimeline extends BaseApi
|
|||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
}
|
||||
|
||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -79,7 +79,7 @@ class Show extends BaseApi
|
|||
throw new BadRequestException(sprintf("There is no status or conversation with the id %d.", $id));
|
||||
}
|
||||
|
||||
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -74,7 +74,7 @@ class UserTimeline extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
Loading…
Reference in a new issue