From 80b79a0aec46ca4146d152c67001ff3296b28502 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 3 Feb 2021 20:23:35 +1300 Subject: [PATCH] Move require once in api kernel to support edge cases The function 'createError' on the kernel class calls 3 functions that are in the api v3 utils file. It is possible to reach this from apiv4 using drush (I realise we don't really know much about how to support api v4 with drush but it DOES work with a simple api with this patch in my testing). We could go with only including utils.php in v4 api AND the createError function. I think it's more readable this way. To test this try drush cvapi Contribution.get version=4 it will legitimately fail without checkPermissions=0 but it will fail with a require_once error without this patch --- Civi/API/Kernel.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Civi/API/Kernel.php b/Civi/API/Kernel.php index 91544231ae..f3cab8ed09 100644 --- a/Civi/API/Kernel.php +++ b/Civi/API/Kernel.php @@ -159,12 +159,15 @@ class Kernel { */ public function boot($apiRequest) { require_once 'api/Exception.php'; + // the create error function loads some functions from utils + // so this require is also needed for apiv4 until such time as + // we alter create error. + require_once 'api/v3/utils.php'; switch ($apiRequest['version']) { case 3: if (!is_array($apiRequest['params'])) { throw new \API_Exception('Input variable `params` is not an array', 2000); } - require_once 'api/v3/utils.php'; _civicrm_api3_initialize(); break; -- 2.25.1