From 15273086229cf52322bc614c6ca6a04badb3c03f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 21 Feb 2023 16:35:40 +1300 Subject: [PATCH] Reply on improved exception handling for handling bad sql in import process Show user sanitised message --- CRM/Import/DataSource/SQL.php | 7 +------ CRM/Import/Form/DataSource.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CRM/Import/DataSource/SQL.php b/CRM/Import/DataSource/SQL.php index d9fa015d90..ad6ac14ea0 100644 --- a/CRM/Import/DataSource/SQL.php +++ b/CRM/Import/DataSource/SQL.php @@ -81,12 +81,7 @@ class CRM_Import_DataSource_SQL extends CRM_Import_DataSource { public function initialize(): void { $table = CRM_Utils_SQL_TempTable::build()->setDurable(); $tableName = $table->getName(); - try { - $table->createWithQuery($this->getSubmittedValue('sqlQuery')); - } - catch (PEAR_Exception $e) { - throw new CRM_Core_Exception($e->getMessage(), 0, ['exception' => $e]); - } + $table->createWithQuery($this->getSubmittedValue('sqlQuery')); // Get the names of the fields to be imported. $columnsResult = CRM_Core_DAO::executeQuery( diff --git a/CRM/Import/Form/DataSource.php b/CRM/Import/Form/DataSource.php index 95b1bf21ad..97bb1ebe3d 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -181,7 +181,7 @@ abstract class CRM_Import_Form_DataSource extends CRM_Import_Forms { $this->instantiateDataSource(); } catch (CRM_Core_Exception $e) { - CRM_Core_Error::statusBounce($e->getMessage()); + CRM_Core_Error::statusBounce($e->getUserMessage()); } } -- 2.25.1