From 56adca759054be92b572ccab77911ee161df3687 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 8 Aug 2022 14:10:59 -0700 Subject: [PATCH] (NFC) Comment noting parallel functions --- CRM/Api4/Page/AJAX.php | 5 +++-- CRM/Api4/Permission.php | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CRM/Api4/Page/AJAX.php b/CRM/Api4/Page/AJAX.php index 4816ea9c97..0aa40e94d9 100644 --- a/CRM/Api4/Page/AJAX.php +++ b/CRM/Api4/Page/AJAX.php @@ -58,8 +58,9 @@ class CRM_Api4_Page_AJAX extends CRM_Core_Page { CRM_Utils_System::civiExit(); } try { - // Call multiple + // Two call formats. Which one was used? Note: CRM_Api4_Permission::check() and CRM_Api4_Page_AJAX::run() should have matching conditionals. if (empty($this->urlPath[3])) { + // Received multi-call format $calls = CRM_Utils_Request::retrieve('calls', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'POST'); $calls = json_decode($calls, TRUE); $response = []; @@ -67,8 +68,8 @@ class CRM_Api4_Page_AJAX extends CRM_Core_Page { $response[$index] = call_user_func_array([$this, 'execute'], $call); } } - // Call single else { + // Received single-call format $entity = $this->urlPath[3]; $action = $this->urlPath[4]; $params = CRM_Utils_Request::retrieve('params', 'String'); diff --git a/CRM/Api4/Permission.php b/CRM/Api4/Permission.php index fa8d0ecca0..e476627656 100644 --- a/CRM/Api4/Permission.php +++ b/CRM/Api4/Permission.php @@ -26,7 +26,9 @@ class CRM_Api4_Permission { $defaultPermissions = [ ['access CiviCRM', 'access AJAX API'], ]; + // Two call formats. Which one was used? Note: CRM_Api4_Permission::check() and CRM_Api4_Page_AJAX::run() should have matching conditionals. if (!empty($urlPath[3])) { + // Received single-call format $entity = $urlPath[3]; $action = $urlPath[4]; $permissions = $defaultPermissions; @@ -34,6 +36,7 @@ class CRM_Api4_Permission { return CRM_Core_Permission::check($permissions); } else { + // Received multi-call format $calls = CRM_Utils_Request::retrieve('calls', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'POST'); $calls = json_decode($calls, TRUE); foreach ($calls as $call) { -- 2.25.1