Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Restore undetermined state in Cache configuration #714

Merged
merged 1 commit into from Feb 23, 2021

Conversation

jderusse
Copy link
Contributor

This PR fix a BC break introduced by #707.

Given the following code:

    /**
     * @Cache(smaxage="+1min")
     */
    public function fooAction(){}

The headers generated by HttpCacheListener changed as following:

- public, s-maxage=60
+ private, s-maxage=60

Why? Because previously the Cache's properties were null until the user provide a value. In such state, isPublic returns false (although isPrivate). And sometimes, null is expected (like the vary array =>

if (!$response->headers->has('Vary') && null !== $configuration->getVary()) {
)

The #707 PR introduce 2 changes:

  • a value for each property is now forced by the constructor's default value.
  • the constructor calls the setter for each property (even if the user did not provide a value for it), some setter (ie. setPublic) does not expect a null value and convert null into something.

It looks like, only the Cache configuration is affected. Other Configuration has already a default value defined for each property.

This PR restore the default null value for all properties and prevent the constructor to call the setter when the value is null.

src/Configuration/Cache.php Outdated Show resolved Hide resolved
@fabpot
Copy link
Member

fabpot commented Feb 23, 2021

Thank you @jderusse.

@fabpot fabpot merged commit 8ef75e9 into sensiolabs:master Feb 23, 2021
@jderusse jderusse deleted the fix-config-default branch February 23, 2021 14:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants