-
Notifications
You must be signed in to change notification settings - Fork 84
Description
When trying to configure match_response on a clean Symfony 7 project with FOSHttpCacheBundle (v3.1.1) enabled, using the following config:
fos_http_cache:
cache_control:
rules:
- match:
host: ^login.example.com$
match_response: 'response.isFresh()'
headers:
cache_control: {public: false}We encounter the following error when clearing Symfony cache:
Service "fos_http_cache.cache_control.expression.e4ac4270c49eeac61019bc369235175a": Cannot replace arguments for class "FOS\HttpCacheBundle\Http\ResponseMatcher\ExpressionResponseMatcher" if none have been configured yet.
It appears that the Symfony DI behavior has changed since Symfony 6+. Instead of calling replaceArgument, the extension should likely call setArgument instead.
The issue can also be reproduced by defining a dummy config in e.g. ./tests/Functional/Fixtures/app/config/config.yml:
- match:
path: ^/foo
match_response: 'response.isFresh()'
headers:
cache_control: {public: true}This causes all tests that compile the Symfony container to fail with the same error.
I’d be happy to submit a PR to fix this if the approach sounds correct. One point I’m unsure about is the subsequent lines in FOSHttpCacheExtension, which reference match_response_expression_service and again use replaceArgument. This setting doesn’t seem to be exposed in the semantic configuration - could this have been intended to use 'expression_language' instead, based on the available configuration options?