From a329ce5b50fc118b8f5aa97e3c4ad6b8c941664c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 1 Jul 2018 00:16:32 -0400 Subject: [PATCH] Fix $called_api expecting at least 2 elements in tests --- include/api.php | 1 + tests/ApiTest.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/api.php b/include/api.php index 6d38be95b7..a9a1800af1 100644 --- a/include/api.php +++ b/include/api.php @@ -575,6 +575,7 @@ function api_get_user(App $a, $contact_id = null) } } + // $called_api is the API path exploded on / and is expected to have at least 2 elements if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) { $argid = count($called_api); list($user, $null) = explode(".", $a->argv[$argid]); diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 4c63af7a91..982f5bf11a 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -818,7 +818,7 @@ class ApiTest extends DatabaseTest public function testApiGetUserWithCalledApi() { global $called_api; - $called_api = ['api_path']; + $called_api = ['api', 'api_path']; $this->assertSelfUser(api_get_user($this->app)); }