diff options
author | Robin Appelman <robin@icewind.nl> | 2025-02-26 17:37:13 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2025-03-04 17:57:33 +0100 |
commit | b5f91fe20ef8fc0891bf3694ebbc2209f25714e5 (patch) | |
tree | b96d2ebcaf1223f4ffcd2b3c63ff08512ff36e84 | |
parent | 6860b5bbbe0efb04ec8549fbe86cc7569269c1a5 (diff) | |
download | nextcloud-server-backport/51073/stable29.tar.gz nextcloud-server-backport/51073/stable29.zip |
feat: log query for dbal exceptionsbackport/51073/stable29
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/DB/ConnectionAdapter.php | 6 | ||||
-rw-r--r-- | lib/private/DB/Exceptions/DbalException.php | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/private/DB/ConnectionAdapter.php b/lib/private/DB/ConnectionAdapter.php index 890161ef76f..ca5daffa26f 100644 --- a/lib/private/DB/ConnectionAdapter.php +++ b/lib/private/DB/ConnectionAdapter.php @@ -69,7 +69,7 @@ class ConnectionAdapter implements IDBConnection { $this->inner->executeQuery($sql, $params, $types) ); } catch (Exception $e) { - throw DbalException::wrap($e); + throw DbalException::wrap($e, '', $sql); } } @@ -77,7 +77,7 @@ class ConnectionAdapter implements IDBConnection { try { return $this->inner->executeUpdate($sql, $params, $types); } catch (Exception $e) { - throw DbalException::wrap($e); + throw DbalException::wrap($e, '', $sql); } } @@ -85,7 +85,7 @@ class ConnectionAdapter implements IDBConnection { try { return $this->inner->executeStatement($sql, $params, $types); } catch (Exception $e) { - throw DbalException::wrap($e); + throw DbalException::wrap($e, '', $sql); } } diff --git a/lib/private/DB/Exceptions/DbalException.php b/lib/private/DB/Exceptions/DbalException.php index 2b860a50ff3..28058f9b69d 100644 --- a/lib/private/DB/Exceptions/DbalException.php +++ b/lib/private/DB/Exceptions/DbalException.php @@ -52,26 +52,29 @@ use OCP\DB\Exception; class DbalException extends Exception { /** @var \Doctrine\DBAL\Exception */ private $original; + public ?string $query; /** * @param \Doctrine\DBAL\Exception $original * @param int $code * @param string $message */ - private function __construct(\Doctrine\DBAL\Exception $original, int $code, string $message) { + private function __construct(\Doctrine\DBAL\Exception $original, int $code, string $message, ?string $query = null) { parent::__construct( $message, $code, $original ); $this->original = $original; + $this->query = $query; } - public static function wrap(\Doctrine\DBAL\Exception $original, string $message = ''): self { + public static function wrap(\Doctrine\DBAL\Exception $original, string $message = '', ?string $query = null): self { return new self( $original, is_int($original->getCode()) ? $original->getCode() : 0, - empty($message) ? $original->getMessage() : $message + empty($message) ? $original->getMessage() : $message, + $query, ); } |