3

In ap4, there are apparently two different ways to specify skipping permissions:

In the api4 browser at /civicrm/api4, when you un-check the "CheckPermissions" checkbox, the action method is given a single boolean-negative argument:

\Civi\Api4\Contact::get(FALSE)

But various documentation (e.g. https://docs.civicrm.org/dev/en/latest/api/v4/joins/#using-an-api-join and https://docs.civicrm.org/dev/en/latest/api/v4/differences-with-v3/) describes an explicit method:

\Civi\Api4\Email::get()
...
  ->setCheckPermissions(FALSE)
...

I assume these are equivalent. Personally I prefer the more explicit method as it's well, more explicit, but I wonder:

Is one of these preferred as a best practice, in the community at large or by core developers?

1 Answer 1

3

Core tends to use the short form but both are equally valid. The short form was introduced later just because it comes up so often that you want to set it to false.

1
  • The shorthand version has been available since 5.29.0. I started using it lots and got continually frustrated by errors when I ran my code on pre 5.29 sites! Commented Dec 13, 2020 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.