fix(comments): Don's catch invalid DriverException

These are nowadays also OCP\DB\Exception and if the id is not a numeric
deleting by id is also non working.

Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
This commit is contained in:
Carl Schwan 2025-08-26 17:21:11 +02:00 committed by Carl Schwan
parent 9b2fff5931
commit 996be0f441

View file

@ -7,8 +7,6 @@
*/
namespace OC\Comments;
use Doctrine\DBAL\Exception\DriverException;
use OCA\DAV\Connector\Sabre\File;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\CommentsEvent;
use OCP\Comments\IComment;
@ -876,20 +874,23 @@ class Manager implements ICommentsManager {
try {
$comment = $this->get($id);
} catch (\Exception $e) {
} catch (\Exception) {
// Ignore exceptions, we just don't fire a hook then
$comment = null;
}
if (!is_numeric($id)) {
return false;
}
$qb = $this->dbConn->getQueryBuilder();
$query = $qb->delete('comments')
->where($qb->expr()->eq('id', $qb->createParameter('id')))
->setParameter('id', $id);
->where($qb->expr()->eq('id', $qb->createNamedParameter((int)$id, IQueryBuilder::PARAM_INT)));
try {
$affectedRows = $query->executeStatement();
$this->uncache($id);
} catch (DriverException $e) {
} catch (Exception $e) {
$this->logger->error($e->getMessage(), [
'exception' => $e,
'app' => 'core_comments',
@ -1332,7 +1333,7 @@ class Manager implements ICommentsManager {
try {
$affectedRows = $query->executeStatement();
} catch (DriverException $e) {
} catch (Exception $e) {
$this->logger->error($e->getMessage(), [
'exception' => $e,
'app' => 'core_comments',
@ -1439,7 +1440,7 @@ class Manager implements ICommentsManager {
try {
$affectedRows = $query->executeStatement();
} catch (DriverException $e) {
} catch (Exception $e) {
$this->logger->error($e->getMessage(), [
'exception' => $e,
'app' => 'core_comments',