From: Thomas Schüttler Date: Mon, 31 Jul 2017 10:30:23 +0000 (+0200) Subject: Allow filtering when return options are set X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=525ccb6876f522297f8845cec1b150a744fd0811;p=civicrm-core.git Allow filtering when return options are set --- diff --git a/api/v3/Extension.php b/api/v3/Extension.php index bb3735ca79..b618a37e83 100644 --- a/api/v3/Extension.php +++ b/api/v3/Extension.php @@ -359,7 +359,10 @@ function civicrm_api3_extension_get($params) { } } $options = _civicrm_api3_get_options_from_params($params); - $returnFields = !empty($options['return']) ? $options['return'] : array('id'); + $returnFields = !empty($options['return']) ? $options['return'] : array(); + if (!in_array('id', $returnFields)) { + $returnFields = array_merge($returnFields, array('id')); + } return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', $returnFields); } diff --git a/tests/phpunit/api/v3/ExtensionTest.php b/tests/phpunit/api/v3/ExtensionTest.php index 2353d156e4..bb04b2a717 100644 --- a/tests/phpunit/api/v3/ExtensionTest.php +++ b/tests/phpunit/api/v3/ExtensionTest.php @@ -109,7 +109,7 @@ class api_v3_ExtensionTest extends CiviUnitTestCase { * Test that extension get can be filtered by id. */ public function testGetExtensionByID() { - $result = $this->callAPISuccess('extension', 'get', array('id' => 2)); + $result = $this->callAPISuccess('extension', 'get', array('id' => 2, 'return' => array('label'))); $this->assertEquals(1, $result['count']); }