Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[Messenger] Automatically clear the entity manager at each message consumption #29662
@sroze Hi, do you think there is any good way to automatize the doctrine entity manager clear between message consumption? Do you think it could be a good idea to provide an embedded middleware to do this on
The use case is: when the worker is running (and not stopped between each messages), if an entity is fetched from the database, it may not be refresh between two messages handling. For example, in the case of an user account recovery process (email sent async with messenger and amqp), if the email address is updated after the first try, the second email is send to the old email address.
Resettable services are only reset on next kernel
This PR was merged into the 4.4 branch. Discussion ---------- [Messenger] Add clear Entity Manager middleware | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29662 | License | MIT | Doc PR | TBD General purpose of this middleware: * avoid memory leaks during messages handling * prevent unexpected side effects when entities that already stored in identity map not refreshed between messages Commits ------- 6e690a6 Add clear Entity Manager middleware (closes #29662)
* 4.4: Extract Abstract Doctrine Middleware [Translation] refactor ArrayLoader::flatten [TwigBundle] mark TemplateIterator as internal Improved error message on create a form builder with invalid options [Security] add PasswordEncoderInterface::needsRehash() [HttpClient] add $response->cancel() Add clear Entity Manager middleware (closes #29662) [FrameworkBundle] Add missing BC layer for deprecated ControllerNameParser injections [Validator] Improve TypeValidator to handle array of types Add exception as HTML comment to beginning and end of `exception_full.html.twig` [Validator] Add compared value path to violation parameters