]> git.mxchange.org Git - friendica.git/commitdiff
Improved parameter assignment
authorMichael <heluecht@pirati.ca>
Tue, 18 May 2021 04:54:37 +0000 (04:54 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 18 May 2021 04:54:37 +0000 (04:54 +0000)
src/Module/Api/Mastodon/Accounts/Search.php
src/Module/Api/Mastodon/Search.php

index f74e35713cab6792bb8000e428c8144e1b6e1b69..30031a3d1ca4ff9b827bf9d9c4e281393da93530 100644 (file)
@@ -46,11 +46,11 @@ class Search extends BaseApi
                // What to search for
                $q = $_REQUEST['q'] ?? '';
                // Maximum number of results. Defaults to 40.
-               $limit = (int)$_REQUEST['limit'] ?? 40;
+               $limit = (int)($_REQUEST['limit'] ?? 40);
                // Attempt WebFinger lookup. Defaults to false. Use this when q is an exact address.
-               $resolve = (bool)!isset($_REQUEST['resolve']) ? false : ($_REQUEST['resolve'] == 'true');
+               $resolve = ($_REQUEST['resolve'] ?? '') == 'true';
                // Only who the user is following. Defaults to false.
-               $following = (bool)!isset($_REQUEST['following']) ? false : ($_REQUEST['following'] == 'true');
+               $following = ($_REQUEST['following'] ?? '') == 'true';
 
                $accounts = [];
 
index b964b35db85b58bd4d155cb4ced2d69c67f7e5ee..2da3f341c401a9b7e6afb1af29c48fdcec3db086 100644 (file)
@@ -55,17 +55,17 @@ class Search extends BaseApi
                // Enum(accounts, hashtags, statuses)
                $type = $_REQUEST['type'] ?? '';
                // Filter out unreviewed tags? Defaults to false. Use true when trying to find trending tags.
-               $exclude_unreviewed = (bool)!isset($_REQUEST['exclude_unreviewed']) ? false : ($_REQUEST['exclude_unreviewed'] == 'true');
+               $exclude_unreviewed = ($_REQUEST['exclude_unreviewed'] ?? '') == 'true';
                // The search query
                $q = $_REQUEST['q'] ?? '';
                // Attempt WebFinger lookup. Defaults to false.
-               $resolve = (bool)!isset($_REQUEST['resolve']) ? false : ($_REQUEST['resolve'] == 'true');
+               $resolve = ($_REQUEST['resolve'] ?? '') == 'true';
                // Maximum number of results to load, per type. Defaults to 20. Max 40.
                $limit = (int)($_REQUEST['limit'] ?? 20);
                // Offset in search results. Used for pagination. Defaults to 0.
                $offset = (int)($_REQUEST['offset'] ?? 0);
                // Only who the user is following. Defaults to false.
-               $following = (bool)!isset($_REQUEST['following']) ? false : ($_REQUEST['following'] == 'true');
+               $following = ($_REQUEST['following'] ?? '') == 'true';
 
                $result = ['accounts' => [], 'statuses' => [], 'hashtags' => []];