From b22688ef812e25a07187d107f2938eb155c8c6e0 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 21 Feb 2023 13:35:42 +1300 Subject: [PATCH] Fix fatal on datasource error --- CRM/Import/DataSource/SQL.php | 7 ++++++- CRM/Import/Form/DataSource.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CRM/Import/DataSource/SQL.php b/CRM/Import/DataSource/SQL.php index ad6ac14ea0..d9fa015d90 100644 --- a/CRM/Import/DataSource/SQL.php +++ b/CRM/Import/DataSource/SQL.php @@ -81,7 +81,12 @@ class CRM_Import_DataSource_SQL extends CRM_Import_DataSource { public function initialize(): void { $table = CRM_Utils_SQL_TempTable::build()->setDurable(); $tableName = $table->getName(); - $table->createWithQuery($this->getSubmittedValue('sqlQuery')); + try { + $table->createWithQuery($this->getSubmittedValue('sqlQuery')); + } + catch (PEAR_Exception $e) { + throw new CRM_Core_Exception($e->getMessage(), 0, ['exception' => $e]); + } // 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 6fef3da018..95b1bf21ad 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -177,7 +177,12 @@ abstract class CRM_Import_Form_DataSource extends CRM_Import_Forms { $this->flushDataSource(); $this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues()); } - $this->instantiateDataSource(); + try { + $this->instantiateDataSource(); + } + catch (CRM_Core_Exception $e) { + CRM_Core_Error::statusBounce($e->getMessage()); + } } /** -- 2.25.1