-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Throw exceptions on SQL errors #18151
base: main
Are you sure you want to change the base?
Throw exceptions on SQL errors #18151
Conversation
1c82c4a
to
f79da9f
Compare
@@ -122,7 +122,7 @@ The present file will list all changes made to the project; according to the | |||
- Usage of `DBmysql::query()`, `DBmysql::queryOrDie()` method are prohibited to ensure that legacy unsafe DB are no more executed. | |||
Building and executing raw queries using `DBmysql::request()`, `DBmysqlIterator::buildQuery()` and `DBmysqlIterator::execute()` methods is also prohibited. | |||
To execute DB queries, either `DBmysql::request()` can be used to craft query using the GLPI query builder, | |||
either `DBmysql::doQuery()`/`DBmysql::doQueryOrDie()` can be used for safe queries to execute DB query using a self-crafted a SQL string. | |||
either `DBmysql::doQuery()` can be used for safe queries to execute DB query using a self-crafted a SQL string. |
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.
either `DBmysql::doQuery()` can be used for safe queries to execute DB query using a self-crafted a SQL string. | |
`DBmysql::doQuery()` can be used for safe queries to execute DB query using a self-crafted a SQL string. |
f79da9f
to
08d23ff
Compare
E2E tests are failing due to the SQL error reported in #18175. |
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.
With these changes, should Toolbox::logSqlError()
and the associated sql-errors.log
file be depreciated/removed ?
With the new exception, SQL errors end up directly in the php-errors-log
file.
I don't see a use case for manually calling Toolbox::logSqlError()
.
|
Checklist before requesting a review
Description
Since we did not have a centralized error catching in the past, we were not able to throw exceptions when a SQL error occurred. They were just logged and were not stopping the code execution, and this could have the effect of triggering hard-to-debug errors in subsequently executed code.
Now we have a centralized error catching system, we can throw exceptions when a SQL error is triggered. It would result in displaying the error page. For instance, if I force a SQL querry error in the impact analysis tab: