From: Tim Otten Date: Wed, 11 Aug 2021 00:11:00 +0000 (-0700) Subject: (REF) ActionSchedule - Remove unused `try`/`catch(TokenException $e)` X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=39eb69ec7d483b7d10abffb6ebd679d66d6b8446;p=civicrm-core.git (REF) ActionSchedule - Remove unused `try`/`catch(TokenException $e)` This try/catch block purports to catch any exceptions of type `TokenException`. However, if you grep the source tree, you will find that `TokenException` is never thrown. --- diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index d77feae933..014978230e 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -269,40 +269,35 @@ FROM civicrm_action_schedule cas $multilingual = CRM_Core_I18n::isMultilingual(); while ($dao->fetch()) { $errors = []; - try { - $tokenProcessor = self::createTokenProcessor($actionSchedule, $mapping); - $row = $tokenProcessor->addRow() - ->context('contactId', $dao->contactID) - ->context('actionSearchResult', (object) $dao->toArray()); - - // switch language if necessary - if ($multilingual) { - $preferred_language = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contactID, 'preferred_language'); - $row->context('locale', CRM_Core_BAO_ActionSchedule::pickLocale($actionSchedule->communication_language, $preferred_language)); - } - - foreach ($tokenProcessor->evaluate()->getRows() as $tokenRow) { - // It's possible, eg, that sendReminderEmail fires Hook::alterMailParams() and that some listener use ts(). - $swapLocale = empty($row->context['locale']) ? NULL : \CRM_Utils_AutoClean::swapLocale($row->context['locale']); + $tokenProcessor = self::createTokenProcessor($actionSchedule, $mapping); + $row = $tokenProcessor->addRow() + ->context('contactId', $dao->contactID) + ->context('actionSearchResult', (object) $dao->toArray()); + + // switch language if necessary + if ($multilingual) { + $preferred_language = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contactID, 'preferred_language'); + $row->context('locale', CRM_Core_BAO_ActionSchedule::pickLocale($actionSchedule->communication_language, $preferred_language)); + } - if ($actionSchedule->mode === 'SMS' || $actionSchedule->mode === 'User_Preference') { - CRM_Utils_Array::extend($errors, self::sendReminderSms($tokenRow, $actionSchedule, $dao->contactID)); - } + foreach ($tokenProcessor->evaluate()->getRows() as $tokenRow) { + // It's possible, eg, that sendReminderEmail fires Hook::alterMailParams() and that some listener use ts(). + $swapLocale = empty($row->context['locale']) ? NULL : \CRM_Utils_AutoClean::swapLocale($row->context['locale']); - if ($actionSchedule->mode === 'Email' || $actionSchedule->mode === 'User_Preference') { - CRM_Utils_Array::extend($errors, self::sendReminderEmail($tokenRow, $actionSchedule, $dao->contactID)); - } - // insert activity log record if needed - if ($actionSchedule->record_activity && empty($errors)) { - $caseID = empty($dao->case_id) ? NULL : $dao->case_id; - CRM_Core_BAO_ActionSchedule::createMailingActivity($tokenRow, $mapping, $dao->contactID, $dao->entityID, $caseID); - } + if ($actionSchedule->mode === 'SMS' || $actionSchedule->mode === 'User_Preference') { + CRM_Utils_Array::extend($errors, self::sendReminderSms($tokenRow, $actionSchedule, $dao->contactID)); + } - unset($swapLocale); + if ($actionSchedule->mode === 'Email' || $actionSchedule->mode === 'User_Preference') { + CRM_Utils_Array::extend($errors, self::sendReminderEmail($tokenRow, $actionSchedule, $dao->contactID)); } - } - catch (\Civi\Token\TokenException $e) { - $errors['token_exception'] = $e->getMessage(); + // insert activity log record if needed + if ($actionSchedule->record_activity && empty($errors)) { + $caseID = empty($dao->case_id) ? NULL : $dao->case_id; + CRM_Core_BAO_ActionSchedule::createMailingActivity($tokenRow, $mapping, $dao->contactID, $dao->entityID, $caseID); + } + + unset($swapLocale); } // update action log record