From 66d2b9e0fba22e6e6b524548ee8a9c2b6df76d08 Mon Sep 17 00:00:00 2001 From: Thiago Festa Date: Fri, 28 Oct 2011 17:54:15 -0200 Subject: [PATCH 1/2] The ProxyFactory was redeclaring methods serialize and unserialize on the cache file on some OSs. --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 490c3a11987..f9ed3640a1e 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -167,7 +167,7 @@ private function _generateMethods(ClassMetadata $class) foreach ($class->reflClass->getMethods() as $method) { /* @var $method ReflectionMethod */ - if ($method->isConstructor() || in_array(strtolower($method->getName()), array("__sleep", "__clone"))) { + if ($method->isConstructor() || in_array(strtolower($method->getName()), array("__sleep", "__clone")) || $class->reflClass->getName() != $method->class) { continue; } From 4571e498b4da9aaa24c27e0a7f4288bb2e182cb6 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 13 Nov 2011 17:16:43 +0100 Subject: [PATCH 2/2] DDC-1477 - Adjust patch to really fix bug in Proxy generation --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 6 ++++-- .../Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 0e37b3faca6..cf704854994 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -165,11 +165,13 @@ private function _generateMethods(ClassMetadata $class) { $methods = ''; + $methodNames = array(); foreach ($class->reflClass->getMethods() as $method) { /* @var $method ReflectionMethod */ - if ($method->isConstructor() || in_array(strtolower($method->getName()), array("__sleep", "__clone")) || $class->reflClass->getName() != $method->class) { + if ($method->isConstructor() || in_array(strtolower($method->getName()), array("__sleep", "__clone")) || isset($methodNames[$method->getName()])) { continue; } + $methodNames[$method->getName()] = true; if ($method->isPublic() && ! $method->isFinal() && ! $method->isStatic()) { $methods .= "\n" . ' public function '; @@ -234,7 +236,7 @@ private function _generateMethods(ClassMetadata $class) */ private function isShortIdentifierGetter($method, $class) { - $identifier = lcfirst(substr($method->getName(), 3)); + $identifier = lcfirst(substr($method->getName(), 3)); return ( $method->getNumberOfParameters() == 0 && substr($method->getName(), 0, 3) == "get" && diff --git a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php index bb324bf678d..f4439b9ad06 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php @@ -39,6 +39,7 @@ public function testCRUD() $cleanFile = $this->_em->find(get_class($file), $file->getId()); $this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $cleanFile->getParent()); $this->assertEquals($directory->getId(), $cleanFile->getParent()->getId()); $this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()->getParent()); $this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId());