From c28b457221c3b5a2e976f5145bf1ca5515ad87c1 Mon Sep 17 00:00:00 2001 From: Guilherme Blanco Date: Sun, 28 Jul 2013 20:30:42 -0400 Subject: [PATCH 1/2] Modified Hydrators to be per-query instances instead of a singleton-like approach. --- lib/Doctrine/ORM/AbstractQuery.php | 2 +- .../ORM/Decorator/EntityManagerDecorator.php | 8 ------ lib/Doctrine/ORM/EntityManager.php | 26 ------------------- lib/Doctrine/ORM/EntityManagerInterface.php | 1 - 4 files changed, 1 insertion(+), 36 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index b32310512a9..8c41a3b210b 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -787,7 +787,7 @@ public function execute($parameters = null, $hydrationMode = null) return $stmt; } - $data = $this->_em->getHydrator($this->_hydrationMode)->hydrateAll( + $data = $this->_em->newHydrator($this->_hydrationMode)->hydrateAll( $stmt, $this->_resultSetMapping, $this->_hints ); diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index dc123118f52..23097edac5c 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -221,14 +221,6 @@ public function getUnitOfWork() return $this->wrapped->getUnitOfWork(); } - /** - * {@inheritdoc} - */ - public function getHydrator($hydrationMode) - { - return $this->wrapped->getHydrator($hydrationMode); - } - /** * {@inheritdoc} */ diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index acaec984dae..220b9d31367 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -99,13 +99,6 @@ */ private $eventManager; - /** - * The maintained (cached) hydrators. One instance per type. - * - * @var array - */ - private $hydrators = array(); - /** * The proxy factory used to create dynamic proxies. * @@ -834,25 +827,6 @@ public function getUnitOfWork() return $this->unitOfWork; } - /** - * Gets a hydrator for the given hydration mode. - * - * This method caches the hydrator instances which is used for all queries that don't - * selectively iterate over the result. - * - * @param int $hydrationMode - * - * @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator - */ - public function getHydrator($hydrationMode) - { - if ( ! isset($this->hydrators[$hydrationMode])) { - $this->hydrators[$hydrationMode] = $this->newHydrator($hydrationMode); - } - - return $this->hydrators[$hydrationMode]; - } - /** * Create a new instance for the given hydration mode. * diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index d72f7cd0cf8..aa26e36abbe 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -51,7 +51,6 @@ public function getEventManager(); public function getConfiguration(); public function isOpen(); public function getUnitOfWork(); - public function getHydrator($hydrationMode); public function newHydrator($hydrationMode); public function getProxyFactory(); public function getFilters(); From 2dd73d4def895e7d8ff9db60180176ae92da0e82 Mon Sep 17 00:00:00 2001 From: Guilherme Blanco Date: Mon, 29 Jul 2013 10:46:47 -0400 Subject: [PATCH 2/2] Kept BC. --- .../ORM/Decorator/EntityManagerDecorator.php | 8 ++++++++ lib/Doctrine/ORM/EntityManager.php | 17 +++++++++++++++++ lib/Doctrine/ORM/EntityManagerInterface.php | 1 + 3 files changed, 26 insertions(+) diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php index 23097edac5c..dc123118f52 100644 --- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php +++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php @@ -221,6 +221,14 @@ public function getUnitOfWork() return $this->wrapped->getUnitOfWork(); } + /** + * {@inheritdoc} + */ + public function getHydrator($hydrationMode) + { + return $this->wrapped->getHydrator($hydrationMode); + } + /** * {@inheritdoc} */ diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 220b9d31367..d21d3fb86d3 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -827,6 +827,23 @@ public function getUnitOfWork() return $this->unitOfWork; } + /** + * Gets a hydrator for the given hydration mode. + * + * This method caches the hydrator instances which is used for all queries that don't + * selectively iterate over the result. + * + * @deprecated + * + * @param int $hydrationMode + * + * @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator + */ + public function getHydrator($hydrationMode) + { + return $this->newHydrator($hydrationMode); + } + /** * Create a new instance for the given hydration mode. * diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index aa26e36abbe..d72f7cd0cf8 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -51,6 +51,7 @@ public function getEventManager(); public function getConfiguration(); public function isOpen(); public function getUnitOfWork(); + public function getHydrator($hydrationMode); public function newHydrator($hydrationMode); public function getProxyFactory(); public function getFilters();