]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix DateTime & clear()
authorJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 9 Sep 2016 08:12:25 +0000 (10:12 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sun, 11 Sep 2016 19:58:55 +0000 (21:58 +0200)
src/Wallabag/CoreBundle/Entity/Entry.php
src/Wallabag/ImportBundle/Consumer/AMPQ/EntryConsumer.php
src/Wallabag/ImportBundle/Import/AbstractImport.php

index 304258a9c28854977988247fd229d9b676d8de9e..a4b0d7a82b4c436ed4bc79b6154e88590da36847 100644 (file)
@@ -97,7 +97,7 @@ class Entry
     private $content;
 
     /**
-     * @var date
+     * @var \DateTime
      *
      * @ORM\Column(name="created_at", type="datetime")
      *
@@ -106,7 +106,7 @@ class Entry
     private $createdAt;
 
     /**
-     * @var date
+     * @var \DateTime
      *
      * @ORM\Column(name="updated_at", type="datetime")
      *
@@ -413,7 +413,7 @@ class Entry
      * Set created_at.
      * Only used when importing data from an other service.
      *
-     * @param DateTime $createdAt
+     * @param \DateTime $createdAt
      *
      * @return Entry
      */
@@ -425,7 +425,7 @@ class Entry
     }
 
     /**
-     * @return DateTime
+     * @return \DateTime
      */
     public function getCreatedAt()
     {
@@ -433,7 +433,7 @@ class Entry
     }
 
     /**
-     * @return DateTime
+     * @return \DateTime
      */
     public function getUpdatedAt()
     {
index 8a8cf45d92fdf97de998421aa1954533ad3f1b61..72a3260a432542560e1b5b9ce964640c3d21afa9 100644 (file)
@@ -7,6 +7,8 @@ use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
 use PhpAmqpLib\Message\AMQPMessage;
 use Wallabag\ImportBundle\Import\AbstractImport;
 use Wallabag\UserBundle\Repository\UserRepository;
+use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Entity\Tag;
 use Psr\Log\LoggerInterface;
 use Psr\Log\NullLogger;
 
@@ -53,7 +55,10 @@ class EntryConsumer implements ConsumerInterface
 
         try {
             $this->em->flush();
-            $this->em->clear($entry);
+
+            // clear only affected entities
+            $this->em->clear(Entry::class);
+            $this->em->clear(Tag::class);
         } catch (\Exception $e) {
             $this->logger->warning('Unable to save entry', ['entry' => $storedEntry, 'exception' => $e]);
 
index 8610062d57fc55c413b756671a98735de0b03660..39befa7b79ab408ecd4f74c1444e7d888832edfb 100644 (file)
@@ -7,6 +7,7 @@ use Psr\Log\NullLogger;
 use Doctrine\ORM\EntityManager;
 use Wallabag\CoreBundle\Helper\ContentProxy;
 use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Entity\Tag;
 use Wallabag\UserBundle\Entity\User;
 use OldSound\RabbitMqBundle\RabbitMq\Producer;
 
@@ -113,7 +114,10 @@ abstract class AbstractImport implements ImportInterface
             // flush every 20 entries
             if (($i % 20) === 0) {
                 $this->em->flush();
-                $this->em->clear($entry);
+
+                // clear only affected entities
+                $this->em->clear(Entry::class);
+                $this->em->clear(Tag::class);
             }
             ++$i;
         }