Description
Since I've upgraded to Symfony 6.2.2 I'm experiencing caching issues when using custom Expressions withing Validators components in production environment, in particular when using:
Symfony\Component\Validator\Constraints\When in a DTO validation
Symfony\Component\Security\Http\Attribute\IsGranted for route access control
Symfony correctly take in charge the request the first time I access a specific page/submit an API request, from there on, replicating the same request won't work anymore, as if it were still validating the previous request, or in different words, it were still using a cached Expression result for the next requests.
How to reproduce
Using IsGranted attribute for route access control:
#[Route(path: '/{report}/edit', name: 'edit_report')]#[IsGranted(new Expression("is_granted('view_report', subject.getOwner())"), subject: 'report')]
Using When Assert in a DTO Request validator:
#[When( expression: '!this.owner && !this.order', constraints: [new NotBlank()] )]
Possible Solution
No response
Additional Context
It works in development environment without any problems, in a production environment it works the first time then only after a cache:clear operation.
I made my best to be as clear as possible, it's my first issue around here 😉
Symfony version(s) affected 6.2.2
Description Since I've upgraded to Symfony 6.2.2 I'm experiencing caching issues when using custom Expressions withing Validators components in production environment, in particular when using:
Symfony correctly take in charge the request the first time I access a specific page/submit an API request, from there on, replicating the same request won't work anymore, as if it were still validating the previous request, or in different words, it were still using a cached Expression result for the next requests.
How to reproduce Using IsGranted attribute for route access control:
#[Route(path: '/{report}/edit', name: 'edit_report')]
#[IsGranted(new Expression("is_granted('view_report', subject.getOwner())"), subject: 'report')]
Using When Assert in a DTO Request validator:
#[When( expression: '!this.owner && !this.order', constraints: [new NotBlank()] )]
Possible Solution No response
Additional Context It works in development environment without any problems, in a production environment it works the first time then only after a cache:clear operation.
I made my best to be as clear as possible, it's my first issue around here 😉