From fb4d02c69b46ef0e352ab7d67b60f3e9721bd0d0 Mon Sep 17 00:00:00 2001 From: bilouwan Date: Fri, 4 Dec 2015 14:49:01 +0100 Subject: [PATCH] Refactor testing Proxy not initilized --- lib/Doctrine/ORM/UnitOfWork.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index ff9c1fd4c..faa6650e2 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1866,7 +1866,7 @@ class UnitOfWork implements PropertyChangedListener } } - if ($class->isVersioned && !($this->isNotInitializedProxy($managedCopy) || $this->isNotInitializedProxy($entity))) { + if ($class->isVersioned && $this->isLoaded($managedCopy) && $this->isLoaded($entity)) { $reflField = $class->reflFields[$class->versionField]; $managedCopyVersion = $reflField->getValue($managedCopy); $entityVersion = $reflField->getValue($entity); @@ -1879,7 +1879,7 @@ class UnitOfWork implements PropertyChangedListener $visited[$oid] = $managedCopy; // mark visited - if (!($entity instanceof Proxy && ! $entity->__isInitialized())) { + if ($this->isLoaded($entity)) { if ($managedCopy instanceof Proxy && ! $managedCopy->__isInitialized()) { $managedCopy->__load(); } @@ -1905,15 +1905,15 @@ class UnitOfWork implements PropertyChangedListener } /** - * Tests if an entity is a non initialized proxy class + * Tests if an entity is loaded (Not a proxy or a non initialized proxy) * * @param $entity * * @return bool */ - private function isNotInitializedProxy($entity) + private function isLoaded($entity) { - return $entity instanceof Proxy && !$entity->__isInitialized(); + return !($entity instanceof Proxy) || $entity->__isInitialized(); } /**