Skip to content

Commit 9054224

Browse files
committed
Not enabling native lazy objects on PHP 8.4+ is deprecated since Doctrine ORM v3.5
1 parent be1ff47 commit 9054224

File tree

5 files changed

+57
-12
lines changed

5 files changed

+57
-12
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"ext-iconv": "*",
1212
"ext-pdo_sqlite": "*",
1313
"doctrine/dbal": "^4.0",
14-
"doctrine/doctrine-bundle": "^2.11",
14+
"doctrine/doctrine-bundle": "^2.16",
1515
"doctrine/doctrine-migrations-bundle": "^3.3",
16-
"doctrine/orm": "^3.0",
16+
"doctrine/orm": "^3.5",
1717
"league/commonmark": "^2.1",
1818
"symfony/apache-pack": "^1.0",
1919
"symfony/asset": "^7",

composer.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/packages/doctrine.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
4+
5+
return static function (ContainerConfigurator $container): void {
6+
$container->extension('doctrine', [
7+
'orm' => [
8+
'enable_native_lazy_objects' => \PHP_VERSION_ID >= 80400,
9+
],
10+
]);
11+
};

config/packages/doctrine.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ doctrine:
88

99
profiling_collect_backtrace: '%kernel.debug%'
1010
use_savepoints: true
11+
1112
orm:
1213
auto_generate_proxy_classes: true
13-
enable_lazy_ghost_objects: true
1414
report_fields_where_declared: true
1515
validate_xml_mapping: true
1616
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
1717
identity_generation_preferences:
1818
Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity
19+
1920
auto_mapping: true
2021
mappings:
2122
App:
@@ -24,6 +25,7 @@ doctrine:
2425
dir: '%kernel.project_dir%/src/Entity'
2526
prefix: 'App\Entity'
2627
alias: App
28+
2729
controller_resolver:
2830
auto_mapping: false
2931

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace App\Tests\Doctrine\ORM;
13+
14+
use Doctrine\ORM\Configuration;
15+
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
16+
17+
class ConfigurationTest extends KernelTestCase
18+
{
19+
private function getConfiguration(): Configuration
20+
{
21+
return static::getContainer()->get('doctrine.orm.default_configuration');
22+
}
23+
24+
public function testNativeLazyObjectsSetting(): void
25+
{
26+
if (\PHP_VERSION_ID >= 80400) {
27+
$this->assertTrue($this->getConfiguration()->isNativeLazyObjectsEnabled());
28+
} else {
29+
$this->assertFalse($this->getConfiguration()->isNativeLazyObjectsEnabled());
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)