*/
public function modifySpec(RequestSpec $spec): void {
$tableName = $spec->getEntityTableName();
- $columns = Import::getFieldsForTable($tableName);
- $action = $spec->getAction();
+ try {
+ $columns = Import::getFieldsForTable($tableName);
+ }
+ catch (\CRM_Core_Exception $e) {
+ // The api metadata may retain the expectation that this entity exists after the
+ // table is deleted - & hence we get an error.
+ return;
+ }
// CheckPermissions does not reach us here - so we will have to rely on earlier permission filters.
$userJobID = substr($spec->getEntity(), (strpos($spec->getEntity(), '_') + 1));
$userJob = UserJob::get(FALSE)->addWhere('id', '=', $userJobID)->addSelect('metadata', 'job_type', 'created_id')->execute()->first();
$headers = UserJob::get(FALSE)
->addWhere('metadata', 'LIKE', '%' . $tableName . '%')
->addSelect('metadata')->execute()->first()['metadata']['DataSource']['column_headers'] ?? [];
- $result = CRM_Core_DAO::executeQuery("SHOW COLUMNS FROM $tableName");
+ try {
+ $result = CRM_Core_DAO::executeQuery("SHOW COLUMNS FROM $tableName");
+ }
+ catch (\PEAR_Exception $e) {
+ throw new CRM_Core_Exception('Import table no longer exists');
+ }
$userFieldIndex = 0;
while ($result->fetch()) {
$columns[$result->Field] = ['name' => $result->Field, 'table_name' => $tableName];