From 1b3795551172a33208ad38e33fbb9c2ed6068e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Tvrd=C3=ADk?= Date: Wed, 9 Aug 2023 10:28:57 +0200 Subject: [PATCH] ProxyFactory: do not generate long file names --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 4 ++-- tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 0660c423f0d..1e3f0cfbce0 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -432,8 +432,8 @@ private function getProxyFileName(string $className, string $baseDirectory): str { $baseDirectory = $baseDirectory ?: $this->proxyDir; - return rtrim($baseDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . InternalProxy::MARKER - . str_replace('\\', '', $className) . '.php'; + return rtrim($baseDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . InternalProxy::MARKER . DIRECTORY_SEPARATOR + . str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php'; } private function getProxyFactory(string $className): Closure diff --git a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php index c0b147dfc56..12ff915c2f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php @@ -235,7 +235,8 @@ public function testCommonPersistenceProxy(): void $restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), '', get_class($entity)); $restName = substr(get_class($entity), strlen($this->_em->getConfiguration()->getProxyNamespace()) + 1); - $proxyFileName = $this->_em->getConfiguration()->getProxyDir() . DIRECTORY_SEPARATOR . str_replace('\\', '', $restName) . '.php'; + $separator = $this->_em->getConfiguration()->isLazyGhostObjectEnabled() ? DIRECTORY_SEPARATOR : ''; + $proxyFileName = $this->_em->getConfiguration()->getProxyDir() . DIRECTORY_SEPARATOR . str_replace('\\', $separator, $restName) . '.php'; self::assertTrue(file_exists($proxyFileName), 'Proxy file name cannot be found generically.'); $entity->__load();