[Bug]: A new entity was found through the relationship
Plugin version
v0.12.0-alpha.5
Sylius version
v1.12.11
What happened?
Hi,
on first add gift card on cart, it's ok
but when we update quantity of a gift card , a doctrine error is thrown
A new entity was found through the relationship 'App\Entity\Order\OrderItemUnit#orderItem' that was not configured to cascade persist operations for entity: App\Entity\Order\OrderItem@6168. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'App\Entity\Order\OrderItem#__toString()' to get a clue.
to reproduce, just install a fresh https://sylius.com/download/ and add setono/sylius-gift-card-plugin configure a product which is a gift card, go to front add this to cart, and add the same product to cart again and boom
perhaps it's related (or not) we also experienced the issue mentionned here : https://github.com/Setono/SyliusGiftCardPlugin/issues/256
someone have a workaround ? or a fix ?
Relevant log output
Doctrine\ORM\ORMInvalidArgumentException:
A new entity was found through the relationship 'App\Entity\Order\OrderItemUnit#orderItem' that was not configured to cascade persist operations for entity: App\Entity\Order\OrderItem@6168. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'App\Entity\Order\OrderItem#__toString()' to get a clue.
at vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:102
at Doctrine\ORM\ORMInvalidArgumentException::newEntitiesFoundThroughRelationships()
(vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:3633)
at Doctrine\ORM\UnitOfWork->assertThatThereAreNoUnintentionallyNonPersistedAssociations()
(vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:412)
at Doctrine\ORM\UnitOfWork->commit()
(vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:403)
at Doctrine\ORM\EntityManager->flush()
(vendor/sylius/sylius/src/Sylius/Bundle/OrderBundle/Controller/OrderItemController.php:81)
at Sylius\Bundle\OrderBundle\Controller\OrderItemController->addAction()
(vendor/symfony/http-kernel/HttpKernel.php:181)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
(vendor/symfony/http-kernel/HttpKernel.php:76)
at Symfony\Component\HttpKernel\HttpKernel->handle()
(vendor/symfony/http-kernel/Kernel.php:197)
at Symfony\Component\HttpKernel\Kernel->handle()
(vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
(vendor/autoload_runtime.php:29)
at require_once('/warehouse/github/acme/vendor/autoload_runtime.php')
(public/index.php:5)
this project is abandonned ?
I had the same problem, do you also have installed the BitBag wishlist plugin?
Can you reproduce it in a new Sylius project without any customizations or other plugins?
yup from description on this issue :
to reproduce, just install a fresh https://sylius.com/download/ and add setono/sylius-gift-card-plugin
configure a product which is a gift card, go to front add this to cart, and add the same product to cart again and boom
Any updates/progress on this issue?
I will be working on these issues in the upcoming weeks. The first PR I did today where I dropped support for PHP 7.4 and PHP 8.0 to make it easier for me.