civiimport - PEAR Exception handling - Mitigation of scenario where an import table has been deleted and the metadata is out of date #25633
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This fixes a situation where a fatal error on the main SearchKit screen which arises if the temp table for an import is deleted but the metadata cache for
\Civi::cache('metadata')->get('api4.entities.info', []);
still retains it.This is most easily replicated by doing an import, deleting the temp table in the DB and then going to the search kit screenSteps to reproduce:
civiimport
/civicrm/admin/search#/list?tab=packaged
.Before
With Civi Import enabled....
After
Technical Details
Although a
try-catch- was added to
SearchKitit is by-passed by the
PEAR_Exception. I could catch the
PEAR_Exception` in SearchKit but SearchKit 'shouldn't have to' so handling in the ImportProvider / converting the exceptions.civicrm-core/ext/search_kit/Civi/Search/Admin.php
Lines 147 to 157 in 4d8aca0
Thoughts about exceptions in #25600
Comments
I've figured out the scenario where this was happening & will separately address - but I think we should handle this regardless as I think there will always be some chance of it arising
Not strictly a regression but the handling that did not have enough cover to catch the
PEAR_Exception
is in 5.59