-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix handling of invalid sql query during import #25600
Conversation
(Standard links)
|
623da56
to
085d0c1
Compare
test this please fatal: unable to access 'https://lab.civicrm.org/extensions/angularprofiles.git/': Failed to connect to lab.civicrm.org port 443 after 130015 ms: Connection timed out |
Note here is another case where code fell into the trap of not catching the |
OK, the PR is doing a bit of trick - in its title, it approaches a narrow problem (the importer fails on SQL exception; go figure), but the discussion proposes a wide-ranging change (rework the class-hierarchy vis-a-vis exceptions and PEAR). I suspect you're looking for feedback on the latter. My first reaction was: "That's crazy." But... the
Trying to rationalize this... I suppose there are a few reasons why downstream would not have taken to
So on conceptual level, there should be path that makes it possible to replace I don't have my head fully around what the exception should look like, but I wonder if the framing in this branch might be a bit too narrow? Like... it means that most use-cases still throw the same kind of exception, but this one throws something different. Since there doesn't seem to be a huge systemic commitment to |
@totten one thing to bear in mind is that I think the obvious place that should through something that inhetirs |
@totten the last point is - yes - this branch only adds the new exception in one place - the focus being on defining what the new exception class might look like rather than the adding of it in - although as I say |
085d0c1
to
a95bd3a
Compare
CRM/Import/Form/DataSource.php
Outdated
$this->instantiateDataSource(); | ||
} | ||
catch (CRM_Core_Exception $e) { | ||
CRM_Core_Error::statusBounce($e->getUserMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton I tried a SQL import with select * from foo
, and it failed like this:
Changing getUserMessage()
to getMessage()
worked locally...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@totten ah yeah - that fell out when I split - OK - will move that part out of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@totten ok fixed - I'll fix up the follow on PR once this is merged
d983a4b
to
b5193dc
Compare
b5193dc
to
b22688e
Compare
Confirmed it works better 👍 Merge on pass |
Overview
Fix handling of invalid sql query during import
To replicate this be sure to log in as admin rather than demo
Attempt an import with an invalid sql query
Before
After
Page reloads as
Technical Details
UPDATE - the exception stuff is being moved to a separate PR
The main thing going on in this PR is trying to think about what is going on with Exceptions. My general thoughts on Exceptions is that any anticipated Exception that arises from within CiviCRM that is handled in a different subsystem than it was generated in should be a version of
CRM_Core_Exception
. This would mean that all CiviCRM code or DB errors arising from CiviCRM sql calls would be caught by catchingCRM_Core_Exception
. From there we can have more nuanced exceptions.This is not currently the case. Any code that runs
CRM_Core_DAO::executeQuery()
indirectly or directly may have to deal with an uncaughtPEAR_Exception
.This PR doesn't change that but starts to propose what an alternative that implements some / most of what
PEAR_Exception
provides - iegetErrorCode
getPEARErrorCode
getUserMessage
One thing it doesn't do is handle protecting the usefulness of the backtrace - I figured I'd worry about that if it became the blocker
A couple more things I realised in the process
CRM_Core_Exception
extendsPEAR_Exception
- I'm not a fan.Comments
This is an alternative to #25171 - although I suspect it will stall so I'm going to put up the context part as a more limited patch to get that merged