polina-suzdal / symfony-discusion

0 stars 0 forks source link

[Cache] ExpressionLanguage caching problem when using within Validators #2

Open polina-suzdal opened 1 year ago

polina-suzdal commented 1 year ago

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 😉

powernic commented 1 year ago

This also impacts me on 6.1.9.

Because it has also been merged back into 6.1.9, 6.0.17 and 5.4.17 it's going to impact quite a lot of people 🙁