|
7 | 7 | */ |
8 | 8 | namespace OC\Comments; |
9 | 9 |
|
10 | | -use Doctrine\DBAL\Exception\DriverException; |
11 | | -use OCA\DAV\Connector\Sabre\File; |
12 | 10 | use OCP\AppFramework\Utility\ITimeFactory; |
13 | 11 | use OCP\Comments\CommentsEvent; |
14 | 12 | use OCP\Comments\IComment; |
@@ -876,20 +874,23 @@ public function delete($id) { |
876 | 874 |
|
877 | 875 | try { |
878 | 876 | $comment = $this->get($id); |
879 | | - } catch (\Exception $e) { |
| 877 | + } catch (\Exception) { |
880 | 878 | // Ignore exceptions, we just don't fire a hook then |
881 | 879 | $comment = null; |
882 | 880 | } |
883 | 881 |
|
| 882 | + if (!is_numeric($id)) { |
| 883 | + return false; |
| 884 | + } |
| 885 | + |
884 | 886 | $qb = $this->dbConn->getQueryBuilder(); |
885 | 887 | $query = $qb->delete('comments') |
886 | | - ->where($qb->expr()->eq('id', $qb->createParameter('id'))) |
887 | | - ->setParameter('id', $id); |
| 888 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter((int)$id, IQueryBuilder::PARAM_INT))); |
888 | 889 |
|
889 | 890 | try { |
890 | 891 | $affectedRows = $query->executeStatement(); |
891 | 892 | $this->uncache($id); |
892 | | - } catch (DriverException $e) { |
| 893 | + } catch (Exception $e) { |
893 | 894 | $this->logger->error($e->getMessage(), [ |
894 | 895 | 'exception' => $e, |
895 | 896 | 'app' => 'core_comments', |
@@ -1340,7 +1341,7 @@ public function deleteReadMarksFromUser(IUser $user) { |
1340 | 1341 |
|
1341 | 1342 | try { |
1342 | 1343 | $affectedRows = $query->executeStatement(); |
1343 | | - } catch (DriverException $e) { |
| 1344 | + } catch (Exception $e) { |
1344 | 1345 | $this->logger->error($e->getMessage(), [ |
1345 | 1346 | 'exception' => $e, |
1346 | 1347 | 'app' => 'core_comments', |
@@ -1447,7 +1448,7 @@ public function deleteReadMarksOnObject($objectType, $objectId) { |
1447 | 1448 |
|
1448 | 1449 | try { |
1449 | 1450 | $affectedRows = $query->executeStatement(); |
1450 | | - } catch (DriverException $e) { |
| 1451 | + } catch (Exception $e) { |
1451 | 1452 | $this->logger->error($e->getMessage(), [ |
1452 | 1453 | 'exception' => $e, |
1453 | 1454 | 'app' => 'core_comments', |
|
0 commit comments