From: Coleman Watts Date: Thu, 15 Sep 2022 23:17:39 +0000 (-0400) Subject: Replace CRM_Core_Exception aliases - Civi dir X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6ef03256261c60a017a4feb23d95446771802037;p=civicrm-core.git Replace CRM_Core_Exception aliases - Civi dir --- diff --git a/Civi/API/Api3SelectQuery.php b/Civi/API/Api3SelectQuery.php index 3bd6708ffa..366223290e 100644 --- a/Civi/API/Api3SelectQuery.php +++ b/Civi/API/Api3SelectQuery.php @@ -111,7 +111,7 @@ class Api3SelectQuery extends SelectQuery { $orClause = []; foreach ($orGroup as $key) { if (!isset($filters[$key])) { - throw new \CiviCRM_API3_Exception("'$key' specified in OR group but not added to params"); + throw new \CRM_Core_Exception("'$key' specified in OR group but not added to params"); } $orClause[] = $filters[$key]; unset($filters[$key]); diff --git a/Civi/API/Provider/ProviderInterface.php b/Civi/API/Provider/ProviderInterface.php index b449338e61..b7830da936 100644 --- a/Civi/API/Provider/ProviderInterface.php +++ b/Civi/API/Provider/ProviderInterface.php @@ -22,7 +22,7 @@ interface ProviderInterface { * @return array * structured response data (per civicrm_api3_create_success) * @see civicrm_api3_create_success - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function invoke($apiRequest); diff --git a/Civi/API/Provider/ReflectionProvider.php b/Civi/API/Provider/ReflectionProvider.php index ac432b8fa3..bc70e301fe 100644 --- a/Civi/API/Provider/ReflectionProvider.php +++ b/Civi/API/Provider/ReflectionProvider.php @@ -97,7 +97,7 @@ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface * @inheritDoc * @param array $apiRequest * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function invoke($apiRequest) { if (strtolower($apiRequest['entity']) == 'entity' && $apiRequest['action'] == 'get') { @@ -114,7 +114,7 @@ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface } // We shouldn't get here because onApiResolve() checks $this->actions - throw new \API_Exception("Unsupported action (" . $apiRequest['entity'] . '.' . $apiRequest['action'] . ']'); + throw new \CRM_Core_Exception("Unsupported action (" . $apiRequest['entity'] . '.' . $apiRequest['action'] . ']'); } /** diff --git a/Civi/API/Provider/StaticProvider.php b/Civi/API/Provider/StaticProvider.php index 138d561b1f..8ba360430d 100644 --- a/Civi/API/Provider/StaticProvider.php +++ b/Civi/API/Provider/StaticProvider.php @@ -87,7 +87,7 @@ class StaticProvider extends AdhocProvider { * The full description of the API request. * @return array * Formatted API result - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function doCreate($apiRequest) { if (isset($apiRequest['params']['id'])) { @@ -99,7 +99,7 @@ class StaticProvider extends AdhocProvider { } if (!isset($this->records[$id])) { - throw new \API_Exception("Invalid ID: $id"); + throw new \CRM_Core_Exception("Invalid ID: $id"); } foreach ($this->fields as $field) { @@ -116,7 +116,7 @@ class StaticProvider extends AdhocProvider { * The full description of the API request. * @return array * Formatted API result - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function doGet($apiRequest) { return _civicrm_api3_basic_array_get($apiRequest['entity'], $apiRequest['params'], $this->records, 'id', $this->fields); @@ -127,7 +127,7 @@ class StaticProvider extends AdhocProvider { * The full description of the API request. * @return array * Formatted API result - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function doDelete($apiRequest) { $id = @$apiRequest['params']['id']; diff --git a/Civi/API/Provider/WrappingProvider.php b/Civi/API/Provider/WrappingProvider.php index 4e39eb4e74..daa4c91c1e 100644 --- a/Civi/API/Provider/WrappingProvider.php +++ b/Civi/API/Provider/WrappingProvider.php @@ -50,12 +50,12 @@ class WrappingProvider implements ProviderInterface { public function getEntityNames($version) { // return $version == $this->version ? [$this->entity] : []; - throw new \API_Exception("Not support: WrappingProvider::getEntityNames()"); + throw new \CRM_Core_Exception("Not support: WrappingProvider::getEntityNames()"); } public function getActionNames($version, $entity) { // return $version == $this->version && $this->entity == $entity ? [$this->action] : []; - throw new \API_Exception("Not support: WrappingProvider::getActionNames()"); + throw new \CRM_Core_Exception("Not support: WrappingProvider::getActionNames()"); } } diff --git a/Civi/API/SelectQuery.php b/Civi/API/SelectQuery.php index 76ae48e064..f22742e844 100644 --- a/Civi/API/SelectQuery.php +++ b/Civi/API/SelectQuery.php @@ -105,7 +105,6 @@ abstract class SelectQuery { * Build & execute the query and return results array * * @return array|int - * @throws \API_Exception * @throws \CRM_Core_Exception * @throws \Exception */ @@ -178,7 +177,7 @@ abstract class SelectQuery { * * @return array|null * Returns the table and field name for adding this field to a SELECT or WHERE clause - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ protected function addFkField($fkFieldName, $side) { @@ -392,7 +391,7 @@ abstract class SelectQuery { /** * Orders the query by one or more fields * - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ protected function buildOrderBy() { @@ -417,7 +416,7 @@ abstract class SelectQuery { } } else { - throw new \API_Exception("Unknown field specified for sort. Cannot order by '$item'"); + throw new \CRM_Core_Exception("Unknown field specified for sort. Cannot order by '$item'"); } } } diff --git a/Civi/API/Subscriber/APIv3SchemaAdapter.php b/Civi/API/Subscriber/APIv3SchemaAdapter.php index fa15949348..ccafbc33fa 100644 --- a/Civi/API/Subscriber/APIv3SchemaAdapter.php +++ b/Civi/API/Subscriber/APIv3SchemaAdapter.php @@ -36,7 +36,7 @@ class APIv3SchemaAdapter implements EventSubscriberInterface { * @param \Civi\API\Event\PrepareEvent $event * API preparation event. * - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function onApiPrepare(\Civi\API\Event\PrepareEvent $event) { $apiRequest = $event->getApiRequest(); diff --git a/Civi/API/Subscriber/DynamicFKAuthorization.php b/Civi/API/Subscriber/DynamicFKAuthorization.php index ec5a50ac13..e84bbb901d 100644 --- a/Civi/API/Subscriber/DynamicFKAuthorization.php +++ b/Civi/API/Subscriber/DynamicFKAuthorization.php @@ -134,7 +134,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface { /** * @param \Civi\API\Event\AuthorizeEvent $event * API authorization event. - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ public function onApiAuthorize(\Civi\API\Event\AuthorizeEvent $event) { @@ -152,7 +152,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface { if (/*!$isTrusted */ empty($apiRequest['params']['id']) && empty($apiRequest['params']['entity_table']) ) { - throw new \API_Exception("Mandatory key(s) missing from params array: 'id' or 'entity_table'"); + throw new \CRM_Core_Exception("Mandatory key(s) missing from params array: 'id' or 'entity_table'"); } if (isset($apiRequest['params']['id'])) { @@ -163,7 +163,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface { return; } elseif ($isValidId) { - throw new \API_Exception("Failed to match record to related entity"); + throw new \CRM_Core_Exception("Failed to match record to related entity"); } elseif (!$isValidId && strtolower($apiRequest['action']) == 'get') { // The matches will be an empty set; doesn't make a difference if we @@ -183,7 +183,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface { return; } - throw new \API_Exception("Failed to run permission check"); + throw new \CRM_Core_Exception("Failed to run permission check"); } } @@ -197,7 +197,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface { * @param array $apiRequest * The full API request. * @throws \Exception - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ public function authorizeDelegate($action, $entityTable, $entityId, $apiRequest) { @@ -207,7 +207,7 @@ class DynamicFKAuthorization implements EventSubscriberInterface { $entity = $this->getDelegatedEntityName($entityTable); if (!$entity) { - throw new \API_Exception("Failed to run permission check: Unrecognized target entity table ($entityTable)"); + throw new \CRM_Core_Exception("Failed to run permission check: Unrecognized target entity table ($entityTable)"); } if (!$entityId) { throw new \Civi\API\Exception\UnauthorizedException("Authorization failed on ($entity): Missing entity_id"); @@ -253,16 +253,16 @@ class DynamicFKAuthorization implements EventSubscriberInterface { * The saved FK. * @param array $apiRequest * The full API request. - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function preventReassignment($fileId, $entityTable, $entityId, $apiRequest) { if (strtolower($apiRequest['action']) == 'create' && $fileId && !$this->isTrusted($apiRequest)) { // TODO: no change in field_name? if (isset($apiRequest['params']['entity_table']) && $entityTable != $apiRequest['params']['entity_table']) { - throw new \API_Exception("Cannot modify entity_table"); + throw new \CRM_Core_Exception("Cannot modify entity_table"); } if (isset($apiRequest['params']['entity_id']) && $entityId != $apiRequest['params']['entity_id']) { - throw new \API_Exception("Cannot modify entity_id"); + throw new \CRM_Core_Exception("Cannot modify entity_id"); } } } diff --git a/Civi/API/Subscriber/I18nSubscriber.php b/Civi/API/Subscriber/I18nSubscriber.php index 5cff107300..89be3aeaf6 100644 --- a/Civi/API/Subscriber/I18nSubscriber.php +++ b/Civi/API/Subscriber/I18nSubscriber.php @@ -45,7 +45,7 @@ class I18nSubscriber implements EventSubscriberInterface { * @param \Civi\API\Event\Event $event * API preparation event. * - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function onApiPrepare(\Civi\API\Event\Event $event) { $apiRequest = $event->getApiRequest(); @@ -71,7 +71,7 @@ class I18nSubscriber implements EventSubscriberInterface { * * @param \Civi\API\Event\Event $event * - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function onApiRespond(\Civi\API\Event\Event $event) { $apiRequest = $event->getApiRequest(); diff --git a/Civi/API/WhitelistRule.php b/Civi/API/WhitelistRule.php index 5150b362f8..25d5e4f3c3 100644 --- a/Civi/API/WhitelistRule.php +++ b/Civi/API/WhitelistRule.php @@ -220,7 +220,7 @@ class WhitelistRule { * API result. * @return array * Modified API result. - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function filter($apiRequest, $apiResult) { if ($this->fields === '*') { @@ -238,7 +238,7 @@ class WhitelistRule { return $apiResult; } } - throw new \API_Exception(sprintf('Filtering failed for %s.%s. Unrecognized result format.', $apiRequest['entity'], $apiRequest['action'])); + throw new \CRM_Core_Exception(sprintf('Filtering failed for %s.%s. Unrecognized result format.', $apiRequest['entity'], $apiRequest['action'])); } /** diff --git a/Civi/Api4/Action/Address/GetCoordinates.php b/Civi/Api4/Action/Address/GetCoordinates.php index bf9ad89c40..33d1487ca7 100644 --- a/Civi/Api4/Action/Address/GetCoordinates.php +++ b/Civi/Api4/Action/Address/GetCoordinates.php @@ -34,14 +34,14 @@ class GetCoordinates extends \Civi\Api4\Generic\AbstractAction { $geocodingClassName = \CRM_Utils_GeocodeProvider::getUsableClassName(); $geocodingProvider = \CRM_Utils_GeocodeProvider::getConfiguredProvider(); if (!is_callable([$geocodingProvider, 'getCoordinates'])) { - throw new \API_Exception('Geocoding provider does not support getCoordinates'); + throw new \CRM_Core_Exception('Geocoding provider does not support getCoordinates'); } $coord = $geocodingClassName::getCoordinates($this->address); if (isset($coord['geo_code_1'], $coord['geo_code_2'])) { $result[] = $coord; } elseif (!empty($coord['geo_code_error'])) { - throw new \API_Exception('Geocoding failed. ' . $coord['geo_code_error']); + throw new \CRM_Core_Exception('Geocoding failed. ' . $coord['geo_code_error']); } } diff --git a/Civi/Api4/Action/Contact/Delete.php b/Civi/Api4/Action/Contact/Delete.php index 2bc03ba4c1..9c739ec409 100644 --- a/Civi/Api4/Action/Contact/Delete.php +++ b/Civi/Api4/Action/Contact/Delete.php @@ -22,12 +22,12 @@ class Delete extends \Civi\Api4\Generic\DAODeleteAction { /** * @param $items * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function deleteObjects($items) { foreach ($items as $item) { if (!\CRM_Contact_BAO_Contact::deleteContact($item['id'], FALSE, !$this->useTrash, $this->checkPermissions)) { - throw new \API_Exception("Could not delete {$this->getEntityName()} id {$item['id']}"); + throw new \CRM_Core_Exception("Could not delete {$this->getEntityName()} id {$item['id']}"); } $ids[] = ['id' => $item['id']]; } diff --git a/Civi/Api4/Action/Contact/GetDuplicates.php b/Civi/Api4/Action/Contact/GetDuplicates.php index a45cf1ab53..2986869de2 100644 --- a/Civi/Api4/Action/Contact/GetDuplicates.php +++ b/Civi/Api4/Action/Contact/GetDuplicates.php @@ -66,7 +66,7 @@ class GetDuplicates extends \Civi\Api4\Generic\DAOCreateAction { if (strpos($this->dedupeRule, '.Unsupervised') || strpos($this->dedupeRule, '.Supervised')) { [$contactType, $ruleType] = explode('.', $this->dedupeRule); if (!empty($item['contact_type']) && $contactType !== $item['contact_type']) { - throw new \API_Exception('Mismatched contact type.'); + throw new \CRM_Core_Exception('Mismatched contact type.'); } $item['contact_type'] = $contactType; $dedupeParams['rule'] = $ruleType; @@ -77,7 +77,7 @@ class GetDuplicates extends \Civi\Api4\Generic\DAOCreateAction { ->addSelect('id', 'contact_type') ->execute()->single(); if (!empty($item['contact_type']) && $ruleGroup['contact_type'] !== $item['contact_type']) { - throw new \API_Exception('Mismatched contact type.'); + throw new \CRM_Core_Exception('Mismatched contact type.'); } $item['contact_type'] = $ruleGroup['contact_type']; $dedupeParams['rule_group_id'] = $ruleGroup['id']; @@ -116,7 +116,7 @@ class GetDuplicates extends \Civi\Api4\Generic\DAOCreateAction { * * @param array $entityValues * @param array $dedupeParams - * @throws \API_Exception + * @throws \CRM_Core_Exception */ private function transformCustomParams(array &$entityValues, array &$dedupeParams) { foreach ($entityValues as $name => $value) { diff --git a/Civi/Api4/Action/Queue/ClaimItems.php b/Civi/Api4/Action/Queue/ClaimItems.php index 8d05495060..2855c02f2c 100644 --- a/Civi/Api4/Action/Queue/ClaimItems.php +++ b/Civi/Api4/Action/Queue/ClaimItems.php @@ -41,7 +41,7 @@ class ClaimItems extends \Civi\Api4\Generic\AbstractAction { $isBatch = $queue instanceof \CRM_Queue_Queue_BatchQueueInterface; $limit = $queue->getSpec('batch_limit') ?: 1; if ($limit > 1 && !$isBatch) { - throw new \API_Exception(sprintf('Queue "%s" (%s) does not support batching.', $queue->getName(), get_class($queue))); + throw new \CRM_Core_Exception(sprintf('Queue "%s" (%s) does not support batching.', $queue->getName(), get_class($queue))); // Note 1: Simply looping over `claimItem()` is unlikley to help the consumer b/c // drivers like Sql+Memory are linear+blocking. // Note 2: The default is batch_limit=1. So someone has specifically chosen an invalid configuration... @@ -82,7 +82,7 @@ class ClaimItems extends \Civi\Api4\Generic\AbstractAction { protected function queue(): \CRM_Queue_Queue { if (empty($this->queue)) { - throw new \API_Exception('Missing required parameter: $queue'); + throw new \CRM_Core_Exception('Missing required parameter: $queue'); } return \Civi::queue($this->queue); } diff --git a/Civi/Api4/Action/Queue/RunItems.php b/Civi/Api4/Action/Queue/RunItems.php index 52a2503239..d711062e6c 100644 --- a/Civi/Api4/Action/Queue/RunItems.php +++ b/Civi/Api4/Action/Queue/RunItems.php @@ -58,7 +58,7 @@ class RunItems extends \Civi\Api4\Generic\AbstractAction { $queue = \Civi::queue($this->items[0]['queue']); $ids = \CRM_Utils_Array::collect('id', $this->items); if (count($ids) > 1 && !($queue instanceof \CRM_Queue_Queue_BatchQueueInterface)) { - throw new \API_Exception("runItems: Error: Running multiple items requires BatchQueueInterface"); + throw new \CRM_Core_Exception("runItems: Error: Running multiple items requires BatchQueueInterface"); } if (count($ids) > 1) { $items = $queue->fetchItems($ids); @@ -77,7 +77,7 @@ class RunItems extends \Civi\Api4\Generic\AbstractAction { : [$queue->claimItem()]; } else { - throw new \API_Exception("runItems: Requires either 'queue' or 'item'."); + throw new \CRM_Core_Exception("runItems: Requires either 'queue' or 'item'."); } if (empty($items)) { @@ -87,7 +87,7 @@ class RunItems extends \Civi\Api4\Generic\AbstractAction { $outcomes = []; \CRM_Utils_Hook::queueRun($queue, $items, $outcomes); if (empty($outcomes)) { - throw new \API_Exception(sprintf('Failed to run queue items (name=%s, runner=%s, itemCount=%d, outcomeCount=%d)', + throw new \CRM_Core_Exception(sprintf('Failed to run queue items (name=%s, runner=%s, itemCount=%d, outcomeCount=%d)', $queue->getName(), $queue->getSpec('runner'), count($items), count($outcomes))); } foreach ($items as $itemPos => $item) { @@ -102,19 +102,19 @@ class RunItems extends \Civi\Api4\Generic\AbstractAction { private function validateItemStubs(): void { $queueNames = []; if (!isset($this->items[0])) { - throw new \API_Exception("Queue items must be given as numeric array."); + throw new \CRM_Core_Exception("Queue items must be given as numeric array."); } foreach ($this->items as $item) { if (empty($item['queue'])) { - throw new \API_Exception("Queue item requires property 'queue'."); + throw new \CRM_Core_Exception("Queue item requires property 'queue'."); } if (empty($item['id'])) { - throw new \API_Exception("Queue item requires property 'id'."); + throw new \CRM_Core_Exception("Queue item requires property 'id'."); } $queueNames[$item['queue']] = 1; } if (count($queueNames) > 1) { - throw new \API_Exception("Queue items cannot be mixed. Found queues: " . implode(', ', array_keys($queueNames))); + throw new \CRM_Core_Exception("Queue items cannot be mixed. Found queues: " . implode(', ', array_keys($queueNames))); } } diff --git a/Civi/Api4/Action/Setting/AbstractSettingAction.php b/Civi/Api4/Action/Setting/AbstractSettingAction.php index 3f362dc404..0f12663344 100644 --- a/Civi/Api4/Action/Setting/AbstractSettingAction.php +++ b/Civi/Api4/Action/Setting/AbstractSettingAction.php @@ -54,7 +54,7 @@ abstract class AbstractSettingAction extends \Civi\Api4\Generic\AbstractAction { * * @param int $domain * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function validateSettings($domain) { $meta = \Civi\Core\SettingsMetadata::getMetadata([], $domain); @@ -63,7 +63,7 @@ abstract class AbstractSettingAction extends \Civi\Api4\Generic\AbstractAction { }, isset($this->values) ? array_keys($this->values) : $this->select); $invalid = array_diff($names, array_keys($meta)); if ($invalid) { - throw new \API_Exception("Unknown settings for domain $domain: " . implode(', ', $invalid)); + throw new \CRM_Core_Exception("Unknown settings for domain $domain: " . implode(', ', $invalid)); } if (isset($this->values)) { foreach ($this->values as $name => $value) { @@ -90,7 +90,7 @@ abstract class AbstractSettingAction extends \Civi\Api4\Generic\AbstractAction { $domains = Domain::get(FALSE)->addSelect('id')->execute()->column('id'); $invalid = array_diff($this->domainId, $domains); if ($invalid) { - throw new \API_Exception('Invalid domain id: ' . implode(', ', $invalid)); + throw new \CRM_Core_Exception('Invalid domain id: ' . implode(', ', $invalid)); } } else { diff --git a/Civi/Api4/Action/System/RotateKey.php b/Civi/Api4/Action/System/RotateKey.php index 7afc9b204e..4f729aa5e3 100644 --- a/Civi/Api4/Action/System/RotateKey.php +++ b/Civi/Api4/Action/System/RotateKey.php @@ -37,12 +37,12 @@ class RotateKey extends AbstractAction { /** * @param \Civi\Api4\Generic\Result $result * - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\Crypto\Exception\CryptoException */ public function _run(Result $result) { if (empty($this->tag)) { - throw new \API_Exception("Missing required argument: tag"); + throw new \CRM_Core_Exception("Missing required argument: tag"); } // Track log of changes in memory. diff --git a/Civi/Api4/CustomValue.php b/Civi/Api4/CustomValue.php index a4a7d935a8..722d6713dd 100644 --- a/Civi/Api4/CustomValue.php +++ b/Civi/Api4/CustomValue.php @@ -30,7 +30,7 @@ class CustomValue { * @param string $customGroup * @param bool $checkPermissions * @return Action\CustomValue\Get - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function get($customGroup, $checkPermissions = TRUE) { return (new Action\CustomValue\Get($customGroup, __FUNCTION__)) @@ -41,7 +41,7 @@ class CustomValue { * @param string $customGroup * @param bool $checkPermissions * @return Action\CustomValue\GetFields - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function getFields($customGroup = NULL, $checkPermissions = TRUE) { return (new Action\CustomValue\GetFields($customGroup, __FUNCTION__)) @@ -52,7 +52,7 @@ class CustomValue { * @param string $customGroup * @param bool $checkPermissions * @return Action\CustomValue\Save - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function save($customGroup, $checkPermissions = TRUE) { return (new Action\CustomValue\Save($customGroup, __FUNCTION__)) @@ -63,7 +63,7 @@ class CustomValue { * @param string $customGroup * @param bool $checkPermissions * @return Action\CustomValue\Create - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function create($customGroup, $checkPermissions = TRUE) { return (new Action\CustomValue\Create($customGroup, __FUNCTION__)) @@ -74,7 +74,7 @@ class CustomValue { * @param string $customGroup * @param bool $checkPermissions * @return Action\CustomValue\Update - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function update($customGroup, $checkPermissions = TRUE) { return (new Action\CustomValue\Update($customGroup, __FUNCTION__)) @@ -85,7 +85,7 @@ class CustomValue { * @param string $customGroup * @param bool $checkPermissions * @return Action\CustomValue\Delete - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function delete($customGroup, $checkPermissions = TRUE) { return (new Action\CustomValue\Delete($customGroup, __FUNCTION__)) @@ -96,7 +96,7 @@ class CustomValue { * @param string $customGroup * @param bool $checkPermissions * @return Generic\BasicReplaceAction - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function replace($customGroup, $checkPermissions = TRUE) { return (new Generic\BasicReplaceAction("Custom_$customGroup", __FUNCTION__)) @@ -107,7 +107,7 @@ class CustomValue { * @param string $customGroup * @param bool $checkPermissions * @return Action\GetActions - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function getActions($customGroup = NULL, $checkPermissions = TRUE) { return (new Action\GetActions("Custom_$customGroup", __FUNCTION__)) diff --git a/Civi/Api4/Event/Subscriber/ValidateFieldsSubscriber.php b/Civi/Api4/Event/Subscriber/ValidateFieldsSubscriber.php index 65b7cc1bdf..b2679c1196 100644 --- a/Civi/Api4/Event/Subscriber/ValidateFieldsSubscriber.php +++ b/Civi/Api4/Event/Subscriber/ValidateFieldsSubscriber.php @@ -32,10 +32,10 @@ class ValidateFieldsSubscriber extends Generic\AbstractPrepareSubscriber { $value = $apiRequest->$getParam(); // Required fields if (!empty($info['required']) && (!$value && $value !== 0 && $value !== '0')) { - throw new \API_Exception('Parameter "' . $param . '" is required.'); + throw new \CRM_Core_Exception('Parameter "' . $param . '" is required.'); } if (!empty($info['type']) && !self::checkType($value, $info['type'])) { - throw new \API_Exception('Parameter "' . $param . '" is not of the correct type. Expecting ' . implode(' or ', $info['type']) . '.'); + throw new \CRM_Core_Exception('Parameter "' . $param . '" is not of the correct type. Expecting ' . implode(' or ', $info['type']) . '.'); } if (!empty($info['deprecated']) && isset($value)) { \CRM_Core_Error::deprecatedWarning('APIv4 ' . $apiRequest->getEntityName() . ".$param parameter is deprecated."); @@ -50,7 +50,7 @@ class ValidateFieldsSubscriber extends Generic\AbstractPrepareSubscriber { * @param $value * @param $types * @return bool - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function checkType($value, $types) { if ($value === NULL) { @@ -78,7 +78,7 @@ class ValidateFieldsSubscriber extends Generic\AbstractPrepareSubscriber { return TRUE; default: - throw new \API_Exception('Unknown parameter type: ' . $type); + throw new \CRM_Core_Exception('Unknown parameter type: ' . $type); } } return FALSE; diff --git a/Civi/Api4/Event/ValidateValuesEvent.php b/Civi/Api4/Event/ValidateValuesEvent.php index 20b3c7de13..6c43855874 100644 --- a/Civi/Api4/Event/ValidateValuesEvent.php +++ b/Civi/Api4/Event/ValidateValuesEvent.php @@ -140,11 +140,11 @@ class ValidateValuesEvent extends GenericHookEvent { /** * Convert the list of errors an exception. * - * @return \API_Exception + * @return \CRM_Core_Exception */ public function toException() { // We should probably have a better way to report the errors in a structured/list format. - return new \API_Exception(ts('Found %1 error(s) in submitted %2 record(s) of type "%3": %4', [ + return new \CRM_Core_Exception(ts('Found %1 error(s) in submitted %2 record(s) of type "%3": %4', [ 1 => count($this->errors), 2 => count(array_unique(array_column($this->errors, 'record'))), 3 => $this->getEntityName(), diff --git a/Civi/Api4/Generic/AbstractAction.php b/Civi/Api4/Generic/AbstractAction.php index 5ad1a3e458..b20c7d9fcb 100644 --- a/Civi/Api4/Generic/AbstractAction.php +++ b/Civi/Api4/Generic/AbstractAction.php @@ -151,7 +151,7 @@ abstract class AbstractAction implements \ArrayAccess { * * @param string $entityName * @param string $actionName - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function __construct($entityName, $actionName) { // If a namespaced class name is passed in @@ -170,17 +170,17 @@ abstract class AbstractAction implements \ArrayAccess { * @throws \Exception */ public function __set($name, $value) { - throw new \API_Exception('Unknown api parameter'); + throw new \CRM_Core_Exception('Unknown api parameter'); } /** * @param int $val * @return $this - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function setVersion($val) { if ($val !== 4 && $val !== '4') { - throw new \API_Exception('Cannot modify api version'); + throw new \CRM_Core_Exception('Cannot modify api version'); } return $this; } @@ -213,12 +213,12 @@ abstract class AbstractAction implements \ArrayAccess { * @param $name * @param $arguments * @return static|mixed - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function __call($name, $arguments) { $param = lcfirst(substr($name, 3)); if (!$param || $param[0] == '_') { - throw new \API_Exception('Unknown api parameter: ' . $name); + throw new \CRM_Core_Exception('Unknown api parameter: ' . $name); } $mode = substr($name, 0, 3); if ($this->paramExists($param)) { @@ -231,7 +231,7 @@ abstract class AbstractAction implements \ArrayAccess { return $this; } } - throw new \API_Exception('Unknown api parameter: ' . $name); + throw new \CRM_Core_Exception('Unknown api parameter: ' . $name); } /** @@ -241,7 +241,7 @@ abstract class AbstractAction implements \ArrayAccess { * This is basically the outer wrapper for api v4. * * @return \Civi\Api4\Generic\Result - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ public function execute() { @@ -378,7 +378,7 @@ abstract class AbstractAction implements \ArrayAccess { */ public function offsetSet($offset, $value): void { if (in_array($offset, ['entity', 'action', 'entityName', 'actionName', 'params', 'version', 'id'])) { - throw new \API_Exception('Cannot modify api4 state via array access'); + throw new \CRM_Core_Exception('Cannot modify api4 state via array access'); } if ($offset == 'check_permissions') { $this->setCheckPermissions($value); @@ -393,7 +393,7 @@ abstract class AbstractAction implements \ArrayAccess { */ public function offsetUnset($offset): void { if (in_array($offset, ['entity', 'action', 'entityName', 'actionName', 'params', 'check_permissions', 'version', 'id'])) { - throw new \API_Exception('Cannot modify api4 state via array access'); + throw new \CRM_Core_Exception('Cannot modify api4 state via array access'); } unset($this->_arrayStorage[$offset]); } @@ -441,7 +441,7 @@ abstract class AbstractAction implements \ArrayAccess { * This is because we DON'T want the wrapper to check permissions as this is an internal op. * @see \Civi\Api4\Action\Contact\GetFields * - * @throws \API_Exception + * @throws \CRM_Core_Exception * @return array */ public function entityFields() { @@ -476,7 +476,7 @@ abstract class AbstractAction implements \ArrayAccess { * * @param $values * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function checkRequiredFields($values) { $unmatched = []; @@ -499,7 +499,7 @@ abstract class AbstractAction implements \ArrayAccess { * Replaces pseudoconstants in input values * * @param array $record - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function formatWriteValues(&$record) { $optionFields = []; @@ -548,12 +548,12 @@ abstract class AbstractAction implements \ArrayAccess { * @param array $vars * Variable name => value * @return bool - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Exception */ protected function evaluateCondition($expr, $vars) { if (strpos($expr, '}') !== FALSE || strpos($expr, '{') !== FALSE) { - throw new \API_Exception('Illegal character in expression'); + throw new \CRM_Core_Exception('Illegal character in expression'); } $tpl = "{if $expr}1{else}0{/if}"; return (bool) trim(\CRM_Core_Smarty::singleton()->fetchWith('string:' . $tpl, $vars)); diff --git a/Civi/Api4/Generic/AbstractCreateAction.php b/Civi/Api4/Generic/AbstractCreateAction.php index d6b7c6dd8e..c1f88ad9ac 100644 --- a/Civi/Api4/Generic/AbstractCreateAction.php +++ b/Civi/Api4/Generic/AbstractCreateAction.php @@ -53,14 +53,14 @@ abstract class AbstractCreateAction extends AbstractAction { } /** - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ protected function validateValues() { - // FIXME: There should be a protocol to report a full list of errors... Perhaps a subclass of API_Exception? + // FIXME: There should be a protocol to report a full list of errors... Perhaps a subclass of CRM_Core_Exception? $unmatched = $this->checkRequiredFields($this->getValues()); if ($unmatched) { - throw new \API_Exception("Mandatory values missing from Api4 {$this->getEntityName()}::{$this->getActionName()}: " . implode(", ", $unmatched), "mandatory_missing", ["fields" => $unmatched]); + throw new \CRM_Core_Exception("Mandatory values missing from Api4 {$this->getEntityName()}::{$this->getActionName()}: " . implode(", ", $unmatched), "mandatory_missing", ["fields" => $unmatched]); } if ($this->checkPermissions && !CoreUtil::checkAccessRecord($this, $this->getValues(), \CRM_Core_Session::getLoggedInContactID() ?: 0)) { diff --git a/Civi/Api4/Generic/AbstractGetAction.php b/Civi/Api4/Generic/AbstractGetAction.php index 8dfff86d61..41b9c2d818 100644 --- a/Civi/Api4/Generic/AbstractGetAction.php +++ b/Civi/Api4/Generic/AbstractGetAction.php @@ -37,7 +37,7 @@ abstract class AbstractGetAction extends AbstractQueryAction { * Note: it will skip adding field defaults when fetching records by id, * or if that field has already been added to the where clause. * - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function setDefaultWhereClause() { if (!$this->_itemsToGet('id')) { diff --git a/Civi/Api4/Generic/AbstractQueryAction.php b/Civi/Api4/Generic/AbstractQueryAction.php index 308c5dcc27..be6b6664dd 100644 --- a/Civi/Api4/Generic/AbstractQueryAction.php +++ b/Civi/Api4/Generic/AbstractQueryAction.php @@ -78,11 +78,11 @@ abstract class AbstractQueryAction extends AbstractAction { * @param string $op * @param mixed $value * @return $this - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function addWhere(string $fieldName, string $op, $value = NULL) { if (!in_array($op, CoreUtil::getOperators())) { - throw new \API_Exception('Unsupported operator'); + throw new \CRM_Core_Exception('Unsupported operator'); } $this->where[] = [$fieldName, $op, $value]; return $this; @@ -96,7 +96,7 @@ abstract class AbstractQueryAction extends AbstractAction { * Either a nested array of arguments, or a variable number of arguments passed to this function. * * @return $this - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function addClause(string $operator, $condition1) { if (!is_array($condition1[0])) { diff --git a/Civi/Api4/Generic/AbstractSaveAction.php b/Civi/Api4/Generic/AbstractSaveAction.php index 3ab1838035..82fac7e023 100644 --- a/Civi/Api4/Generic/AbstractSaveAction.php +++ b/Civi/Api4/Generic/AbstractSaveAction.php @@ -73,12 +73,12 @@ abstract class AbstractSaveAction extends AbstractAction { protected $reload = FALSE; /** - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ protected function validateValues() { $idField = CoreUtil::getIdFieldName($this->getEntityName()); - // FIXME: There should be a protocol to report a full list of errors... Perhaps a subclass of API_Exception? + // FIXME: There should be a protocol to report a full list of errors... Perhaps a subclass of CRM_Core_Exception? $unmatched = []; foreach ($this->records as $record) { if (empty($record[$idField])) { @@ -86,7 +86,7 @@ abstract class AbstractSaveAction extends AbstractAction { } } if ($unmatched) { - throw new \API_Exception("Mandatory values missing from Api4 {$this->getEntityName()}::{$this->getActionName()}: " . implode(", ", $unmatched), "mandatory_missing", ["fields" => $unmatched]); + throw new \CRM_Core_Exception("Mandatory values missing from Api4 {$this->getEntityName()}::{$this->getActionName()}: " . implode(", ", $unmatched), "mandatory_missing", ["fields" => $unmatched]); } if ($this->checkPermissions) { diff --git a/Civi/Api4/Generic/AbstractUpdateAction.php b/Civi/Api4/Generic/AbstractUpdateAction.php index ba8e3934a8..d4b78a13eb 100644 --- a/Civi/Api4/Generic/AbstractUpdateAction.php +++ b/Civi/Api4/Generic/AbstractUpdateAction.php @@ -79,7 +79,7 @@ abstract class AbstractUpdateAction extends AbstractBatchAction { // Require WHERE if we didn't get primary keys from values if (!$this->where) { - throw new \API_Exception('Parameter "where" is required unless primary keys are supplied in values.'); + throw new \CRM_Core_Exception('Parameter "where" is required unless primary keys are supplied in values.'); } // Update a single record by primary key (if this entity has a single primary key) @@ -129,10 +129,10 @@ abstract class AbstractUpdateAction extends AbstractBatchAction { } /** - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function validateValues() { - // FIXME: There should be a protocol to report a full list of errors... Perhaps a subclass of API_Exception? + // FIXME: There should be a protocol to report a full list of errors... Perhaps a subclass of CRM_Core_Exception? $e = new ValidateValuesEvent($this, [$this->values], new \CRM_Utils_LazyArray(function () { $existing = $this->getBatchAction()->setSelect(['*'])->execute(); $result = []; diff --git a/Civi/Api4/Generic/BasicGetAction.php b/Civi/Api4/Generic/BasicGetAction.php index 8f5ffdc1d7..95639ae36f 100644 --- a/Civi/Api4/Generic/BasicGetAction.php +++ b/Civi/Api4/Generic/BasicGetAction.php @@ -99,7 +99,6 @@ class BasicGetAction extends AbstractGetAction { * Evaluate :pseudoconstant suffix expressions and replace raw values with option values * * @param $records - * @throws \API_Exception * @throws \CRM_Core_Exception */ protected function formatRawValues(&$records) { diff --git a/Civi/Api4/Generic/BasicUpdateAction.php b/Civi/Api4/Generic/BasicUpdateAction.php index 5fefc107f4..2667bebfb8 100644 --- a/Civi/Api4/Generic/BasicUpdateAction.php +++ b/Civi/Api4/Generic/BasicUpdateAction.php @@ -49,7 +49,7 @@ class BasicUpdateAction extends AbstractUpdateAction { /** * @param array $items * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function updateRecords(array $items): array { return array_map([$this, 'writeRecord'], $items); diff --git a/Civi/Api4/Generic/DAOCreateAction.php b/Civi/Api4/Generic/DAOCreateAction.php index b40a67d448..21170f7e51 100644 --- a/Civi/Api4/Generic/DAOCreateAction.php +++ b/Civi/Api4/Generic/DAOCreateAction.php @@ -36,12 +36,12 @@ class DAOCreateAction extends AbstractCreateAction { } /** - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function validateValues() { $idField = CoreUtil::getIdFieldName($this->getEntityName()); if (!empty($this->values[$idField])) { - throw new \API_Exception("Cannot pass $idField to Create action. Use Update action instead."); + throw new \CRM_Core_Exception("Cannot pass $idField to Create action. Use Update action instead."); } parent::validateValues(); } diff --git a/Civi/Api4/Generic/DAODeleteAction.php b/Civi/Api4/Generic/DAODeleteAction.php index cd7a32fc1d..daf3317672 100644 --- a/Civi/Api4/Generic/DAODeleteAction.php +++ b/Civi/Api4/Generic/DAODeleteAction.php @@ -30,7 +30,7 @@ class DAODeleteAction extends AbstractBatchAction { public function _run(Result $result) { $defaults = $this->getParamDefaults(); if ($defaults['where'] && $this->where === $defaults['where']) { - throw new \API_Exception('Cannot delete ' . $this->getEntityName() . ' with no "where" parameter specified'); + throw new \CRM_Core_Exception('Cannot delete ' . $this->getEntityName() . ' with no "where" parameter specified'); } $items = $this->getBatchRecords(); @@ -53,7 +53,7 @@ class DAODeleteAction extends AbstractBatchAction { /** * @param $items * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function deleteObjects($items) { $idField = CoreUtil::getIdFieldName($this->getEntityName()); @@ -69,7 +69,7 @@ class DAODeleteAction extends AbstractBatchAction { $result[] = [$idField => $item[$idField]]; } else { - throw new \API_Exception("Could not delete {$this->getEntityName()} $idField {$item[$idField]}"); + throw new \CRM_Core_Exception("Could not delete {$this->getEntityName()} $idField {$item[$idField]}"); } } } diff --git a/Civi/Api4/Generic/DAOGetAction.php b/Civi/Api4/Generic/DAOGetAction.php index 3d6c8753e8..0e85f84d7b 100644 --- a/Civi/Api4/Generic/DAOGetAction.php +++ b/Civi/Api4/Generic/DAOGetAction.php @@ -92,7 +92,6 @@ class DAOGetAction extends AbstractGetAction { protected $translationMode; /** - * @throws \API_Exception * @throws \CRM_Core_Exception */ public function _run(Result $result) { @@ -100,7 +99,7 @@ class DAOGetAction extends AbstractGetAction { $baoName = $this->getBaoName(); if (!$baoName) { // In some cases (eg. site spin-up) the code may attempt to call the api before the entity name is registered. - throw new \API_Exception("BAO for {$this->getEntityName()} is not available. This could be a load-order issue"); + throw new \CRM_Core_Exception("BAO for {$this->getEntityName()} is not available. This could be a load-order issue"); } if (!$baoName::tableHasBeenAdded()) { \Civi::log()->warning("Could not read from {$this->getEntityName()} before table has been added. Upgrade required.", ['civi.tag' => 'upgrade_needed']); @@ -151,11 +150,11 @@ class DAOGetAction extends AbstractGetAction { * @param mixed $value * @param bool $isExpression * @return $this - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function addWhere(string $fieldName, string $op, $value = NULL, bool $isExpression = FALSE) { if (!in_array($op, CoreUtil::getOperators())) { - throw new \API_Exception('Unsupported operator'); + throw new \CRM_Core_Exception('Unsupported operator'); } $this->where[] = [$fieldName, $op, $value, $isExpression]; return $this; @@ -191,11 +190,11 @@ class DAOGetAction extends AbstractGetAction { * @param string $op * @param mixed $value * @return $this - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function addHaving(string $expr, string $op, $value = NULL) { if (!in_array($op, CoreUtil::getOperators())) { - throw new \API_Exception('Unsupported operator'); + throw new \CRM_Core_Exception('Unsupported operator'); } $this->having[] = [$expr, $op, $value]; return $this; diff --git a/Civi/Api4/Generic/DAOGetFieldsAction.php b/Civi/Api4/Generic/DAOGetFieldsAction.php index 7b8e848b1b..ab29f0306e 100644 --- a/Civi/Api4/Generic/DAOGetFieldsAction.php +++ b/Civi/Api4/Generic/DAOGetFieldsAction.php @@ -76,7 +76,7 @@ class DAOGetFieldsAction extends BasicGetFieldsAction { * @param string $fieldName * @param array $fields * @return array|null - * @throws \API_Exception + * @throws \CRM_Core_Exception */ private function getFkFieldSpec($fieldName, $fields) { $fieldPath = explode('.', $fieldName); @@ -100,7 +100,7 @@ class DAOGetFieldsAction extends BasicGetFieldsAction { * * Normally this would involve calling getFields... but this IS getFields. * - * @throws \API_Exception + * @throws \CRM_Core_Exception */ private function formatValues() { foreach (array_keys($this->values) as $key) { diff --git a/Civi/Api4/Generic/DAOUpdateAction.php b/Civi/Api4/Generic/DAOUpdateAction.php index 25593822a6..5026e649eb 100644 --- a/Civi/Api4/Generic/DAOUpdateAction.php +++ b/Civi/Api4/Generic/DAOUpdateAction.php @@ -24,7 +24,6 @@ class DAOUpdateAction extends AbstractUpdateAction { /** * @param array $items * @return array - * @throws \API_Exception * @throws \CRM_Core_Exception */ protected function updateRecords(array $items): array { diff --git a/Civi/Api4/Generic/ExportAction.php b/Civi/Api4/Generic/ExportAction.php index e7cce1bb9f..4a98943d8e 100644 --- a/Civi/Api4/Generic/ExportAction.php +++ b/Civi/Api4/Generic/ExportAction.php @@ -74,7 +74,7 @@ class ExportAction extends AbstractAction { */ private function exportRecord(string $entityType, int $entityId, Result $result, $parentName = NULL, $excludeFields = []) { if (isset($this->exportedEntities[$entityType][$entityId])) { - throw new \API_Exception("Circular reference detected: attempted to export $entityType id $entityId multiple times."); + throw new \CRM_Core_Exception("Circular reference detected: attempted to export $entityType id $entityId multiple times."); } $this->exportedEntities[$entityType][$entityId] = TRUE; $select = $pseudofields = []; diff --git a/Civi/Api4/Generic/Result.php b/Civi/Api4/Generic/Result.php index fb8401e4d1..f7998df3a7 100644 --- a/Civi/Api4/Generic/Result.php +++ b/Civi/Api4/Generic/Result.php @@ -84,7 +84,7 @@ class Result extends \ArrayObject implements \JsonSerializable { * If there are too many or too few results, then throw an exception. * * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function single() { return \CRM_Utils_Array::single($this, "{$this->entity} record"); @@ -109,7 +109,7 @@ class Result extends \ArrayObject implements \JsonSerializable { * * @param string $key * @return $this - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function indexBy($key) { $this->indexedBy = $key; @@ -121,7 +121,7 @@ class Result extends \ArrayObject implements \JsonSerializable { } } if (!$newResults) { - throw new \API_Exception("Key $key not found in api results"); + throw new \CRM_Core_Exception("Key $key not found in api results"); } $this->exchangeArray($newResults); } @@ -167,7 +167,7 @@ class Result extends \ArrayObject implements \JsonSerializable { */ public function countMatched() :int { if (!isset($this->matchedCount)) { - throw new \API_Exception("countMatched can only be used if there was no limit set or if row_count was included in the select fields."); + throw new \CRM_Core_Exception("countMatched can only be used if there was no limit set or if row_count was included in the select fields."); } return $this->matchedCount; } diff --git a/Civi/Api4/Generic/Traits/DAOActionTrait.php b/Civi/Api4/Generic/Traits/DAOActionTrait.php index 047cdd26c2..9ef9c08bb4 100644 --- a/Civi/Api4/Generic/Traits/DAOActionTrait.php +++ b/Civi/Api4/Generic/Traits/DAOActionTrait.php @@ -98,7 +98,6 @@ trait DAOActionTrait { * * @return array * The records after being written to the DB (e.g. including newly assigned "id"). - * @throws \API_Exception * @throws \CRM_Core_Exception */ protected function writeObjects($items) { @@ -135,7 +134,7 @@ trait DAOActionTrait { foreach ($this->write($items) as $index => $dao) { if (!$dao) { $errMessage = sprintf('%s write operation failed', $this->getEntityName()); - throw new \API_Exception($errMessage); + throw new \CRM_Core_Exception($errMessage); } $result[] = $this->baoToArray($dao, $items[$index]); } @@ -230,7 +229,6 @@ trait DAOActionTrait { * @param array $params * @param int $entityId * - * @throws \API_Exception * @throws \CRM_Core_Exception */ protected function formatCustomParams(&$params, $entityId) { @@ -264,7 +262,7 @@ trait DAOActionTrait { require_once 'api/v3/utils.php'; $value = \_civicrm_api3_resolve_contactID($value); if ('unknown-user' === $value) { - throw new \API_Exception("\"{$field['name']}\" \"{$value}\" cannot be resolved to a contact ID", 2002, ['error_field' => $field['name'], "type" => "integer"]); + throw new \CRM_Core_Exception("\"{$field['name']}\" \"{$value}\" cannot be resolved to a contact ID", 2002, ['error_field' => $field['name'], "type" => "integer"]); } } diff --git a/Civi/Api4/Generic/Traits/ManagedEntity.php b/Civi/Api4/Generic/Traits/ManagedEntity.php index df7fc0edf6..f014bc76a6 100644 --- a/Civi/Api4/Generic/Traits/ManagedEntity.php +++ b/Civi/Api4/Generic/Traits/ManagedEntity.php @@ -32,7 +32,7 @@ trait ManagedEntity { return $item; } else { - throw new \API_Exception('Cannot revert ' . $action->getEntityName() . ' with id ' . $item['id']); + throw new \CRM_Core_Exception('Cannot revert ' . $action->getEntityName() . ' with id ' . $item['id']); } }))->setCheckPermissions($checkPermissions); } diff --git a/Civi/Api4/Generic/Traits/SavedSearchInspectorTrait.php b/Civi/Api4/Generic/Traits/SavedSearchInspectorTrait.php index 0cd0f230a1..699ed310a5 100644 --- a/Civi/Api4/Generic/Traits/SavedSearchInspectorTrait.php +++ b/Civi/Api4/Generic/Traits/SavedSearchInspectorTrait.php @@ -45,7 +45,7 @@ trait SavedSearchInspectorTrait { /** * If SavedSearch is supplied as a string, this will load it as an array - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ protected function loadSavedSearch() { diff --git a/Civi/Api4/Generic/Traits/SelectParamTrait.php b/Civi/Api4/Generic/Traits/SelectParamTrait.php index 7ecd154363..e2a3c7fbae 100644 --- a/Civi/Api4/Generic/Traits/SelectParamTrait.php +++ b/Civi/Api4/Generic/Traits/SelectParamTrait.php @@ -50,7 +50,7 @@ trait SelectParamTrait { * It ignores those containing special characters like dots or parentheses, * they are handled separately in Api4SelectQuery. * - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function expandSelectClauseWildcards() { if (!$this->select) { diff --git a/Civi/Api4/Provider/ActionObjectProvider.php b/Civi/Api4/Provider/ActionObjectProvider.php index 8bfa560507..d3130eb61e 100644 --- a/Civi/Api4/Provider/ActionObjectProvider.php +++ b/Civi/Api4/Provider/ActionObjectProvider.php @@ -93,7 +93,7 @@ class ActionObjectProvider implements EventSubscriberInterface, ProviderInterfac * @param $request * @param $row * @return array|\Civi\Api4\Generic\Result|null - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function runChain($request, $row) { [$entity, $action, $params, $index] = $request; diff --git a/Civi/Api4/Query/Api4SelectQuery.php b/Civi/Api4/Query/Api4SelectQuery.php index f4abb51acc..70dda45a15 100644 --- a/Civi/Api4/Query/Api4SelectQuery.php +++ b/Civi/Api4/Query/Api4SelectQuery.php @@ -142,7 +142,6 @@ class Api4SelectQuery { * Builds main final sql statement after initialization. * * @return string - * @throws \API_Exception * @throws \CRM_Core_Exception */ public function getSql() { @@ -180,7 +179,7 @@ class Api4SelectQuery { /** * @return int - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function getCount() { $this->buildWhereClause(); @@ -208,7 +207,7 @@ class Api4SelectQuery { /** * @param array $select * Array of select expressions; defaults to $this->getSelect - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function buildSelectClause($select = NULL) { // Use default if select not provided, exclude row_count which is handled elsewhere @@ -268,7 +267,7 @@ class Api4SelectQuery { if ($valid) { $alias = $expr->getAlias(); if ($alias != $expr->getExpr() && isset($this->apiFieldSpec[$alias])) { - throw new \API_Exception('Cannot use existing field name as alias'); + throw new \CRM_Core_Exception('Cannot use existing field name as alias'); } $this->selectAliases[$alias] = $expr->getExpr(); $this->query->select($expr->render($this) . " AS `$alias`"); @@ -322,7 +321,7 @@ class Api4SelectQuery { protected function buildOrderBy() { foreach ($this->getOrderBy() as $item => $dir) { if ($dir !== 'ASC' && $dir !== 'DESC') { - throw new \API_Exception("Invalid sort direction. Cannot order by $item $dir"); + throw new \CRM_Core_Exception("Invalid sort direction. Cannot order by $item $dir"); } try { @@ -341,7 +340,7 @@ class Api4SelectQuery { } } // If the expression could not be rendered, it might be a field alias - catch (\API_Exception $e) { + catch (\CRM_Core_Exception $e) { // Silently ignore fields the user lacks permission to see if (is_a($e, 'Civi\API\Exception\UnauthorizedException')) { $this->debug('unauthorized_fields', $item); @@ -351,7 +350,7 @@ class Api4SelectQuery { $column = '`' . $item . '`'; } else { - throw new \API_Exception("Invalid field '{$item}'"); + throw new \CRM_Core_Exception("Invalid field '{$item}'"); } } @@ -389,7 +388,7 @@ class Api4SelectQuery { * @param int $depth * @return string SQL where clause * - * @throws \API_Exception + * @throws \CRM_Core_Exception * @uses composeClause() to generate the SQL etc. */ protected function treeWalkClauses($clause, $type, $depth = 0) { @@ -438,7 +437,7 @@ class Api4SelectQuery { * WHERE|HAVING|ON * @param int $depth * @return string SQL - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Exception */ public function composeClause(array $clause, string $type, int $depth) { @@ -447,7 +446,7 @@ class Api4SelectQuery { [$expr, $operator, $value] = array_pad($clause, 3, NULL); $isExpression = $clause[3] ?? FALSE; if (!in_array($operator, CoreUtil::getOperators(), TRUE)) { - throw new \API_Exception('Illegal operator'); + throw new \CRM_Core_Exception('Illegal operator'); } // For WHERE clause, expr must be the name of a field. @@ -500,7 +499,7 @@ class Api4SelectQuery { throw new UnauthorizedException("Unauthorized field '$expr'"); } else { - throw new \API_Exception("Invalid expression in HAVING clause: '$expr'. Must use a value from SELECT clause."); + throw new \CRM_Core_Exception("Invalid expression in HAVING clause: '$expr'. Must use a value from SELECT clause."); } } $fieldAlias = '`' . $fieldAlias . '`'; @@ -529,7 +528,7 @@ class Api4SelectQuery { $sqlClause = $this->createSQLClause($fieldAlias, $operator, $value, $field, $depth); if ($sqlClause === NULL) { - throw new \API_Exception("Invalid value in $type clause for '$expr'"); + throw new \CRM_Core_Exception("Invalid value in $type clause for '$expr'"); } return $sqlClause; } @@ -545,7 +544,7 @@ class Api4SelectQuery { */ protected function createSQLClause($fieldAlias, $operator, $value, $field, int $depth) { if (!empty($field['operators']) && !in_array($operator, $field['operators'], TRUE)) { - throw new \API_Exception('Illegal operator for ' . $field['name']); + throw new \CRM_Core_Exception('Illegal operator for ' . $field['name']); } // Some fields use a callback to generate their sql if (!empty($field['sql_filters'])) { @@ -605,7 +604,7 @@ class Api4SelectQuery { * @param string $expr * @param array $allowedTypes * @return SqlExpression - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function getExpression(string $expr, $allowedTypes = NULL) { $sqlExpr = SqlExpression::convert($expr, FALSE, $allowedTypes); @@ -649,7 +648,7 @@ class Api4SelectQuery { * In strict mode, this will throw an exception if the field doesn't exist * * @return array|null - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function getField($expr, $strict = FALSE) { // If the expression contains a pseudoconstant filter like activity_type_id:label, @@ -665,7 +664,7 @@ class Api4SelectQuery { $this->debug($field === FALSE ? 'unauthorized_fields' : 'undefined_fields', $fieldName); } if ($strict && $field === NULL) { - throw new \API_Exception("Invalid field '$fieldName'"); + throw new \CRM_Core_Exception("Invalid field '$fieldName'"); } if ($strict && $field === FALSE) { throw new UnauthorizedException("Unauthorized field '$fieldName'"); @@ -704,7 +703,7 @@ class Api4SelectQuery { /** * Join onto other entities as specified by the api call. * - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\NotImplementedException */ private function addExplicitJoins() { @@ -720,7 +719,7 @@ class Api4SelectQuery { // Ensure alias is a safe string, and supply default if not given $alias = $alias ?: strtolower($entity); if ($alias === self::MAIN_TABLE_ALIAS || !preg_match('/^[-\w]{1,256}$/', $alias)) { - throw new \API_Exception('Illegal join alias: "' . $alias . '"'); + throw new \CRM_Core_Exception('Illegal join alias: "' . $alias . '"'); } // First item in the array is a boolean indicating if the join is required (aka INNER or LEFT). // The rest are join conditions. @@ -730,7 +729,7 @@ class Api4SelectQuery { $side = $side ? 'INNER' : 'LEFT'; } if (!in_array($side, ['INNER', 'LEFT', 'EXCLUDE'])) { - throw new \API_Exception("Illegal value for join side: '$side'."); + throw new \CRM_Core_Exception("Illegal value for join side: '$side'."); } if ($side === 'EXCLUDE') { $side = 'LEFT'; @@ -832,7 +831,7 @@ class Api4SelectQuery { * @param string $joinEntity * @param string $alias * @param string $side - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function addBridgeJoin($joinTree, $joinEntity, $alias, $side) { $bridgeEntity = array_shift($joinTree); @@ -892,7 +891,7 @@ class Api4SelectQuery { * @param string $bridgeEntity * @param string $joinEntity * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ private function getBridgeRefs(string $bridgeEntity, string $joinEntity): array { $bridges = CoreUtil::getInfoItem($bridgeEntity, 'bridge') ?? []; @@ -916,7 +915,7 @@ class Api4SelectQuery { } } } - throw new \API_Exception("Unable to join $bridgeEntity to $joinEntity"); + throw new \CRM_Core_Exception("Unable to join $bridgeEntity to $joinEntity"); } /** @@ -980,7 +979,7 @@ class Api4SelectQuery { * @param string $bridgeEntity * @param string $side * @return string[] - * @throws \API_Exception + * @throws \CRM_Core_Exception */ private function getBridgeJoinConditions(array &$joinTree, $baseRef, string $alias, string $bridgeAlias, string $bridgeEntity, string $side): array { $bridgeConditions = []; @@ -1009,7 +1008,7 @@ class Api4SelectQuery { // If no bridge conditions were specified, link it to the base entity if (!$bridgeConditions) { if (!in_array($this->getEntity(), $baseRef->getTargetEntities())) { - throw new \API_Exception("Unable to join $bridgeEntity to " . $this->getEntity()); + throw new \CRM_Core_Exception("Unable to join $bridgeEntity to " . $this->getEntity()); } $bridgeConditions[] = "`$bridgeAlias`.`{$baseRef->getReferenceKey()}` = a.`{$baseRef->getTargetKey()}`"; if ($baseRef->getTypeColumn()) { @@ -1052,14 +1051,14 @@ class Api4SelectQuery { try { $joinPath = $joiner->getPath($explicitJoin['table'] ?? $this->getFrom(), $pathArray); } - catch (\API_Exception $e) { + catch (\CRM_Core_Exception $e) { if (!empty($explicitJoin['bridge'])) { // Try looking up custom field in bridge entity instead try { $useBridgeTable = TRUE; $joinPath = $joiner->getPath(CoreUtil::getTableName($explicitJoin['bridge']), $pathArray); } - catch (\API_Exception $e) { + catch (\CRM_Core_Exception $e) { return; } } diff --git a/Civi/Api4/Query/SqlExpression.php b/Civi/Api4/Query/SqlExpression.php index d52c0a2d41..1ddf884995 100644 --- a/Civi/Api4/Query/SqlExpression.php +++ b/Civi/Api4/Query/SqlExpression.php @@ -74,7 +74,7 @@ abstract class SqlExpression { * @param bool $parseAlias * @param array $mustBe * @return SqlExpression - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function convert(string $expression, $parseAlias = FALSE, $mustBe = []) { $as = $parseAlias ? strrpos($expression, ' AS ') : FALSE; @@ -91,7 +91,7 @@ abstract class SqlExpression { elseif ($bracketPos && $lastChar === ')') { $fnName = substr($expr, 0, $bracketPos); if ($fnName !== strtoupper($fnName)) { - throw new \API_Exception('Sql function must be uppercase.'); + throw new \CRM_Core_Exception('Sql function must be uppercase.'); } $className = 'SqlFunction' . $fnName; } @@ -114,7 +114,7 @@ abstract class SqlExpression { } $className = __NAMESPACE__ . '\\' . $className; if (!class_exists($className)) { - throw new \API_Exception('Unable to parse sql expression: ' . $expression); + throw new \CRM_Core_Exception('Unable to parse sql expression: ' . $expression); } $sqlExpression = new $className($expr, $alias); if ($mustBe) { @@ -123,7 +123,7 @@ abstract class SqlExpression { return $sqlExpression; } } - throw new \API_Exception('Illegal sql expression.'); + throw new \CRM_Core_Exception('Illegal sql expression.'); } return $sqlExpression; } @@ -209,7 +209,7 @@ abstract class SqlExpression { * @param array $mustBe * @param int $max * @return SqlExpression[] - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function captureExpressions(string &$arg, array $mustBe, int $max) { $captured = []; diff --git a/Civi/Api4/Query/SqlField.php b/Civi/Api4/Query/SqlField.php index 0dde50583b..a921dabfaa 100644 --- a/Civi/Api4/Query/SqlField.php +++ b/Civi/Api4/Query/SqlField.php @@ -20,7 +20,7 @@ class SqlField extends SqlExpression { protected function initialize() { if ($this->alias && $this->alias !== $this->expr) { - throw new \API_Exception("Aliasing field names is not allowed, only expressions can have an alias."); + throw new \CRM_Core_Exception("Aliasing field names is not allowed, only expressions can have an alias."); } $this->fields[] = $this->expr; } diff --git a/Civi/Api4/Query/SqlFunction.php b/Civi/Api4/Query/SqlFunction.php index 32843bafa9..9f25b7a238 100644 --- a/Civi/Api4/Query/SqlFunction.php +++ b/Civi/Api4/Query/SqlFunction.php @@ -59,7 +59,7 @@ abstract class SqlFunction extends SqlExpression { continue; } if (!$prefix && !$param['optional']) { - throw new \API_Exception("Missing param $name for SQL function " . static::getName()); + throw new \CRM_Core_Exception("Missing param $name for SQL function " . static::getName()); } } elseif ($param['flag_before']) { @@ -76,7 +76,7 @@ abstract class SqlFunction extends SqlExpression { count($exprs) < $param['min_expr'] && !(!$exprs && $param['optional']) ) { - throw new \API_Exception("Too few arguments to param $name for SQL function " . static::getName()); + throw new \CRM_Core_Exception("Too few arguments to param $name for SQL function " . static::getName()); } $this->args[$idx]['expr'] = $exprs; @@ -84,7 +84,7 @@ abstract class SqlFunction extends SqlExpression { } } if (trim($arg)) { - throw new \API_Exception("Too many arguments given for SQL function " . static::getName()); + throw new \CRM_Core_Exception("Too many arguments given for SQL function " . static::getName()); } } diff --git a/Civi/Api4/Service/Schema/Joinable/CustomGroupJoinable.php b/Civi/Api4/Service/Schema/Joinable/CustomGroupJoinable.php index e42248279a..4ca50f0795 100644 --- a/Civi/Api4/Service/Schema/Joinable/CustomGroupJoinable.php +++ b/Civi/Api4/Service/Schema/Joinable/CustomGroupJoinable.php @@ -97,7 +97,7 @@ class CustomGroupJoinable extends Joinable { * * @param $extends * @return string - * @throws \API_Exception + * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ public static function getEntityFromExtends($extends) { diff --git a/Civi/Api4/Service/Schema/Joiner.php b/Civi/Api4/Service/Schema/Joiner.php index cda0a8344e..4d96d3461c 100644 --- a/Civi/Api4/Service/Schema/Joiner.php +++ b/Civi/Api4/Service/Schema/Joiner.php @@ -39,7 +39,7 @@ class Joiner { * @param array $joinPath * * @return \Civi\Api4\Service\Schema\Joinable\Joinable[] - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function getPath(string $baseTable, array $joinPath) { $cacheKey = sprintf('%s.%s', $baseTable, implode('.', $joinPath)); @@ -50,7 +50,7 @@ class Joiner { $link = $this->schemaMap->getLink($baseTable, $targetAlias); if (!$link) { - throw new \API_Exception(sprintf('Cannot join %s to %s', $baseTable, $targetAlias)); + throw new \CRM_Core_Exception(sprintf('Cannot join %s to %s', $baseTable, $targetAlias)); } else { $fullPath[$targetAlias] = $link; diff --git a/Civi/Api4/Service/Schema/SchemaMap.php b/Civi/Api4/Service/Schema/SchemaMap.php index c6c01d6c7b..180932bbbd 100644 --- a/Civi/Api4/Service/Schema/SchemaMap.php +++ b/Civi/Api4/Service/Schema/SchemaMap.php @@ -25,13 +25,13 @@ class SchemaMap { * * @return \Civi\Api4\Service\Schema\Joinable\Joinable|NULL * Link to the target table - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public function getLink($baseTableName, $targetTableAlias): ?Joinable\Joinable { $table = $this->getTableByName($baseTableName); if (!$table) { - throw new \API_Exception("Table $baseTableName not found"); + throw new \CRM_Core_Exception("Table $baseTableName not found"); } foreach ($table->getTableLinks() as $link) { diff --git a/Civi/Api4/Service/Spec/SpecGatherer.php b/Civi/Api4/Service/Spec/SpecGatherer.php index 7b0a3b9e8a..501dcbb9c1 100644 --- a/Civi/Api4/Service/Spec/SpecGatherer.php +++ b/Civi/Api4/Service/Spec/SpecGatherer.php @@ -108,7 +108,7 @@ class SpecGatherer { * * @param string $entity * @param \Civi\Api4\Service\Spec\RequestSpec $spec - * @throws \API_Exception + * @throws \CRM_Core_Exception * @see \CRM_Core_SelectValues::customGroupExtends */ private function addCustomFields($entity, RequestSpec $spec) { @@ -220,12 +220,12 @@ class SpecGatherer { * @param string $entityName * * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ private function getDAOFields(string $entityName): array { $bao = CoreUtil::getBAOFromApiName($entityName); if (!$bao) { - throw new \API_Exception('Entity not loaded: ' . $entityName); + throw new \CRM_Core_Exception('Entity not loaded: ' . $entityName); } return $bao::getSupportedFields(); } diff --git a/Civi/Api4/Utils/CoreUtil.php b/Civi/Api4/Utils/CoreUtil.php index f6f7801058..630c9e7137 100644 --- a/Civi/Api4/Utils/CoreUtil.php +++ b/Civi/Api4/Utils/CoreUtil.php @@ -161,7 +161,6 @@ class CoreUtil { * @param int|string $userID * Contact ID of the user we are testing,. 0 for the anonymous user. * @return bool - * @throws \API_Exception * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\NotImplementedException * @throws \Civi\API\Exception\UnauthorizedException @@ -208,7 +207,6 @@ class CoreUtil { * Contact ID of the user we are testing, or 0 for the anonymous user. * * @return bool - * @throws \API_Exception * @throws \CRM_Core_Exception */ public static function checkAccessDelegated(string $entityName, string $actionName, array $record, int $userID) { diff --git a/Civi/Api4/Utils/FormattingUtil.php b/Civi/Api4/Utils/FormattingUtil.php index 3e92ddd2e0..2fe49d3453 100644 --- a/Civi/Api4/Utils/FormattingUtil.php +++ b/Civi/Api4/Utils/FormattingUtil.php @@ -37,7 +37,7 @@ class FormattingUtil { * * @param array $params * @param array $fields - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function formatWriteParams(&$params, $fields) { foreach ($fields as $name => $field) { @@ -84,7 +84,6 @@ class FormattingUtil { * @param array $fieldSpec * @param string|null $operator (only for 'get' actions) * @param null $index (for recursive loops) - * @throws \API_Exception * @throws \CRM_Core_Exception */ public static function formatInputValue(&$value, ?string $fieldName, array $fieldSpec, &$operator = NULL, $index = NULL) { @@ -111,7 +110,7 @@ class FormattingUtil { if ($fk === 'Contact' && !is_numeric($value)) { $value = \_civicrm_api3_resolve_contactID($value); if ('unknown-user' === $value) { - throw new \API_Exception("\"{$fieldSpec['name']}\" \"{$value}\" cannot be resolved to a contact ID", 2002, ['error_field' => $fieldSpec['name'], "type" => "integer"]); + throw new \CRM_Core_Exception("\"{$fieldSpec['name']}\" \"{$value}\" cannot be resolved to a contact ID", 2002, ['error_field' => $fieldSpec['name'], "type" => "integer"]); } } @@ -148,7 +147,7 @@ class FormattingUtil { return date($format, strtotime($value ?? '')); } if (isset($index) && !strstr($operator, 'BETWEEN')) { - throw new \API_Exception("Relative dates cannot be in an array using the $operator operator."); + throw new \CRM_Core_Exception("Relative dates cannot be in an array using the $operator operator."); } [$dateFrom, $dateTo] = \CRM_Utils_Date::getFromTo($value); switch ($operator) { @@ -177,7 +176,7 @@ class FormattingUtil { return self::formatDateValue($format, $index ? $dateTo : $dateFrom); default: - throw new \API_Exception("Relative dates cannot be used with the $operator operator."); + throw new \CRM_Core_Exception("Relative dates cannot be used with the $operator operator."); } } @@ -188,7 +187,6 @@ class FormattingUtil { * @param array $fields * @param string $action * @param array $selectAliases - * @throws \API_Exception * @throws \CRM_Core_Exception */ public static function formatOutputValues(&$results, $fields, $action = 'get', $selectAliases = []) { @@ -247,7 +245,7 @@ class FormattingUtil { * Other values for this object * @param string $action * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ public static function getPseudoconstantList(array $field, string $fieldAlias, $params = [], $action = 'get') { [$fieldPath, $valueType] = explode(':', $fieldAlias); @@ -255,7 +253,7 @@ class FormattingUtil { // For create actions, only unique identifiers can be used. // For get actions any valid suffix is ok. if (($action === 'create' && !$context) || !in_array($valueType, self::$pseudoConstantSuffixes, TRUE)) { - throw new \API_Exception('Illegal expression'); + throw new \CRM_Core_Exception('Illegal expression'); } $baoName = $context ? CoreUtil::getBAOFromApiName($field['entity']) : NULL; // Use BAO::buildOptions if possible @@ -271,7 +269,7 @@ class FormattingUtil { if (is_array($options)) { return $options; } - throw new \API_Exception("No option list found for '{$field['name']}'"); + throw new \CRM_Core_Exception("No option list found for '{$field['name']}'"); } /** diff --git a/Civi/CCase/SequenceListener.php b/Civi/CCase/SequenceListener.php index 3629914bca..8b80360d1b 100644 --- a/Civi/CCase/SequenceListener.php +++ b/Civi/CCase/SequenceListener.php @@ -39,7 +39,7 @@ class SequenceListener implements CaseChangeListener { * * @param \Civi\CCase\Event\CaseChangeEvent $event * - * @throws \CiviCRM_API3_Exception + * @throws \CRM_Core_Exception * @return void */ public function onCaseChange(\Civi\CCase\Event\CaseChangeEvent $event) { diff --git a/Civi/Payment/System.php b/Civi/Payment/System.php index 358ce7f023..1dfa4eaf4f 100644 --- a/Civi/Payment/System.php +++ b/Civi/Payment/System.php @@ -106,7 +106,7 @@ class System { * * @return \CRM_Core_Payment * - * @throws \CiviCRM_API3_Exception|\CRM_Core_Exception + * @throws \CRM_Core_Exception */ public function getById($id) { if (isset($this->cache[$id])) { @@ -124,7 +124,7 @@ class System { * @param bool $is_test * * @return \CRM_Core_Payment|NULL - * @throws \CiviCRM_API3_Exception + * @throws \CRM_Core_Exception */ public function getByName($name, $is_test) { $processor = civicrm_api3('payment_processor', 'getsingle', ['name' => $name, 'is_test' => $is_test]); @@ -157,7 +157,7 @@ class System { * @param string $className * * @return \Civi\Payment\CRM_Core_Payment|NULL - * @throws \CiviCRM_API3_Exception + * @throws \CRM_Core_Exception */ public function getByClass($className) { return $this->getByProcessor([ diff --git a/Civi/Test/Api3TestTrait.php b/Civi/Test/Api3TestTrait.php index 59eb25c063..57007fa4bc 100644 --- a/Civi/Test/Api3TestTrait.php +++ b/Civi/Test/Api3TestTrait.php @@ -130,7 +130,7 @@ trait Api3TestTrait { try { $result = $this->civicrm_api($entity, $action, $params); } - catch (\API_Exception $e) { + catch (\CRM_Core_Exception $e) { // api v4 call failed and threw an exception. return []; } @@ -299,8 +299,7 @@ trait Api3TestTrait { * @param $v3Action * @param array $v3Params * @return array|int - * @throws \API_Exception - * @throws \CiviCRM_API3_Exception + * @throws \CRM_Core_Exception * @throws \Exception */ public function runApi4Legacy($v3Entity, $v3Action, $v3Params = []) { @@ -626,7 +625,7 @@ trait Api3TestTrait { * @param array $result * @param bool $sequential * @return array - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function runApi4LegacyChain($key, $params, $mainEntity, $result, $sequential) { // Handle an array of multiple calls using recursion diff --git a/Civi/Test/WorkflowMessageTestTrait.php b/Civi/Test/WorkflowMessageTestTrait.php index 1c4bd77805..8adf4e5038 100644 --- a/Civi/Test/WorkflowMessageTestTrait.php +++ b/Civi/Test/WorkflowMessageTestTrait.php @@ -24,7 +24,7 @@ trait WorkflowMessageTestTrait { /** * @return \Civi\Api4\Generic\AbstractGetAction - * @throws \API_Exception + * @throws \CRM_Core_Exception */ protected function findExamples(): \Civi\Api4\Generic\AbstractGetAction { return \Civi\Api4\ExampleData::get(0)