Skip to content

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

@cbastienbaron

Description

@cbastienbaron

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions