From: eileen Date: Wed, 3 Feb 2021 07:23:35 +0000 (+1300) Subject: Move require once in api kernel to support edge cases X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=80b79a0aec46ca4146d152c67001ff3296b28502;p=civicrm-core.git 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 --- 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;