]> git.mxchange.org Git - friendica.git/commitdiff
Throw NotFoundException if results are empty in api_users_lookup
authorPierre Rudloff <contact@rudloff.pro>
Tue, 19 Dec 2017 10:37:55 +0000 (11:37 +0100)
committerPierre Rudloff <contact@rudloff.pro>
Tue, 19 Dec 2017 10:37:55 +0000 (11:37 +0100)
include/api.php

index ced1f1cbb8517accd4d6bc6d38f69584bb138225..6201b460a3c162e6ce96d68ea9660740568a35ca 100644 (file)
@@ -1494,16 +1494,24 @@ api_register_func('api/users/search', 'api_users_search');
  *
  * @return array|string
  * @throws UnauthorizedException
+ * @throws NotFoundException
  */
 function api_users_lookup($type)
 {
        $users = array();
-       foreach (explode(',', $_REQUEST['user_id']) as $id) {
-               if (!empty($id)) {
-                       $users[] = api_get_user(get_app(), $id);
+
+       if (x($_REQUEST['user_id'])) {
+               foreach (explode(',', $_REQUEST['user_id']) as $id) {
+                       if (!empty($id)) {
+                               $users[] = api_get_user(get_app(), $id);
+                       }
                }
        }
 
+       if (empty($users)) {
+               throw new NotFoundException;
+       }
+
        return api_format_data("users", $type, array('users' => $users));
 }