From 93fe7baf9ca9c0dc85e642fa23dc39ed2366d27d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:17:00 +0000 Subject: [PATCH 1/5] Initial plan From 913c7cc4ca7bc60705a98563d07f2f2cc3b6d0c4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:19:58 +0000 Subject: [PATCH 2/5] feat: upgrade to Doctrine ORM 3.6 and DoctrineBundle 3.0 Co-authored-by: ambroisemaupate <380026+ambroisemaupate@users.noreply.github.com> --- composer.json | 4 ++-- config/packages/doctrine.yaml | 3 +++ lib/Documents/composer.json | 4 ++-- lib/Models/composer.json | 4 ++-- lib/RoadizCoreBundle/composer.json | 4 ++-- lib/RoadizSolrBundle/composer.json | 2 +- lib/RoadizTwoFactorBundle/composer.json | 2 +- lib/RoadizUserBundle/composer.json | 2 +- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 026cbaab1..952330aa5 100644 --- a/composer.json +++ b/composer.json @@ -53,10 +53,10 @@ "composer/package-versions-deprecated": "1.11.99.3", "deeplcom/deepl-php": "^1.12", "doctrine/collections": ">=1.6", - "doctrine/doctrine-bundle": "^2.8.1", + "doctrine/doctrine-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^3.1", "doctrine/migrations": "^3.1.1", - "doctrine/orm": "~2.20.0", + "doctrine/orm": "^3.6", "dragonmantank/cron-expression": "^3.4", "endroid/qr-code": "^4.0", "enshrined/svg-sanitize": "^0.22", diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 84f7975bb..e61dd0cce 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -101,6 +101,9 @@ when@prod: orm: auto_generate_proxy_classes: false proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies' + metadata_cache_driver: + type: pool + pool: doctrine.system_cache_pool query_cache_driver: type: pool pool: doctrine.system_cache_pool diff --git a/lib/Documents/composer.json b/lib/Documents/composer.json index 44bfb1ec1..efe6654f8 100644 --- a/lib/Documents/composer.json +++ b/lib/Documents/composer.json @@ -25,7 +25,7 @@ "ext-zip": "*", "ext-simplexml": "*", "ext-fileinfo": "*", - "doctrine/orm": "~2.20.0", + "doctrine/orm": "^3.6", "enshrined/svg-sanitize": "^0.22", "intervention/image": "^3.11", "league/flysystem": "^3.0", @@ -43,7 +43,7 @@ }, "require-dev": { "api-platform/metadata": "^4.1.18", - "doctrine/doctrine-bundle": "^2.8.1", + "doctrine/doctrine-bundle": "^3.0", "php-coveralls/php-coveralls": "^2.4", "phpstan/phpstan": "^2.1.36", "phpstan/phpdoc-parser": "<2", diff --git a/lib/Models/composer.json b/lib/Models/composer.json index b063a894a..efb4da332 100644 --- a/lib/Models/composer.json +++ b/lib/Models/composer.json @@ -19,7 +19,7 @@ ], "require": { "php": ">=8.3", - "doctrine/orm": "~2.20.0", + "doctrine/orm": "^3.6", "api-platform/doctrine-orm": "^4.1.18", "api-platform/metadata": "^4.1.18", "roadiz/nodetype-contracts": "^3.1.1", @@ -31,7 +31,7 @@ "symfony/validator": "7.4.*" }, "require-dev": { - "doctrine/doctrine-bundle": "^2.8.1", + "doctrine/doctrine-bundle": "^3.0", "php-coveralls/php-coveralls": "^2.4", "phpstan/phpstan": "^2.1.36", "phpstan/phpdoc-parser": "<2", diff --git a/lib/RoadizCoreBundle/composer.json b/lib/RoadizCoreBundle/composer.json index 48b1593da..be4ee4165 100644 --- a/lib/RoadizCoreBundle/composer.json +++ b/lib/RoadizCoreBundle/composer.json @@ -26,9 +26,9 @@ "ext-mbstring": "*", "api-platform/doctrine-orm": "^4.1.18", "api-platform/symfony": "^4.1.18", - "doctrine/doctrine-bundle": "^2.8.1", + "doctrine/doctrine-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^3.1", - "doctrine/orm": "~2.20.0", + "doctrine/orm": "^3.6", "dragonmantank/cron-expression": "^3.4", "gedmo/doctrine-extensions": "^3.19.0", "inlinestyle/inlinestyle": "~1.2.7", diff --git a/lib/RoadizSolrBundle/composer.json b/lib/RoadizSolrBundle/composer.json index fc60f8aee..1b6837c3f 100644 --- a/lib/RoadizSolrBundle/composer.json +++ b/lib/RoadizSolrBundle/composer.json @@ -25,7 +25,7 @@ "ext-zip": "*", "ext-json": "*", "ext-mbstring": "*", - "doctrine/orm": "~2.20.0", + "doctrine/orm": "^3.6", "nelmio/solarium-bundle": "^5.1", "roadiz/core-bundle": "2.8.x-dev", "roadiz/documents": "2.8.x-dev", diff --git a/lib/RoadizTwoFactorBundle/composer.json b/lib/RoadizTwoFactorBundle/composer.json index 263de9b96..4a978cdf1 100644 --- a/lib/RoadizTwoFactorBundle/composer.json +++ b/lib/RoadizTwoFactorBundle/composer.json @@ -21,7 +21,7 @@ "prefer-stable": true, "require": { "php": ">=8.3", - "doctrine/orm": "~2.20.0", + "doctrine/orm": "^3.6", "endroid/qr-code": "^4.0", "roadiz/core-bundle": "2.8.x-dev", "roadiz/rozier-bundle": "2.8.x-dev", diff --git a/lib/RoadizUserBundle/composer.json b/lib/RoadizUserBundle/composer.json index 8ff1479f8..0df629f86 100644 --- a/lib/RoadizUserBundle/composer.json +++ b/lib/RoadizUserBundle/composer.json @@ -21,7 +21,7 @@ "require": { "php": ">=8.3", "api-platform/symfony": "^4.1.18", - "doctrine/orm": "~2.20.0", + "doctrine/orm": "^3.6", "roadiz/core-bundle": "2.8.x-dev", "roadiz/models": "2.8.x-dev", "symfony/framework-bundle": "7.4.*", From 890077e3055e682644801562e2a7619b36eb2c2c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:28:10 +0000 Subject: [PATCH 3/5] docs: add Doctrine ORM 3.x upgrade documentation Co-authored-by: ambroisemaupate <380026+ambroisemaupate@users.noreply.github.com> --- UPGRADE.md | 53 ++++++++++++++++++++++++++++++ composer.json | 2 +- lib/Documents/composer.json | 2 +- lib/Models/composer.json | 2 +- lib/RoadizCoreBundle/composer.json | 2 +- 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 58d0fe863..9d687a479 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,58 @@ # Upgrade to 2.8 +## ⚠ Doctrine ORM 3.x Upgrade + +Roadiz has been upgraded from **Doctrine ORM 2.20** to **Doctrine ORM 3.6**, bringing performance improvements and better maintainability. This is a major internal upgrade with the following changes: + +### What Changed + +- **Doctrine ORM**: Upgraded from `~2.20.0` to `^3.6` +- **Doctrine DBAL**: Automatically upgraded to `^3.0` (ORM 3 dependency) +- **DoctrineBundle**: Remains at `^2.12` (supports both ORM 2.x and 3.x, PHP 8.3 compatible) + +### Breaking Changes + +⚠️ **None for standard Roadiz usage** - All deprecated APIs were already removed or avoided in Roadiz codebase: + +- ✅ No `EntityManager::merge()` usage +- ✅ No cascade merge definitions +- ✅ All entities use PHP 8 attributes (not annotations) +- ✅ No YAML mappings +- ✅ No partial flush usage +- ✅ Lazy ghost objects already enabled + +### Configuration Changes + +The Doctrine configuration in `config/packages/doctrine.yaml` now includes `metadata_cache_driver` for the production environment to optimize metadata caching with ORM 3. + +### For Custom Code + +If you have custom code in your project that extends Roadiz: + +1. **Check for `merge()` usage**: ORM 3 removed `EntityManager::merge()`. Use explicit load and update patterns instead. +2. **Check cascade definitions**: `cascade={"merge"}` is no longer supported. +3. **Review custom DQL queries**: Verify they still work correctly. +4. **Test lazy loading**: Verify proxy generation and lazy loading work as expected. + +### Migration Steps + +No migration steps required. The upgrade is transparent for standard Roadiz installations. + +### Testing + +After upgrading, verify: + +```bash +# Validate schema +php bin/console doctrine:schema:validate + +# Run migrations +php bin/console doctrine:migrations:migrate + +# Clear caches +php bin/console cache:clear +``` + ## ⚠ Twig Breaking changes For twig templates using `@RoadizRozier/admin/base.html.twig` as parent template, make sure to update - `content_title` diff --git a/composer.json b/composer.json index 952330aa5..1ec26bdbf 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "composer/package-versions-deprecated": "1.11.99.3", "deeplcom/deepl-php": "^1.12", "doctrine/collections": ">=1.6", - "doctrine/doctrine-bundle": "^3.0", + "doctrine/doctrine-bundle": "^2.12", "doctrine/doctrine-migrations-bundle": "^3.1", "doctrine/migrations": "^3.1.1", "doctrine/orm": "^3.6", diff --git a/lib/Documents/composer.json b/lib/Documents/composer.json index efe6654f8..4ef442728 100644 --- a/lib/Documents/composer.json +++ b/lib/Documents/composer.json @@ -43,7 +43,7 @@ }, "require-dev": { "api-platform/metadata": "^4.1.18", - "doctrine/doctrine-bundle": "^3.0", + "doctrine/doctrine-bundle": "^2.12", "php-coveralls/php-coveralls": "^2.4", "phpstan/phpstan": "^2.1.36", "phpstan/phpdoc-parser": "<2", diff --git a/lib/Models/composer.json b/lib/Models/composer.json index efb4da332..edd6c14df 100644 --- a/lib/Models/composer.json +++ b/lib/Models/composer.json @@ -31,7 +31,7 @@ "symfony/validator": "7.4.*" }, "require-dev": { - "doctrine/doctrine-bundle": "^3.0", + "doctrine/doctrine-bundle": "^2.12", "php-coveralls/php-coveralls": "^2.4", "phpstan/phpstan": "^2.1.36", "phpstan/phpdoc-parser": "<2", diff --git a/lib/RoadizCoreBundle/composer.json b/lib/RoadizCoreBundle/composer.json index be4ee4165..66bb14c2d 100644 --- a/lib/RoadizCoreBundle/composer.json +++ b/lib/RoadizCoreBundle/composer.json @@ -26,7 +26,7 @@ "ext-mbstring": "*", "api-platform/doctrine-orm": "^4.1.18", "api-platform/symfony": "^4.1.18", - "doctrine/doctrine-bundle": "^3.0", + "doctrine/doctrine-bundle": "^2.12", "doctrine/doctrine-migrations-bundle": "^3.1", "doctrine/orm": "^3.6", "dragonmantank/cron-expression": "^3.4", From 3f2dfcff52f0fdd5fb4c0858279e842d75d23aab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:48:55 +0000 Subject: [PATCH 4/5] fix: remove HINT_FORCE_PARTIAL_LOAD for ORM 3.0 compatibility - Remove deprecated HINT_FORCE_PARTIAL_LOAD from LogRepository - Remove deprecated HINT_FORCE_PARTIAL_LOAD from TagRepository - Remove deprecated HINT_FORCE_PARTIAL_LOAD from OptimizedNodesSourcesGraphPathAggregator - Add doctrine:migrations:sync-metadata-storage to upgrade steps - Update UPGRADE.md to document partial objects removal Co-authored-by: ambroisemaupate <380026+ambroisemaupate@users.noreply.github.com> --- UPGRADE.md | 8 +++++++- lib/RoadizCoreBundle/src/Repository/LogRepository.php | 1 - lib/RoadizCoreBundle/src/Repository/TagRepository.php | 1 - .../Routing/OptimizedNodesSourcesGraphPathAggregator.php | 1 - 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 9d687a479..0a4c5ab44 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -12,8 +12,11 @@ Roadiz has been upgraded from **Doctrine ORM 2.20** to **Doctrine ORM 3.6**, bri ### Breaking Changes -⚠️ **None for standard Roadiz usage** - All deprecated APIs were already removed or avoided in Roadiz codebase: +⚠️ **Internal changes only** - The following deprecated APIs were removed from Roadiz codebase: +- ✅ Removed `HINT_FORCE_PARTIAL_LOAD` query hint (removed in ORM 3.0) + - Affected files: `LogRepository`, `TagRepository`, `OptimizedNodesSourcesGraphPathAggregator` + - This hint is no longer needed as ORM 3.0 properly handles scalar and array results - ✅ No `EntityManager::merge()` usage - ✅ No cascade merge definitions - ✅ All entities use PHP 8 attributes (not annotations) @@ -46,6 +49,9 @@ After upgrading, verify: # Validate schema php bin/console doctrine:schema:validate +# Sync migrations metadata storage (required for ORM 3) +php bin/console doctrine:migrations:sync-metadata-storage + # Run migrations php bin/console doctrine:migrations:migrate diff --git a/lib/RoadizCoreBundle/src/Repository/LogRepository.php b/lib/RoadizCoreBundle/src/Repository/LogRepository.php index cfa0488c9..b5e45e605 100644 --- a/lib/RoadizCoreBundle/src/Repository/LogRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/LogRepository.php @@ -43,7 +43,6 @@ public function findLatestByNodesSources(int $maxResult = 5): Paginator ->setMaxResults($maxResult) ; $ids = $qb->getQuery() - ->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) ->getScalarResult(); $qb2 = $this->createQueryBuilder('log'); diff --git a/lib/RoadizCoreBundle/src/Repository/TagRepository.php b/lib/RoadizCoreBundle/src/Repository/TagRepository.php index d99f88a7e..7277935bc 100644 --- a/lib/RoadizCoreBundle/src/Repository/TagRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/TagRepository.php @@ -480,7 +480,6 @@ public function findAllLinkedToNodeChildren(Node $parentNode, ?TranslationInterf } return $qb->getQuery() - ->setHint(\Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD, true) ->getResult() ; } diff --git a/lib/RoadizCoreBundle/src/Routing/OptimizedNodesSourcesGraphPathAggregator.php b/lib/RoadizCoreBundle/src/Routing/OptimizedNodesSourcesGraphPathAggregator.php index d27e8c7fe..19ba0d683 100644 --- a/lib/RoadizCoreBundle/src/Routing/OptimizedNodesSourcesGraphPathAggregator.php +++ b/lib/RoadizCoreBundle/src/Routing/OptimizedNodesSourcesGraphPathAggregator.php @@ -89,7 +89,6 @@ private function getIdentifiers(NodesSources $source): array 'translation' => $source->getTranslation(), ]) ->getQuery() - ->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) ->setCacheable(true) ->getArrayResult() ; From de9325b4beb464a2a166f86e0c132f49d952d3e3 Mon Sep 17 00:00:00 2001 From: eliot lauger Date: Thu, 19 Feb 2026 16:26:58 +0100 Subject: [PATCH 5/5] feat(orm): upgrade to Doctrine ORM 3.6 and adjust cascade settings --- config/packages/doctrine.yaml | 2 ++ .../NodesSourcesInheritanceSubscriber.php | 6 +++--- lib/RoadizCoreBundle/src/Entity/Attribute.php | 2 +- lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php | 4 ++-- lib/RoadizCoreBundle/src/Entity/Document.php | 1 - lib/RoadizCoreBundle/src/Entity/Setting.php | 2 +- lib/RoadizCoreBundle/src/Entity/Tag.php | 2 +- lib/RoadizCoreBundle/src/Entity/TagTranslation.php | 2 +- .../src/Entity/TagTranslationDocuments.php | 4 ++-- .../src/EntityHandler/TranslationHandler.php | 10 +--------- .../src/EventSubscriber/TranslationSubscriber.php | 8 ++------ lib/RoadizCoreBundle/src/Importer/SettingsImporter.php | 6 +----- lib/RoadizCoreBundle/src/Model/AttributeTrait.php | 2 +- .../src/Controller/SettingController.php | 8 +++----- 14 files changed, 21 insertions(+), 38 deletions(-) diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index e61dd0cce..9fbb709bd 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -3,6 +3,8 @@ doctrine: url: '%env(resolve:DATABASE_URL)%' profiling_collect_backtrace: '%kernel.debug%' use_savepoints: true + types: + array: Doctrine\DBAL\Types\JsonType orm: auto_generate_proxy_classes: true default_entity_manager: default diff --git a/lib/RoadizCoreBundle/src/Doctrine/EventSubscriber/NodesSourcesInheritanceSubscriber.php b/lib/RoadizCoreBundle/src/Doctrine/EventSubscriber/NodesSourcesInheritanceSubscriber.php index 8363a2a49..6bb96d362 100644 --- a/lib/RoadizCoreBundle/src/Doctrine/EventSubscriber/NodesSourcesInheritanceSubscriber.php +++ b/lib/RoadizCoreBundle/src/Doctrine/EventSubscriber/NodesSourcesInheritanceSubscriber.php @@ -8,7 +8,7 @@ use Doctrine\ORM\Event\LoadClassMetadataEventArgs; use Doctrine\ORM\Event\PostLoadEventArgs; use Doctrine\ORM\Events; -use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\ORM\Mapping\ClassMetadata; use Psr\Log\LoggerInterface; use RZ\Roadiz\Contracts\NodeType\NodeTypeClassLocatorInterface; use RZ\Roadiz\Contracts\NodeType\NodeTypeFieldInterface; @@ -90,9 +90,9 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void ]; if (Configuration::INHERITANCE_TYPE_JOINED === $this->inheritanceType) { - $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_JOINED); + $metadata->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_JOINED); } elseif (Configuration::INHERITANCE_TYPE_SINGLE_TABLE === $this->inheritanceType) { - $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE); + $metadata->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE); /* * If inheritance type is single table, we need to set indexes on parent class: NodesSources */ diff --git a/lib/RoadizCoreBundle/src/Entity/Attribute.php b/lib/RoadizCoreBundle/src/Entity/Attribute.php index ec6ea25dd..33a285267 100644 --- a/lib/RoadizCoreBundle/src/Entity/Attribute.php +++ b/lib/RoadizCoreBundle/src/Entity/Attribute.php @@ -40,7 +40,7 @@ class Attribute implements AttributeInterface #[ORM\OneToMany( mappedBy: 'attribute', targetEntity: AttributeDocuments::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], orphanRemoval: true ), ORM\OrderBy(['position' => 'ASC']), diff --git a/lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php b/lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php index edd205bee..80cfd5df4 100644 --- a/lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php +++ b/lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php @@ -29,7 +29,7 @@ class AttributeDocuments implements PositionedInterface, PersistableInterface public function __construct( #[ORM\ManyToOne( targetEntity: Attribute::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], fetch: 'EAGER', inversedBy: 'attributeDocuments' ), @@ -43,7 +43,7 @@ public function __construct( protected Attribute $attribute, #[ORM\ManyToOne( targetEntity: Document::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], fetch: 'EAGER', inversedBy: 'attributeDocuments' ), diff --git a/lib/RoadizCoreBundle/src/Entity/Document.php b/lib/RoadizCoreBundle/src/Entity/Document.php index 8084a79fe..9dac69f50 100644 --- a/lib/RoadizCoreBundle/src/Entity/Document.php +++ b/lib/RoadizCoreBundle/src/Entity/Document.php @@ -206,7 +206,6 @@ class Document implements \Stringable, AdvancedDocumentInterface, HasThumbnailIn /** * @var Collection */ - #[ORM\JoinTable(name: 'documents_folders')] #[ORM\ManyToMany(targetEntity: Folder::class, mappedBy: 'documents')] #[SymfonySerializer\Ignore] protected Collection $folders; diff --git a/lib/RoadizCoreBundle/src/Entity/Setting.php b/lib/RoadizCoreBundle/src/Entity/Setting.php index b5dc3cbec..c0be81504 100644 --- a/lib/RoadizCoreBundle/src/Entity/Setting.php +++ b/lib/RoadizCoreBundle/src/Entity/Setting.php @@ -71,7 +71,7 @@ class Setting implements PersistableInterface #[ORM\ManyToOne( targetEntity: SettingGroup::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], inversedBy: 'settings' )] #[ORM\JoinColumn(name: 'setting_group_id', referencedColumnName: 'id', onDelete: 'SET NULL')] diff --git a/lib/RoadizCoreBundle/src/Entity/Tag.php b/lib/RoadizCoreBundle/src/Entity/Tag.php index 98cb30f51..daf38ef01 100644 --- a/lib/RoadizCoreBundle/src/Entity/Tag.php +++ b/lib/RoadizCoreBundle/src/Entity/Tag.php @@ -97,7 +97,7 @@ class Tag implements DateTimedInterface, LeafInterface, PersistableInterface, \S #[ORM\OneToMany( mappedBy: 'parent', targetEntity: Tag::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], orphanRemoval: true )] #[ORM\OrderBy(['position' => 'ASC'])] diff --git a/lib/RoadizCoreBundle/src/Entity/TagTranslation.php b/lib/RoadizCoreBundle/src/Entity/TagTranslation.php index 3ef58d7f2..08c1cf8f8 100644 --- a/lib/RoadizCoreBundle/src/Entity/TagTranslation.php +++ b/lib/RoadizCoreBundle/src/Entity/TagTranslation.php @@ -48,7 +48,7 @@ class TagTranslation implements PersistableInterface #[ORM\OneToMany( mappedBy: 'tagTranslation', targetEntity: TagTranslationDocuments::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], orphanRemoval: true )] #[ORM\OrderBy(['position' => 'ASC'])] diff --git a/lib/RoadizCoreBundle/src/Entity/TagTranslationDocuments.php b/lib/RoadizCoreBundle/src/Entity/TagTranslationDocuments.php index a6a2d5164..ce49fd106 100644 --- a/lib/RoadizCoreBundle/src/Entity/TagTranslationDocuments.php +++ b/lib/RoadizCoreBundle/src/Entity/TagTranslationDocuments.php @@ -32,7 +32,7 @@ class TagTranslationDocuments implements PositionedInterface, PersistableInterfa public function __construct( #[ORM\ManyToOne( targetEntity: TagTranslation::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], fetch: 'EAGER', inversedBy: 'tagTranslationDocuments' )] @@ -41,7 +41,7 @@ public function __construct( protected TagTranslation $tagTranslation, #[ORM\ManyToOne( targetEntity: Document::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], fetch: 'EAGER', inversedBy: 'tagTranslations' )] diff --git a/lib/RoadizCoreBundle/src/EntityHandler/TranslationHandler.php b/lib/RoadizCoreBundle/src/EntityHandler/TranslationHandler.php index 92e8b917d..9f0a328ba 100644 --- a/lib/RoadizCoreBundle/src/EntityHandler/TranslationHandler.php +++ b/lib/RoadizCoreBundle/src/EntityHandler/TranslationHandler.php @@ -4,12 +4,10 @@ namespace RZ\Roadiz\CoreBundle\EntityHandler; -use Doctrine\Common\Cache\FlushableCache; use Doctrine\ORM\EntityManagerInterface; use RZ\Roadiz\Core\AbstractEntities\TranslationInterface; use RZ\Roadiz\Core\Handlers\AbstractHandler; use RZ\Roadiz\CoreBundle\Entity\Translation; -use Symfony\Component\Cache\ResettableInterface; /** * Handle operations with translations entities. @@ -48,13 +46,7 @@ public function makeDefault(): static $this->objectManager->flush(); if ($this->objectManager instanceof EntityManagerInterface) { - $cache = $this->objectManager->getConfiguration()->getResultCacheImpl(); - if ($cache instanceof FlushableCache) { - $cache->flushAll(); - } - if ($cache instanceof ResettableInterface) { - $cache->reset(); - } + $this->objectManager->getConfiguration()->getResultCache()?->clear(); } return $this; diff --git a/lib/RoadizCoreBundle/src/EventSubscriber/TranslationSubscriber.php b/lib/RoadizCoreBundle/src/EventSubscriber/TranslationSubscriber.php index ed86c4f20..d6a1f0163 100644 --- a/lib/RoadizCoreBundle/src/EventSubscriber/TranslationSubscriber.php +++ b/lib/RoadizCoreBundle/src/EventSubscriber/TranslationSubscriber.php @@ -4,7 +4,6 @@ namespace RZ\Roadiz\CoreBundle\EventSubscriber; -use Doctrine\Common\Cache\CacheProvider; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\ManagerRegistry; use RZ\Roadiz\CoreBundle\Event\Cache\CachePurgeRequestEvent; @@ -41,11 +40,8 @@ public function purgeCache(Event $event, string $eventName, EventDispatcherInter { $manager = $this->managerRegistry->getManager(); // Clear result cache - if ( - $manager instanceof EntityManagerInterface - && $manager->getConfiguration()->getResultCacheImpl() instanceof CacheProvider - ) { - $manager->getConfiguration()->getResultCacheImpl()->deleteAll(); + if ($manager instanceof EntityManagerInterface) { + $manager->getConfiguration()->getResultCache()?->clear(); } $dispatcher->dispatch(new CachePurgeRequestEvent()); } diff --git a/lib/RoadizCoreBundle/src/Importer/SettingsImporter.php b/lib/RoadizCoreBundle/src/Importer/SettingsImporter.php index 5867e3c9d..7c0999ebd 100644 --- a/lib/RoadizCoreBundle/src/Importer/SettingsImporter.php +++ b/lib/RoadizCoreBundle/src/Importer/SettingsImporter.php @@ -4,7 +4,6 @@ namespace RZ\Roadiz\CoreBundle\Importer; -use Doctrine\Common\Cache\CacheProvider; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\ManagerRegistry; use RZ\Roadiz\CoreBundle\Entity\Setting; @@ -42,10 +41,7 @@ public function import(string $serializedData): bool if ($manager instanceof EntityManagerInterface) { // Clear result cache - $cacheDriver = $manager->getConfiguration()->getResultCacheImpl(); - if ($cacheDriver instanceof CacheProvider) { - $cacheDriver->deleteAll(); - } + $manager->getConfiguration()->getResultCache()?->clear(); } return true; diff --git a/lib/RoadizCoreBundle/src/Model/AttributeTrait.php b/lib/RoadizCoreBundle/src/Model/AttributeTrait.php index df1663cca..4fc9ce35b 100644 --- a/lib/RoadizCoreBundle/src/Model/AttributeTrait.php +++ b/lib/RoadizCoreBundle/src/Model/AttributeTrait.php @@ -35,7 +35,7 @@ trait AttributeTrait #[ORM\ManyToOne( targetEntity: AttributeGroupInterface::class, - cascade: ['persist', 'merge'], + cascade: ['persist'], fetch: 'EAGER', inversedBy: 'attributes' ), diff --git a/lib/RoadizRozierBundle/src/Controller/SettingController.php b/lib/RoadizRozierBundle/src/Controller/SettingController.php index c0ce1f39a..a728ecd08 100644 --- a/lib/RoadizRozierBundle/src/Controller/SettingController.php +++ b/lib/RoadizRozierBundle/src/Controller/SettingController.php @@ -4,7 +4,6 @@ namespace RZ\Roadiz\RozierBundle\Controller; -use Doctrine\Common\Cache\CacheProvider; use Doctrine\Persistence\ManagerRegistry; use RZ\Roadiz\CoreBundle\Bag\Settings; use RZ\Roadiz\CoreBundle\Entity\Setting; @@ -241,12 +240,11 @@ public function editAction(Request $request, int $settingId): Response protected function resetSettingsCache(): void { $this->settingsBag->reset(); - /** @var CacheProvider|null $cacheDriver */ - $cacheDriver = $this->managerRegistry + $this->managerRegistry ->getManagerForClass(Setting::class) ?->getConfiguration() - ->getResultCacheImpl(); - $cacheDriver?->deleteAll(); + ->getResultCache() + ?->clear(); $this->eventDispatcher->dispatch(new CachePurgeRequestEvent()); }