Partially rollback changes to `$userID`. Merely lay groundwork for future update.
authorTim Otten <totten@civicrm.org>
Wed, 9 Jun 2021 02:46:17 +0000 (19:46 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 9 Jun 2021 03:29:41 +0000 (20:29 -0700)
commit70da392777d9c663ea79755b43cfec2e347b5f04
treee8a38738d0e28e6dcbed2ae49d8d3ccbeec9d80f
parentaf4cccf728aaf85d323397fe43ee5c4ae2ec499f
Partially rollback changes to `$userID`. Merely lay groundwork for future update.

Context: AuthorizeEvent did not allow tracking userID.  AuthorizeRecordEvent
is spec'd to track userID.  This is a step toward supporting checks when the
target user is non-present (ie not the user in the browser/session).
However, this step is not *sufficient* - additional work is also needed to
support non-present users.

Original: AuthorizeEvent and AbstractAction::isAuthorized did not report
current userID.  However, the wiring for AuthorizeRecordEvent is spec'd
to allow userID.

Previous: Made a breaking change in the signature of
AuthorizeEvent/AbstractAction::isAuthorized() to report userID.  However,
even with the break, it's not clear if this is the best approach.

Revised:
* Both AuthorizeEvent and AuthorizeRecordEvent report `userID`. This allows consumers to start using
  this information -- laying the groundwork for future changes.
* If an existing event-consumer ignores the `userID`, it will still work as correctly as before. This is
  because we guarantee that the userID matches the session-user.
* The signature of `AbstractAction::isAuthorized()` matches its original. No BC break. However, the method
  is flagged `@internal` to warn about the prospect of future changes.
* In the future, after we do more legwork on to ensure that the overall
  system makes sense, we may flip this and start doing non-present users.
18 files changed:
CRM/Contact/AccessTrait.php
CRM/Core/BAO/CustomValue.php
CRM/Core/DynamicFKAccessTrait.php
Civi/API/Event/AuthorizeEvent.php
Civi/API/Kernel.php
Civi/Api4/Event/ActiveUserTrait.php [new file with mode: 0644]
Civi/Api4/Event/AuthorizeRecordEvent.php
Civi/Api4/Generic/AbstractAction.php
Civi/Api4/Generic/AbstractCreateAction.php
Civi/Api4/Generic/AbstractSaveAction.php
Civi/Api4/Generic/BasicBatchAction.php
Civi/Api4/Generic/BasicUpdateAction.php
Civi/Api4/Generic/CheckAccessAction.php
Civi/Api4/Generic/DAODeleteAction.php
Civi/Api4/Generic/DAOUpdateAction.php
Civi/Api4/Utils/CoreUtil.php
api/v3/Contribution.php
ext/oauth-client/Civi/Api4/Action/OAuthContactToken/OnlyModifyOwnTokensTrait.php