Merge pull request #7624 from MrPetovan/bug/notices

Fix notice message when $return is undefined in Core\ACL
This commit is contained in:
Philipp 2019-09-14 05:05:14 +02:00 committed by GitHub
commit 43df34fe05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -186,8 +186,9 @@ function acl_content(App $a)
// autocomplete for global contact search (e.g. navbar search)
$search = Strings::escapeTags(trim($_REQUEST['search']));
$mode = $_REQUEST['smode'];
$page = $_REQUEST['page'] ?? 1;
$r = ACL::contactAutocomplete($search, $mode);
$r = ACL::contactAutocomplete($search, $mode, $page);
$contacts = [];
foreach ($r as $g) {

View file

@ -327,10 +327,11 @@ class ACL extends BaseObject
* @brief Searching for global contacts for autocompletion
* @param string $search Name or part of a name or nick
* @param string $mode Search mode (e.g. "community")
* @param int $page Page number (starts at 1)
* @return array with the search results
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function contactAutocomplete($search, $mode)
public static function contactAutocomplete($search, $mode, int $page = 1)
{
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
return [];
@ -349,9 +350,9 @@ class ACL extends BaseObject
if (Config::get('system', 'poco_local_search')) {
$return = GContact::searchByName($search, $mode);
} else {
$p = defaults($_GET, 'page', 1) != 1 ? '&p=' . defaults($_GET, 'page', 1) : '';
$p = $page > 1 ? 'p=' . $page : '';
$curlResult = Network::curl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
$curlResult = Network::curl(get_server() . '/lsearch?' . $p . '&search=' . urlencode($search));
if ($curlResult->isSuccess()) {
$lsearch = json_decode($curlResult->getBody(), true);
if (!empty($lsearch['results'])) {
@ -360,6 +361,6 @@ class ACL extends BaseObject
}
}
return defaults($return, []);
return $return ?? [];
}
}