]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
Merge pull request #4151 from ldidry/fix-4060
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Event / Subscriber / SQLiteCascadeDeleteSubscriber.php
index 3b4c4cf9fedfdd8d8e5ff1ffd141336873a92a68..dcadeedfc484a794b115fd652718dbb54a569b80 100644 (file)
@@ -2,10 +2,10 @@
 
 namespace Wallabag\CoreBundle\Event\Subscriber;
 
+use Doctrine\Bundle\DoctrineBundle\Registry;
 use Doctrine\Common\EventSubscriber;
 use Doctrine\ORM\Event\LifecycleEventArgs;
 use Wallabag\CoreBundle\Entity\Entry;
-use Doctrine\Bundle\DoctrineBundle\Registry;
 
 /**
  * SQLite doesn't care about cascading remove, so we need to manually remove associated stuf for an Entry.
@@ -18,9 +18,6 @@ class SQLiteCascadeDeleteSubscriber implements EventSubscriber
 {
     private $doctrine;
 
-    /**
-     * @param \Doctrine\Bundle\DoctrineBundle\Registry $doctrine
-     */
     public function __construct(Registry $doctrine)
     {
         $this->doctrine = $doctrine;
@@ -39,15 +36,12 @@ class SQLiteCascadeDeleteSubscriber implements EventSubscriber
     /**
      * We removed everything related to the upcoming removed entry because SQLite can't handle it on it own.
      * We do it in the preRemove, because we can't retrieve tags in the postRemove (because the entry id is gone).
-     *
-     * @param LifecycleEventArgs $args
      */
     public function preRemove(LifecycleEventArgs $args)
     {
         $entity = $args->getEntity();
-
-        if (!$this->doctrine->getConnection()->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver ||
-            !$entity instanceof Entry) {
+        if (!$this->doctrine->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform
+            || !$entity instanceof Entry) {
             return;
         }