Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: A new entity was found through the relationship #260

Open
cbastienbaron opened this issue Nov 10, 2023 · 6 comments
Open

[Bug]: A new entity was found through the relationship #260

cbastienbaron opened this issue Nov 10, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@cbastienbaron
Copy link

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 : #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)
@cbastienbaron cbastienbaron added the bug Something isn't working label Nov 10, 2023
@cbastienbaron
Copy link
Author

this project is abandonned ?

@lruozzi9
Copy link
Contributor

I had the same problem, do you also have installed the BitBag wishlist plugin?

@vvasiloi
Copy link

Can you reproduce it in a new Sylius project without any customizations or other plugins?

@cbastienbaron
Copy link
Author

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

@marekrzytki
Copy link

Any updates/progress on this issue?

@loevgaard
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants