diff --git a/CONFLICTS.md b/CONFLICTS.md index f0bd16aa41..5d584011df 100644 --- a/CONFLICTS.md +++ b/CONFLICTS.md @@ -13,14 +13,10 @@ references related issues. This version is missing the service alias `validator.expression` which causes ValidatorException exception to be thrown when using `Expression` constraint. -- `doctrine/orm:2.15.2`: +- `doctrine/orm:>= 2.16.0` - This version introduced a bug, which causes the `ForeignKeyConstraintViolationException` exception to not be thrown when trying to delete a resource with a foreign key constraint. - References: https://github.com/doctrine/orm/issues/10752 - -- `doctrine/orm:>=2.15.3` - - This version introduced a bug, causing the bulk editing not to work properly. When deleting two items at once, the second one is deleted and re-added to the database. + This version makes Sylius Fixtures loading fail on the product review fixtures. + References: https://github.com/doctrine/orm/issues/10869 - `symfony/validator:5.4.25 || 6.2.12 || 6.3.1` diff --git a/composer.json b/composer.json index c3df88b3f0..2af47173e0 100644 --- a/composer.json +++ b/composer.json @@ -186,7 +186,7 @@ "sylius/user-bundle": "self.version" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "lexik/jwt-authentication-bundle": "^2.18", "stof/doctrine-extensions-bundle": "1.8.0", "symfony/framework-bundle": "6.2.8", diff --git a/src/Sylius/Bundle/AddressingBundle/composer.json b/src/Sylius/Bundle/AddressingBundle/composer.json index 00ee6a58f1..c8154c25e5 100644 --- a/src/Sylius/Bundle/AddressingBundle/composer.json +++ b/src/Sylius/Bundle/AddressingBundle/composer.json @@ -34,7 +34,7 @@ "symfony/intl": "^5.4.21 || ^6.0" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "stof/doctrine-extensions-bundle": "1.8.0", "twig/twig": "^1.0 || ^3.0" }, diff --git a/src/Sylius/Bundle/AttributeBundle/composer.json b/src/Sylius/Bundle/AttributeBundle/composer.json index bc40666e87..15dfdbdcfd 100644 --- a/src/Sylius/Bundle/AttributeBundle/composer.json +++ b/src/Sylius/Bundle/AttributeBundle/composer.json @@ -43,7 +43,7 @@ "symfony/form": "^5.4.21 || ^6.0" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "stof/doctrine-extensions-bundle": "1.8.0" }, "config": { diff --git a/src/Sylius/Bundle/ChannelBundle/composer.json b/src/Sylius/Bundle/ChannelBundle/composer.json index b3516d0fd3..bfdd169203 100644 --- a/src/Sylius/Bundle/ChannelBundle/composer.json +++ b/src/Sylius/Bundle/ChannelBundle/composer.json @@ -42,7 +42,7 @@ "twig/twig": "^2.12 || ^3.3" }, "conflict": { - "doctrine/orm": ">= 2.15.2" + "doctrine/orm": ">= 2.16.0" }, "config": { "allow-plugins": { diff --git a/src/Sylius/Bundle/CurrencyBundle/composer.json b/src/Sylius/Bundle/CurrencyBundle/composer.json index 7bb357ff00..f629560588 100644 --- a/src/Sylius/Bundle/CurrencyBundle/composer.json +++ b/src/Sylius/Bundle/CurrencyBundle/composer.json @@ -33,7 +33,7 @@ "symfony/templating": "^5.4.21 || ^6.0" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "twig/twig": "^1.0" }, "require-dev": { diff --git a/src/Sylius/Bundle/CustomerBundle/composer.json b/src/Sylius/Bundle/CustomerBundle/composer.json index 1851531114..cfe7082459 100644 --- a/src/Sylius/Bundle/CustomerBundle/composer.json +++ b/src/Sylius/Bundle/CustomerBundle/composer.json @@ -44,7 +44,7 @@ "webmozart/assert": "^1.9" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "twig/twig": "^3.0" }, "require-dev": { diff --git a/src/Sylius/Bundle/InventoryBundle/composer.json b/src/Sylius/Bundle/InventoryBundle/composer.json index a0c10452c1..4005a9b0be 100644 --- a/src/Sylius/Bundle/InventoryBundle/composer.json +++ b/src/Sylius/Bundle/InventoryBundle/composer.json @@ -34,7 +34,7 @@ "symfony/validator": "^5.4.21 || ^6.0" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "twig/twig": "^1.0" }, "require-dev": { diff --git a/src/Sylius/Bundle/LocaleBundle/composer.json b/src/Sylius/Bundle/LocaleBundle/composer.json index fa8ed7b7cf..6a85d6e7c2 100644 --- a/src/Sylius/Bundle/LocaleBundle/composer.json +++ b/src/Sylius/Bundle/LocaleBundle/composer.json @@ -33,7 +33,7 @@ "symfony/templating": "^5.4.21 || ^6.0" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "twig/twig": "^1.0" }, "require-dev": { diff --git a/src/Sylius/Bundle/MoneyBundle/composer.json b/src/Sylius/Bundle/MoneyBundle/composer.json index 4928fcafc9..013b125d3f 100644 --- a/src/Sylius/Bundle/MoneyBundle/composer.json +++ b/src/Sylius/Bundle/MoneyBundle/composer.json @@ -33,7 +33,7 @@ "webmozart/assert": "^1.9" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "twig/twig": "^1.0" }, "require-dev": { diff --git a/src/Sylius/Bundle/OrderBundle/composer.json b/src/Sylius/Bundle/OrderBundle/composer.json index 7191e9c174..3ec5693689 100644 --- a/src/Sylius/Bundle/OrderBundle/composer.json +++ b/src/Sylius/Bundle/OrderBundle/composer.json @@ -38,7 +38,7 @@ "symfony/templating": "^5.4.21 || ^6.0" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "stof/doctrine-extensions-bundle": "1.8.0", "twig/twig": "^1.0 || ^3.0" }, diff --git a/src/Sylius/Bundle/ReviewBundle/EventListener/ReviewChangeListener.php b/src/Sylius/Bundle/ReviewBundle/EventListener/ReviewChangeListener.php index 0127107a38..1ffc7608c1 100644 --- a/src/Sylius/Bundle/ReviewBundle/EventListener/ReviewChangeListener.php +++ b/src/Sylius/Bundle/ReviewBundle/EventListener/ReviewChangeListener.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace Sylius\Bundle\ReviewBundle\EventListener; +use Doctrine\ORM\Event\PostRemoveEventArgs; use Doctrine\Persistence\Event\LifecycleEventArgs; use Sylius\Bundle\ReviewBundle\Updater\ReviewableRatingUpdaterInterface; use Sylius\Component\Review\Model\ReviewInterface; @@ -46,6 +47,12 @@ final class ReviewChangeListener return; } - $this->averageRatingUpdater->update($subject->getReviewSubject()); + $reviewSubject = $subject->getReviewSubject(); + + if ($args instanceof PostRemoveEventArgs) { + $reviewSubject->removeReview($subject); + } + + $this->averageRatingUpdater->update($reviewSubject); } } diff --git a/src/Sylius/Bundle/ReviewBundle/spec/EventListener/ReviewChangeListenerSpec.php b/src/Sylius/Bundle/ReviewBundle/spec/EventListener/ReviewChangeListenerSpec.php index d171484d2c..5e2b6d94b1 100644 --- a/src/Sylius/Bundle/ReviewBundle/spec/EventListener/ReviewChangeListenerSpec.php +++ b/src/Sylius/Bundle/ReviewBundle/spec/EventListener/ReviewChangeListenerSpec.php @@ -13,7 +13,9 @@ declare(strict_types=1); namespace spec\Sylius\Bundle\ReviewBundle\EventListener; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Event\LifecycleEventArgs; +use Doctrine\ORM\Event\PostRemoveEventArgs; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Sylius\Bundle\ReviewBundle\Updater\ReviewableRatingUpdaterInterface; @@ -28,7 +30,7 @@ final class ReviewChangeListenerSpec extends ObjectBehavior } function it_recalculates_subject_rating_on_accepted_review_deletion( - $averageRatingUpdater, + ReviewableRatingUpdaterInterface $averageRatingUpdater, LifecycleEventArgs $event, ReviewInterface $review, ReviewableInterface $reviewSubject, @@ -41,8 +43,25 @@ final class ReviewChangeListenerSpec extends ObjectBehavior $this->recalculateSubjectRating($event); } - function it_does_nothing_if_event_subject_is_not_review_object($averageRatingUpdater, LifecycleEventArgs $event): void - { + function it_removes_a_review_from_a_review_subject_on_the_post_remove_event( + ReviewableRatingUpdaterInterface $averageRatingUpdater, + ReviewInterface $review, + ReviewableInterface $reviewSubject, + EntityManagerInterface $entityManager, + ): void { + $event = new PostRemoveEventArgs($review->getWrappedObject(), $entityManager->getWrappedObject()); + $review->getReviewSubject()->willReturn($reviewSubject); + + $reviewSubject->removeReview($review)->shouldBeCalled(); + $averageRatingUpdater->update($reviewSubject)->shouldBeCalled(); + + $this->recalculateSubjectRating($event); + } + + function it_does_nothing_if_event_subject_is_not_review_object( + ReviewableRatingUpdaterInterface $averageRatingUpdater, + LifecycleEventArgs $event + ): void { $event->getObject()->willReturn('badObject'); $averageRatingUpdater->update(Argument::type(ReviewableInterface::class))->shouldNotBeCalled(); diff --git a/src/Sylius/Bundle/TaxationBundle/composer.json b/src/Sylius/Bundle/TaxationBundle/composer.json index 025ab3e609..b1a6ca1508 100644 --- a/src/Sylius/Bundle/TaxationBundle/composer.json +++ b/src/Sylius/Bundle/TaxationBundle/composer.json @@ -36,7 +36,7 @@ "symfony/framework-bundle": "^5.4.21 || ^6.0" }, "conflict": { - "doctrine/orm": ">= 2.15.2", + "doctrine/orm": ">= 2.16.0", "stof/doctrine-extensions-bundle": "1.8.0", "twig/twig": "^3.0" },