Skip to content

Allow respect_cache_headers to be "false" #166

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

Merged
merged 6 commits into from
May 12, 2017
Merged

Allow respect_cache_headers to be "false" #166

merged 6 commits into from
May 12, 2017

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented May 11, 2017

This PR adds a test for an issue I found.

We define respect_cache_headers like:

->enumNode('respect_cache_headers')
    ->info('Whether we should care about cache headers or not [DEPRECATED]')
    ->values([null, true, false])
    ->beforeNormalization()
        ->always(function ($v) {
            @trigger_error('The option "respect_cache_headers" is deprecated since version 1.3 and will be removed in 2.0. Use "respect_response_cache_directives" instead.', E_USER_DEPRECATED);

            return $v;
        })
    ->end()
->end()

On Symfony 2.8, the EnumNode runs array_unique over the possible values. Though, null and false is treated the same. See https://3v4l.org/KWuNP

This will result in that the possible values for respect_cache_headers will only be true and null. This issue will break BC since we promise that all previous configuration will work on newer versions.

FYI: In the last release we defined the respect_cache_headers like:

->scalarNode('respect_cache_headers')->defaultTrue()->end()

@Nyholm Nyholm added this to the Version 1.5.0 milestone May 11, 2017
@Nyholm Nyholm mentioned this pull request May 11, 2017
@Nyholm
Copy link
Member Author

Nyholm commented May 12, 2017

@stof, have you seen this issue before? Do you know a workaround?

@stof
Copy link
Contributor

stof commented May 12, 2017

hmm, I think the enumNode was always used with strings until now, which is why such issue was never spotted before

@Nyholm Nyholm changed the title respect_cache_headers does not allow "false" Allow respect_cache_headers to be "false" May 12, 2017
@Nyholm
Copy link
Member Author

Nyholm commented May 12, 2017

Thank you. I use a ScalarNode for this now.

->beforeNormalization()
->always(function ($v) {
@trigger_error('The option "respect_cache_headers" is deprecated since version 1.3 and will be removed in 2.0. Use "respect_response_cache_directives" instead.', E_USER_DEPRECATED);

return $v;
})
->end()
->validate()
->ifNotInArray([null, true, false])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one should be indented inside ->validate

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

->beforeNormalization()
->always(function ($v) {
@trigger_error('The option "respect_cache_headers" is deprecated since version 1.3 and will be removed in 2.0. Use "respect_response_cache_directives" instead.', E_USER_DEPRECATED);

return $v;
})
->end()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the end call should be unindented to make the tree structure visual. This is the end of ->beforeNormalization()

->ifNotInArray([null, true, false])
->thenInvalid('Value for "respect_cache_headers" must be null or boolean')
->ifNotInArray([null, true, false])
->thenInvalid('Value for "respect_cache_headers" must be null or boolean')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifNotInArray does not create a new node in the tree (otherwise it would need an end node too). It configures the validation node. So this one should be unindented (it was right before your last update)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it was me that misunderstood. Thank you.

@Nyholm
Copy link
Member Author

Nyholm commented May 12, 2017

Thank you for the reviews.

@Nyholm Nyholm merged commit 6096905 into master May 12, 2017
@Nyholm Nyholm deleted the issue-166 branch May 22, 2017 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants