Move require once in api kernel to support edge cases
authoreileen <emcnaughton@wikimedia.org>
Wed, 3 Feb 2021 07:23:35 +0000 (20:23 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 3 Feb 2021 07:23:38 +0000 (20:23 +1300)
commit80b79a0aec46ca4146d152c67001ff3296b28502
treecc4743e03e09f5a21864e0e1825fc23a071e4aed
parent995bab0ca21003aa85c962052ad0ff28f2af02c6
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