From 90542240eb1f7994af4ba0d4ea14d1702844d244 Mon Sep 17 00:00:00 2001 From: Jan Rosier Date: Mon, 15 Sep 2025 19:59:12 +0200 Subject: [PATCH] Not enabling native lazy objects on PHP 8.4+ is deprecated since Doctrine ORM v3.5 --- composer.json | 4 +-- composer.lock | 18 ++++++------- config/packages/doctrine.php | 11 ++++++++ config/packages/doctrine.yaml | 4 ++- tests/Doctrine/ORM/ConfigurationTest.php | 32 ++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 config/packages/doctrine.php create mode 100644 tests/Doctrine/ORM/ConfigurationTest.php diff --git a/composer.json b/composer.json index 68db2db48..703a45423 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,9 @@ "ext-iconv": "*", "ext-pdo_sqlite": "*", "doctrine/dbal": "^4.0", - "doctrine/doctrine-bundle": "^2.11", + "doctrine/doctrine-bundle": "^2.16", "doctrine/doctrine-migrations-bundle": "^3.3", - "doctrine/orm": "^3.0", + "doctrine/orm": "^3.5", "league/commonmark": "^2.1", "symfony/apache-pack": "^1.0", "symfony/asset": "^7", diff --git a/composer.lock b/composer.lock index 3356fb2f7..29c6b7007 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "736f58aef66a37eeeb1f044a92e9dd87", + "content-hash": "368008d26768326c3f563acb6f6492ec", "packages": [ { "name": "composer/semver", @@ -404,16 +404,16 @@ }, { "name": "doctrine/doctrine-bundle", - "version": "2.15.1", + "version": "2.16.2", "source": { "type": "git", "url": "https://github.com/doctrine/DoctrineBundle.git", - "reference": "5a305c5e776f9d3eb87f5b94d40d50aff439211d" + "reference": "1c10de0fe995f01eca6b073d1c2549ef0b603a7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/5a305c5e776f9d3eb87f5b94d40d50aff439211d", - "reference": "5a305c5e776f9d3eb87f5b94d40d50aff439211d", + "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/1c10de0fe995f01eca6b073d1c2549ef0b603a7f", + "reference": "1c10de0fe995f01eca6b073d1c2549ef0b603a7f", "shasum": "" }, "require": { @@ -447,11 +447,11 @@ "phpstan/phpstan": "2.1.1", "phpstan/phpstan-phpunit": "2.0.3", "phpstan/phpstan-strict-rules": "^2", - "phpunit/phpunit": "^9.6.22", + "phpunit/phpunit": "^10.5.53", "psr/log": "^1.1.4 || ^2.0 || ^3.0", "symfony/doctrine-messenger": "^6.4 || ^7.0", + "symfony/expression-language": "^6.4 || ^7.0", "symfony/messenger": "^6.4 || ^7.0", - "symfony/phpunit-bridge": "^7.2", "symfony/property-info": "^6.4 || ^7.0", "symfony/security-bundle": "^6.4 || ^7.0", "symfony/stopwatch": "^6.4 || ^7.0", @@ -506,7 +506,7 @@ ], "support": { "issues": "https://github.com/doctrine/DoctrineBundle/issues", - "source": "https://github.com/doctrine/DoctrineBundle/tree/2.15.1" + "source": "https://github.com/doctrine/DoctrineBundle/tree/2.16.2" }, "funding": [ { @@ -522,7 +522,7 @@ "type": "tidelift" } ], - "time": "2025-07-30T15:48:28+00:00" + "time": "2025-09-10T19:14:48+00:00" }, { "name": "doctrine/doctrine-migrations-bundle", diff --git a/config/packages/doctrine.php b/config/packages/doctrine.php new file mode 100644 index 000000000..d8e1af611 --- /dev/null +++ b/config/packages/doctrine.php @@ -0,0 +1,11 @@ +extension('doctrine', [ + 'orm' => [ + 'enable_native_lazy_objects' => \PHP_VERSION_ID >= 80400, + ], + ]); +}; diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 25138b979..3a220dec3 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -8,14 +8,15 @@ doctrine: profiling_collect_backtrace: '%kernel.debug%' use_savepoints: true + orm: auto_generate_proxy_classes: true - enable_lazy_ghost_objects: true report_fields_where_declared: true validate_xml_mapping: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware identity_generation_preferences: Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity + auto_mapping: true mappings: App: @@ -24,6 +25,7 @@ doctrine: dir: '%kernel.project_dir%/src/Entity' prefix: 'App\Entity' alias: App + controller_resolver: auto_mapping: false diff --git a/tests/Doctrine/ORM/ConfigurationTest.php b/tests/Doctrine/ORM/ConfigurationTest.php new file mode 100644 index 000000000..6d8c90140 --- /dev/null +++ b/tests/Doctrine/ORM/ConfigurationTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace App\Tests\Doctrine\ORM; + +use Doctrine\ORM\Configuration; +use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; + +class ConfigurationTest extends KernelTestCase +{ + private function getConfiguration(): Configuration + { + return static::getContainer()->get('doctrine.orm.default_configuration'); + } + + public function testNativeLazyObjectsSetting(): void + { + if (\PHP_VERSION_ID >= 80400) { + $this->assertTrue($this->getConfiguration()->isNativeLazyObjectsEnabled()); + } else { + $this->assertFalse($this->getConfiguration()->isNativeLazyObjectsEnabled()); + } + } +}