-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix php error #639
Fix php error #639
Conversation
Update see: #639 (comment) |
damn, did not realize how defaults in the configuration work. and looks like we did not add enough tests to discover this issue, sorry. to avoid side effects like always enabling the cache control listener even when not wanted, lets use the fallback in the FOSHttpCacheExtension class as @94noni originally proposed with the default value if nothing is in the array. the default will then only matter if people write to make things more explicit, lets add a public constant in the src/EventListener/CacheControlListener.php class and reference that both from Configuration and from FOSHttpCacheExtension to avoid the magic string. do you want to do that @richardhj ? then i can tag a patch version with the fix. |
Should be ready to review |
@@ -48,7 +49,7 @@ public function load(array $configs, ContainerBuilder $container): void | |||
|
|||
if ($config['debug']['enabled'] || (!empty($config['cache_control']))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu Do we want to have the CacheControlListener
registered if only the new ttl_header
config is defined, for maybe just the debug ENVs?
If not we would need to go with: count($config['cache_control']) > 1
and addDefaultsIfNotSet
in the config. The ??
would not be required then also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can't see a use case for configuring the ttl_header but not configuring any reverse_proxy_ttl at all.
if we merge as is now, my understanding is that the behaviour is the same as before, except that the ttl_header configuration is respected if overwritten, but does not cause errors if not explicitly mentioned by the user. am i missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it will not break, it just register a listener which does then nothing as no rules are configured.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i clarified with alexander, we leave it like this. the cleanest way would be to count if there are any cache_control.rules, but this is not the bug and could have edge case side effects if somebody relies on the cache control service to exist even without rules if there is any configuration.
could be a cleanup for 4.x. when we count the rules, we can also addDefaultsIfNotSet on the ttl_header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets do it that way in fine 👍🏻
Fixes #638