Problem/Motivation
The PostgreSQL driver throw a DatabaseExceptionWrapper to provide additional debug information.
For the Insert query, this driver pass wrong argument to this Exception (an integer instead of a throwable).
throw new DatabaseExceptionWrapper($message, 0, $e->getCode());
Proposed resolution
It should pass the exception code as second argument and the exception as the third one.
throw new DatabaseExceptionWrapper($message, $e->getCode(), $e);
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | postgresql-database-exception-wrapper-issues-3255437-2.patch | 629 bytes | papajo |
Comments
Comment #2
papajo commentedHere is a patch to fix it.
Comment #3
cilefen commentedComment #4
kalpaitch commentedTested, this works for me and looks like the correct approach.
Comment #5
szeidler commentedGood catch. +1 for the change. Otherwise you will see a
Wrong parameters for Drupal\Core\Database\DatabaseExceptionWrapper(instead of the database error you're interested in.Comment #6
quietone commentedThe file being changed here was deprecated in Drupal 9.4 and moved to the pgsql module, in #3129043: Move core database drivers to modules of their own. The exception is now handled in \Drupal\Core\Database\ExceptionHandler::handleExecutionException() which is where I think this change needs to be moved to. Setting to NW and changing version to 10.0.x
Comment #7
kalpaitch commentedThis doesn't seem to be an issue in 9.4. The exception handler handles exceptions as expected. Still an issue for older versions prior to 9.4 though.