From 9fe3b63a1d0db6a4cb308444b6d663bea5acefec Mon Sep 17 00:00:00 2001 From: Aleksey Polyvanyi Date: Tue, 26 Nov 2024 17:41:24 +0100 Subject: [PATCH] Use `kernel.build_dir` by default for proxy dir and metadata cache (#1843) --- src/DependencyInjection/Configuration.php | 2 +- src/DependencyInjection/DoctrineExtension.php | 2 +- tests/CacheSchemaSubscriberTest.php | 2 +- tests/DependencyInjection/AbstractDoctrineExtensionTest.php | 1 + tests/DependencyInjection/Compiler/IdGeneratorPassTest.php | 2 +- tests/DependencyInjection/DoctrineExtensionTest.php | 5 +++-- tests/DependencyInjection/Fixtures/config/xml/orm_proxy.xml | 2 +- tests/LockStoreSchemaListenerTest.php | 2 +- tests/ServiceRepositoryTest.php | 2 +- tests/TestCase.php | 1 + 10 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 04a38b277..ebc833dad 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -511,7 +511,7 @@ private function addOrmSection(ArrayNodeDefinition $node): void ->defaultValue(! method_exists(ProxyFactory::class, 'resetUninitializedProxy')) ->info('Enables the new implementation of proxies based on lazy ghosts instead of using the legacy implementation') ->end() - ->scalarNode('proxy_dir')->defaultValue('%kernel.cache_dir%/doctrine/orm/Proxies')->end() + ->scalarNode('proxy_dir')->defaultValue('%kernel.build_dir%/doctrine/orm/Proxies')->end() ->scalarNode('proxy_namespace')->defaultValue('Proxies')->end() ->arrayNode('controller_resolver') ->canBeDisabled() diff --git a/src/DependencyInjection/DoctrineExtension.php b/src/DependencyInjection/DoctrineExtension.php index feab52407..de74334c9 100644 --- a/src/DependencyInjection/DoctrineExtension.php +++ b/src/DependencyInjection/DoctrineExtension.php @@ -1115,7 +1115,7 @@ private function createMetadataCache(string $objectManagerName, ContainerBuilder $cache = new Definition(ArrayAdapter::class); if (! $container->getParameter('kernel.debug')) { - $phpArrayFile = '%kernel.cache_dir%' . sprintf('/doctrine/orm/%s_metadata.php', $objectManagerName); + $phpArrayFile = '%kernel.build_dir%' . sprintf('/doctrine/orm/%s_metadata.php', $objectManagerName); $cacheWarmerServiceId = $this->getObjectManagerElementName(sprintf('%s_%s', $objectManagerName, 'metadata_cache_warmer')); $container->register($cacheWarmerServiceId, DoctrineMetadataCacheWarmer::class) diff --git a/tests/CacheSchemaSubscriberTest.php b/tests/CacheSchemaSubscriberTest.php index 22bcc169a..22c7d6a88 100644 --- a/tests/CacheSchemaSubscriberTest.php +++ b/tests/CacheSchemaSubscriberTest.php @@ -39,9 +39,9 @@ public function testSchemaSubscriberWiring(string $adapterId, string $subscriber 'kernel.debug' => false, 'kernel.bundles' => [], 'kernel.cache_dir' => sys_get_temp_dir(), + 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.runtime_environment' => '%%env(default:kernel.environment:APP_RUNTIME_ENV)%%', - 'kernel.build_dir' => __DIR__ . '/../../../../', // src dir 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir 'kernel.bundles_metadata' => [], diff --git a/tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/tests/DependencyInjection/AbstractDoctrineExtensionTest.php index 7346b724b..26d72a2e3 100644 --- a/tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -1504,6 +1504,7 @@ private function getContainer(array $bundles): ContainerBuilder 'kernel.debug' => false, 'kernel.bundles' => $map, 'kernel.cache_dir' => sys_get_temp_dir(), + 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.root_dir' => __DIR__ . '/../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../', // src dir diff --git a/tests/DependencyInjection/Compiler/IdGeneratorPassTest.php b/tests/DependencyInjection/Compiler/IdGeneratorPassTest.php index f83cf7252..f5fd9c996 100644 --- a/tests/DependencyInjection/Compiler/IdGeneratorPassTest.php +++ b/tests/DependencyInjection/Compiler/IdGeneratorPassTest.php @@ -69,9 +69,9 @@ public function testRepositoryServiceWiring(): void 'kernel.debug' => false, 'kernel.bundles' => $bundles, 'kernel.cache_dir' => sys_get_temp_dir(), + 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.runtime_environment' => '%%env(default:kernel.environment:APP_RUNTIME_ENV)%%', - 'kernel.build_dir' => __DIR__ . '/../../../../', // src dir 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir 'kernel.bundles_metadata' => [], diff --git a/tests/DependencyInjection/DoctrineExtensionTest.php b/tests/DependencyInjection/DoctrineExtensionTest.php index c3d25d8cd..7ebce4621 100644 --- a/tests/DependencyInjection/DoctrineExtensionTest.php +++ b/tests/DependencyInjection/DoctrineExtensionTest.php @@ -519,7 +519,7 @@ public function testDependencyInjectionConfigurationDefaults(): void $this->assertEquals( [ new Reference('doctrine.orm.default_entity_manager'), - '%kernel.cache_dir%/doctrine/orm/default_metadata.php', + '%kernel.build_dir%/doctrine/orm/default_metadata.php', ], $definition->getArguments(), ); @@ -528,7 +528,7 @@ public function testDependencyInjectionConfigurationDefaults(): void $this->assertEquals(PhpArrayAdapter::class, $definition->getClass()); $arguments = $definition->getArguments(); - $this->assertSame('%kernel.cache_dir%/doctrine/orm/default_metadata.php', $arguments[0]); + $this->assertSame('%kernel.build_dir%/doctrine/orm/default_metadata.php', $arguments[0]); $wrappedDefinition = $arguments[1]; $this->assertSame(ArrayAdapter::class, $wrappedDefinition->getClass()); @@ -1506,6 +1506,7 @@ private static function getContainer(array $bundles = ['YamlBundle'], string $ve 'kernel.bundles' => $map, 'kernel.bundles_metadata' => $metadataMap, 'kernel.cache_dir' => sys_get_temp_dir(), + 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.root_dir' => __DIR__ . '/../../', // src dir ])); diff --git a/tests/DependencyInjection/Fixtures/config/xml/orm_proxy.xml b/tests/DependencyInjection/Fixtures/config/xml/orm_proxy.xml index 96208ddb8..a4410da97 100644 --- a/tests/DependencyInjection/Fixtures/config/xml/orm_proxy.xml +++ b/tests/DependencyInjection/Fixtures/config/xml/orm_proxy.xml @@ -7,6 +7,6 @@ http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> - + diff --git a/tests/LockStoreSchemaListenerTest.php b/tests/LockStoreSchemaListenerTest.php index 93f4a182d..142645a56 100644 --- a/tests/LockStoreSchemaListenerTest.php +++ b/tests/LockStoreSchemaListenerTest.php @@ -37,9 +37,9 @@ public function testLockStoreSchemaSubscriberWiring(array $config, int $expected 'kernel.debug' => false, 'kernel.bundles' => [], 'kernel.cache_dir' => sys_get_temp_dir(), + 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.runtime_environment' => '%%env(default:kernel.environment:APP_RUNTIME_ENV)%%', - 'kernel.build_dir' => __DIR__ . '/../../../../', // src dir 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir 'kernel.bundles_metadata' => [], diff --git a/tests/ServiceRepositoryTest.php b/tests/ServiceRepositoryTest.php index e064f5a04..94121b6e6 100644 --- a/tests/ServiceRepositoryTest.php +++ b/tests/ServiceRepositoryTest.php @@ -49,9 +49,9 @@ public function testRepositoryServiceWiring(): void 'kernel.debug' => false, 'kernel.bundles' => ['RepositoryServiceBundle' => RepositoryServiceBundle::class], 'kernel.cache_dir' => sys_get_temp_dir(), + 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.runtime_environment' => '%%env(default:kernel.environment:APP_RUNTIME_ENV)%%', - 'kernel.build_dir' => __DIR__ . '/../../../../', // src dir 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir 'kernel.bundles_metadata' => [], diff --git a/tests/TestCase.php b/tests/TestCase.php index 770340796..c59570403 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -26,6 +26,7 @@ public function createXmlBundleTestContainer(): ContainerBuilder 'kernel.debug' => false, 'kernel.bundles' => ['XmlBundle' => 'Fixtures\Bundles\XmlBundle\XmlBundle'], 'kernel.cache_dir' => sys_get_temp_dir(), + 'kernel.build_dir' => sys_get_temp_dir(), 'kernel.environment' => 'test', 'kernel.root_dir' => __DIR__ . '/../../../../', // src dir 'kernel.project_dir' => __DIR__ . '/../../../../', // src dir