Use-Case: You create a dynamic FK with a reference to an invalid table.
Before: Returns an API error/exception about type-matching (string vs null)
After: Returns an API error/exception about the invalid reference
}
if ($eid && $table) {
$targetEntity = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($table));
+ if ($targetEntity === NULL) {
+ throw new \API_Exception(sprintf('Cannot resolve permissions for dynamic foreign key in "%s". Invalid table reference "%s".',
+ static::getTableName(), $table));
+ }
return \Civi\Api4\Utils\CoreUtil::checkAccessDelegated($targetEntity, 'update', ['id' => $eid], $userID);
}
return TRUE;