diff --git a/CRM/SMS/Form/Provider.php b/CRM/SMS/Form/Provider.php index 6f209565504d..1a94c13d0f86 100644 --- a/CRM/SMS/Form/Provider.php +++ b/CRM/SMS/Form/Provider.php @@ -175,7 +175,7 @@ public function postProcess() { if ($this->_id) { $recData['id'] = $this->_id; } - CRM_SMS_BAO_Provider::create($recData); + civicrm_api3('SmsProvider', 'create', $recData); } } diff --git a/Civi/API/Subscriber/ChainSubscriber.php b/Civi/API/Subscriber/ChainSubscriber.php index fe8dce83403c..5906878f690c 100644 --- a/Civi/API/Subscriber/ChainSubscriber.php +++ b/Civi/API/Subscriber/ChainSubscriber.php @@ -125,6 +125,14 @@ protected function callNestedApi($apiKernel, &$params, &$result, $action, $entit ); $subEntity = _civicrm_api_get_entity_name_from_camel($subAPI[1]); + // Hard coded list of entitys that have fields starting api_ and shouldn't be automatically + // deemed to be chained API calls + if ((($subEntity == 'type' || $subEntity == 'url') && $entity == 'SmsProvider') || + ($entity == 'Job' && ($subEntity == 'prefix' || $subEntity == 'entity' || $subEntity == 'action')) || + ($entity == 'Contact' && $subEntity == 'key')) { + continue; + } + foreach ($result['values'] as $idIndex => $parentAPIValues) { if ($subEntity != 'contact') { diff --git a/tests/phpunit/CRM/SMS/BAO/ProviderTest.php b/tests/phpunit/CRM/SMS/BAO/ProviderTest.php index a451d105c773..185edf826bcb 100644 --- a/tests/phpunit/CRM/SMS/BAO/ProviderTest.php +++ b/tests/phpunit/CRM/SMS/BAO/ProviderTest.php @@ -65,12 +65,11 @@ public function testCreateAndUpdateProvider() { 'api_type' => 1, ); $this->callAPISuccess('SmsProvider', 'create', $values); - // CRM_SMS_BAO_Provider::create($values); $provider = $this->callAPISuccess('SmsProvider', 'getsingle', array('title' => 'test SMS provider')); $domain_id = CRM_Core_DAO::getFieldValue('CRM_SMS_DAO_Provider', $provider['id'], 'domain_id'); $this->assertNull($domain_id); $values2 = array('title' => 'Test SMS Provider2', 'id' => $provider['id']); - CRM_SMS_BAO_Provider::create($values2); + $this->callAPISuccess('SmsProvider', 'create', $values2); $provider = $this->callAPISuccess('SmsProvider', 'getsingle', array('id' => $provider['id'])); $this->assertEquals('Test SMS Provider2', $provider['title']); $domain_id = CRM_Core_DAO::getFieldValue('CRM_SMS_DAO_Provider', $provider['id'], 'domain_id'); @@ -90,7 +89,7 @@ public function testCreateWithoutDomain() { 'is_active' => 1, 'api_type' => 1, ); - CRM_SMS_BAO_Provider::create($values); + $this->callAPISuccess('SmsProvider', 'create', $values); $provider = $this->callAPISuccess('SmsProvider', 'getsingle', array('title' => 'test SMS provider')); $domain_id = CRM_Core_DAO::getFieldValue('CRM_SMS_DAO_Provider', $provider['id'], 'domain_id'); $this->assertEquals(CRM_Core_Config::domainID(), $domain_id);