Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

[Messenger] Problem with async messages and Doctrine (serialized) entites #60015

Closed as not planned
@gremo

Description

@gremo

Symfony version(s) affected

7.2

Description

I have the following message (event) where$order is a simple DTO and$customer is a Doctrine entity:

#[AsMessage('async')]finalclass CapturePayPalOrderCompleted{publicfunction__construct(publicreadonlyOrder$order,publicreadonlyCustomer$customer,    ) {    }}

In my listener I can use any "direct" property ofCustomer without problems, even when event is dispatched asynchronously.I can't, however, access any related entity property (apart from theid) when dispatched asynchronously:

publicfunction__invoke(CapturePayPalOrderCompleted$event):void{// Works, values are present$event->customer->id;$event->customer->priceList?->id;// Doesn't work: value is empty$event->customer->priceList?->appConfigId;}

Of course I'm 100% sure that bothpriceList andappConfigId are notnull. Also because, as I said, code works properly when dispatched synchronously.

Before going crazy, refactoring the code, and transforming dozens and dozens of messages to make them compatible with asynchronous sending (essentially removing every Doctrine entity), I wanted to know: is this a known behavior or a bug? Is there anything that can be done to make these properties work?

How to reproduce

Send a message which has a Doctrine entity as property and use some (nested) object value.

Possible Solution

No response

Additional Context

Customer is eventually connected to aPriceList entity:

#[ORM\Entity]class Customer{    #[ORM\Id]    #[ORM\GeneratedValue]    #[ORM\Column]publicint$id;    #[ORM\ManyToOne]    #[ORM\JoinColumn]public ?PriceList$priceList =null;}

And this entity has an integer property$appConfigId:

#[ORM\Entity]class PriceList{    #[ORM\Id]    #[ORM\GeneratedValue]    #[ORM\Column]publicint$id;    #[ORM\Column(nullable:true)]public ?int$appConfigId =null;}

EDIT: indeed what's serialized is aDoctrine Proxy, I expected that sincePriceRule isn't eager loaded. But the question remain: as soon as I access theappConfigId value, why entity isn't loaded by Doctrine?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp