Skip to content

Commit 16efeac

Browse files
committed
[Tests] Configure doctrine.orm.enable_native_lazy_objects to fix deprecation in PHP 8.4+
Fix https://github.com/symfony/ux/actions/runs/15787680645/job/44507502967?pr=2712
1 parent 7cb2a5b commit 16efeac

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Autocomplete/tests/Fixtures/Kernel.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\UX\Autocomplete\Tests\Fixtures;
1313

14+
use Composer\InstalledVersions;
1415
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
1516
use Doctrine\ORM\Mapping\AssociationMapping;
1617
use Fixtures\Form\CategoryWithCallbackAsCustomValue;
@@ -104,7 +105,7 @@ protected function configureContainer(ContainerConfigurator $c): void
104105
'auto_refresh_proxies' => false,
105106
]);
106107

107-
$config = [
108+
$doctrineConfig = [
108109
'dbal' => ['url' => '%env(resolve:DATABASE_URL)%'],
109110
'orm' => [
110111
'auto_generate_proxy_classes' => true,
@@ -122,11 +123,17 @@ protected function configureContainer(ContainerConfigurator $c): void
122123
];
123124
if (class_exists(AssociationMapping::class)) {
124125
// Doctrine ORM >= 3.0
125-
$config['orm']['controller_resolver'] = [
126+
$doctrineConfig['orm']['controller_resolver'] = [
126127
'auto_mapping' => true,
127128
];
128129
}
129-
$c->extension('doctrine', $config);
130+
if (null !== $doctrineBundleVersion = InstalledVersions::getVersion('doctrine/doctrine-bundle')) {
131+
if (\PHP_VERSION_ID >= 80400 && version_compare($doctrineBundleVersion, '2.15.0', '>=')) {
132+
$doctrineConfig['orm']['enable_native_lazy_objects'] = true;
133+
}
134+
}
135+
136+
$c->extension('doctrine', $doctrineConfig);
130137

131138
$c->extension('security', [
132139
'password_hashers' => [

src/LiveComponent/tests/Fixtures/Kernel.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ protected function configureContainer(ContainerConfigurator $c): void
186186
if (version_compare($doctrineBundleVersion, '2.12.0', '>=')) {
187187
$doctrineConfig['orm']['controller_resolver']['auto_mapping'] = false;
188188
}
189+
if (\PHP_VERSION_ID >= 80400 && version_compare($doctrineBundleVersion, '2.15.0', '>=')) {
190+
$doctrineConfig['orm']['enable_native_lazy_objects'] = true;
191+
}
189192
}
190193

191194
$c->extension('doctrine', $doctrineConfig);

0 commit comments

Comments
 (0)