From cd18a3c13ad4e6362899375b7efbeaf08cfebe71 Mon Sep 17 00:00:00 2001 From: holtkamp Date: Fri, 30 Aug 2013 15:51:10 +0200 Subject: [PATCH] Made EntityManager flush operation Entity specific I encountered weird behavior where Entities were flushed to the database when I never intended to. It appeared I indicated the session to write and close at the end of PHP execution cycle. Because the EntityManager in the Doctrine Session SaveHandler, performs a general flush, all Entities are flushed, not only the Session Entity. --- lib/Pike/Session/SaveHandler/Doctrine.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Pike/Session/SaveHandler/Doctrine.php b/lib/Pike/Session/SaveHandler/Doctrine.php index 2a5b7e6..81a90c4 100644 --- a/lib/Pike/Session/SaveHandler/Doctrine.php +++ b/lib/Pike/Session/SaveHandler/Doctrine.php @@ -161,7 +161,7 @@ public function read($id) $return = $entity->getData(); } else { self::$em->remove($entity); - self::$em->flush(); + self::$em->flush($this->_entityName); } } @@ -186,7 +186,7 @@ public function write($id, $data) $entity->setModified(new DateTime('now')); self::$em->persist($entity); - self::$em->flush(); + self::$em->flush($this->_entityName); return true; } @@ -203,7 +203,7 @@ public function destroy($id) if ($entity instanceof Pike_Session_Entity_Interface) { self::$em->remove($entity); - self::$em->flush(); + self::$em->flush($this->_entityName); return true; } @@ -232,4 +232,4 @@ public function gc($maxlifetime) return true; } -} \ No newline at end of file +}