Skip to content

Commit

Permalink
ActionObjectProvider - suppress mismatched entity error
Browse files Browse the repository at this point in the history
  • Loading branch information
ufundo committed Oct 18, 2024
1 parent 009c20f commit 228a90f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Civi/Api4/Provider/ActionObjectProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,22 @@ public function onApiResolve(ResolveEvent $event) {
if ($apiRequest instanceof AbstractAction) {
$entityName = $apiRequest->getEntityName();
if (!isset($this->getEntities()[$entityName])) {
throw new \CRM_Core_Exception("Unrecognised entity in Api4 ActionObjectProvider: $entityName");
// this certainly seems bad - we're taking an action on an entity that doesn't currently exist
//
// however some existing behaviours seem to rely on this being possible
// @see https://lab.civicrm.org/dev/core/-/issues/5533
//
// maybe this is reasonable for some kinds of AbstractAction that happen to live
// on an entity, but the entity isn't really doing anything (like a static method)?
//
// for something like DAOEntities, it will definitely fail later when it realises
// the entity doesnt exist - and give a more cryptic error message
//
// unfortunately because the entity doesn't exist we can't check what kind of entity
// for now let's just log that something weird is happening
//
// throw new \CRM_Core_Exception("Unrecognised entity in Api4 ActionObjectProvider: $entityName");
Civi::log()->debug("Unrecognised entity in Api4 ActionObjectProvider: $entityName");
}
$event->setApiRequest($apiRequest);
$event->setApiProvider($this);
Expand Down

0 comments on commit 228a90f

Please sign in to comment.