Answers.Body: <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-13T07:32:57.647Z
Answers.Text: The shorthand version has been available since [5.29.0](https://lab.civicrm.org/dev/core/-/commit/6764a9d37254c69efd9133ddb1e9a315bbff1d76). I started using it lots and got continually frustrated by errors when I ran my code on pre 5.29 sites!
Answers.UserDisplayName: artfulrobot
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-11T16:09:49.010Z
Answers.LastActivityDate: 2020-12-11T16:09:49.010Z
Answers.UserDisplayName: Demerit
Body: <p>In ap4, there are apparently two different ways to specify skipping permissions:</p>
  <p>In the api4 browser at /civicrm/api4, when you un-check the &quot;CheckPermissions&quot; checkbox, the action method is given a single boolean-negative argument:</p>
  <pre><code>\Civi\Api4\Contact::get(FALSE)
  </code></pre>
  <p>But various documentation (e.g. <a href="https://docs.civicrm.org/dev/en/latest/api/v4/joins/#using-an-api-join" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/api/v4/joins/#using-an-api-join</a> and <a href="https://docs.civicrm.org/dev/en/latest/api/v4/differences-with-v3/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/api/v4/differences-with-v3/</a>) describes an explicit method:</p>
  <pre><code>\Civi\Api4\Email::get()
  ...
    -&gt;setCheckPermissions(FALSE)
  ...
  </code></pre>
  <p>I assume these are equivalent. Personally I prefer the more explicit method as it's well, more explicit, but I wonder:</p>
  <p>Is one of these preferred as a best practice, in the community at large or by core developers?</p>
  
Tags: <best-practice><coding-standards><apiv4>
Title: api4: get(FALSE) vs get()->setCheckPermissions(FALSE): which is preferred?
ThreadText: # api4: get(FALSE) vs get()->setCheckPermissions(FALSE): which is preferred?
  
  (Asked by: username_0 on 2020-12-11)
  
  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?
  
  **Tags:** best-practice, coding-standards, apiv4
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-12-11. Score: 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.
  
  > **Comments:**
  > **username_2**: The shorthand version has been available since [5.29.0](https://lab.civicrm.org/dev/core/-/commit/6764a9d37254c69efd9133ddb1e9a315bbff1d76). I started using it lots and got continually frustrated by errors when I ran my code on pre 5.29 sites!  
  
  ---
  
  