Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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 <[email protected]>
  • Loading branch information
Carl Schwan authored and CarlSchwan committed Sep 2, 2025
commit 996be0f4411fdb2214c8b38445a245661bc871fd
17 changes: 9 additions & 8 deletions lib/private/Comments/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -876,20 +874,23 @@ public function delete($id) {

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',
Expand Down Expand Up @@ -1332,7 +1333,7 @@ public function deleteReadMarksFromUser(IUser $user) {

try {
$affectedRows = $query->executeStatement();
} catch (DriverException $e) {
} catch (Exception $e) {
$this->logger->error($e->getMessage(), [
'exception' => $e,
'app' => 'core_comments',
Expand Down Expand Up @@ -1439,7 +1440,7 @@ public function deleteReadMarksOnObject($objectType, $objectId) {

try {
$affectedRows = $query->executeStatement();
} catch (DriverException $e) {
} catch (Exception $e) {
$this->logger->error($e->getMessage(), [
'exception' => $e,
'app' => 'core_comments',
Expand Down
Loading