From 89d1696642cb8eb685b87088dc10bf690f1e6edd Mon Sep 17 00:00:00 2001 From: Vangelis Pantazis Date: Sun, 18 Jun 2023 10:44:26 +0300 Subject: [PATCH] Catches exception errors before rendering the form --- CRM/Admin/Form/Setting/Smtp.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CRM/Admin/Form/Setting/Smtp.php b/CRM/Admin/Form/Setting/Smtp.php index 16afa30d36..6670e4a633 100644 --- a/CRM/Admin/Form/Setting/Smtp.php +++ b/CRM/Admin/Form/Setting/Smtp.php @@ -256,7 +256,13 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { $this->_defaults = $mailingBackend; if (!empty($this->_defaults['smtpPassword'])) { - $this->_defaults['smtpPassword'] = \Civi::service('crypto.token')->decrypt($this->_defaults['smtpPassword']); + try { + $this->_defaults['smtpPassword'] = \Civi::service('crypto.token')->decrypt($this->_defaults['smtpPassword']); + } + catch (Exception $e) { + Civi::log()->error($e->getMessage()); + CRM_Core_Session::setStatus(ts('Unable to retrieve the encrypted password. Please check your configured encryption keys. The error message is: %1', [1 => $e->getMessage()]), ts("Encryption key error"), "error"); + } } } else { -- 2.25.1