From c0e26341d9e05cc691ed33cbdb2aa5fd49b73585 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 27 Mar 2015 20:25:24 -0700 Subject: [PATCH] Civi\API\Subscriber\ChainSubscriber - Reuse the inputted kernel, not the global kernel. --- Civi/API/Subscriber/ChainSubscriber.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Civi/API/Subscriber/ChainSubscriber.php b/Civi/API/Subscriber/ChainSubscriber.php index a44a4be3a2..944dc71fa0 100644 --- a/Civi/API/Subscriber/ChainSubscriber.php +++ b/Civi/API/Subscriber/ChainSubscriber.php @@ -69,7 +69,7 @@ class ChainSubscriber implements EventSubscriberInterface { $apiRequest = $event->getApiRequest(); $result = $event->getResponse(); if (\CRM_Utils_Array::value('is_error', $result, 0) == 0) { - $this->callNestedApi($apiRequest['params'], $result, $apiRequest['action'], $apiRequest['entity'], $apiRequest['version']); + $this->callNestedApi($event->getApiKernel(), $apiRequest['params'], $result, $apiRequest['action'], $apiRequest['entity'], $apiRequest['version']); $event->setResponse($result); } } @@ -78,6 +78,7 @@ class ChainSubscriber implements EventSubscriberInterface { * Call any nested api calls. * * TODO: We don't really need this to be a separate function. + * @param \Civi\API\Kernel $apiKernel * @param $params * @param $result * @param $action @@ -85,7 +86,7 @@ class ChainSubscriber implements EventSubscriberInterface { * @param $version * @throws \Exception */ - protected function callNestedApi(&$params, &$result, $action, $entity, $version) { + protected function callNestedApi($apiKernel, &$params, &$result, $action, $entity, $version) { $lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity); // We don't need to worry about nested api in the getfields/getoptions @@ -182,7 +183,7 @@ class ChainSubscriber implements EventSubscriberInterface { foreach ($newparams as $entityparams) { $subParams = array_merge($genericParams, $entityparams); _civicrm_api_replace_variables($subParams, $result['values'][$idIndex], $separator); - $result['values'][$result['id']][$field][] = civicrm_api($subEntity, $subaction, $subParams); + $result['values'][$result['id']][$field][] = $apiKernel->run($subEntity, $subaction, $subParams); if ($result['is_error'] === 1) { throw new \Exception($subEntity . ' ' . $subaction . 'call failed with' . $result['error_message']); } @@ -192,7 +193,7 @@ class ChainSubscriber implements EventSubscriberInterface { $subParams = array_merge($subParams, $newparams); _civicrm_api_replace_variables($subParams, $result['values'][$idIndex], $separator); - $result['values'][$idIndex][$field] = civicrm_api($subEntity, $subaction, $subParams); + $result['values'][$idIndex][$field] = $apiKernel->run($subEntity, $subaction, $subParams); if (!empty($result['is_error'])) { throw new \Exception($subEntity . ' ' . $subaction . 'call failed with' . $result['error_message']); } -- 2.25.1