Skip to content

Commit

Permalink
Fix fatal on datasource error
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Feb 21, 2023
1 parent 20c3cc4 commit d983a4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CRM/Import/DataSource/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ public static function formRule($fields, $files, $form) {
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(
Expand Down
8 changes: 7 additions & 1 deletion CRM/Import/Form/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function preProcess(): void {
CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE);
$this->assign('importEntity', $this->getTranslatedEntity());
$this->assign('importEntities', $this->getTranslatedEntities());
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
}

/**
Expand Down Expand Up @@ -176,7 +177,12 @@ protected function processDatasource(): void {
$this->flushDataSource();
$this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());
}
$this->instantiateDataSource();
try {
$this->instantiateDataSource();
}
catch (CRM_Core_Exception $e) {
CRM_Core_Error::statusBounce($e->getMessage());
}
}

/**
Expand Down

0 comments on commit d983a4b

Please sign in to comment.