Skip to content

A deprecation notice is always triggered #37

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

Closed
Nyholm opened this issue Apr 5, 2017 · 4 comments · Fixed by #38
Closed

A deprecation notice is always triggered #37

Nyholm opened this issue Apr 5, 2017 · 4 comments · Fixed by #38

Comments

@Nyholm
Copy link
Member

Nyholm commented Apr 5, 2017

It is for respect_cache_headers.

From @GrahamCampbell KnpLabs/php-github-api#557 (comment)

@acrobat
Copy link
Contributor

acrobat commented Apr 5, 2017

That's indeed from my PR for the new caching headers option. I will look into it and provide fix

@Nyholm
Copy link
Member Author

Nyholm commented Apr 5, 2017

Are you currently working on this?

@acrobat
Copy link
Contributor

acrobat commented Apr 5, 2017

No I will be able to check the code this evening. This can be resolved with setting this option as defined instead of a default value I think. See http://symfony.com/doc/2.6/components/options_resolver.html#options-without-default-values

But I didn't write any actual code yet

@acrobat
Copy link
Contributor

acrobat commented Apr 5, 2017

@Nyholm I quickly checked the code and this should fix it. If you want you can apply the patch otherwise I will create a PR later tonight!

diff --git a/src/CachePlugin.php b/src/CachePlugin.php
index fd7d87f..f4a10f6 100644
--- a/src/CachePlugin.php
+++ b/src/CachePlugin.php
@@ -338,7 +338,7 @@ final class CachePlugin implements Plugin
             'cache_lifetime' => 86400 * 30, // 30 days
             'default_ttl' => 0,
             //Deprecated as of v1.3, to be removed in v2.0. Use respect_response_cache_directives instead
-            'respect_cache_headers' => true,
+            'respect_cache_headers' => null,
             'hash_algo' => 'sha1',
             'methods' => ['GET', 'HEAD'],
             'respect_response_cache_directives' => ['no-cache', 'private', 'max-age', 'no-store'],
@@ -363,7 +363,7 @@ final class CachePlugin implements Plugin
                 @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 $value;
+            return null === $value ? true : $value;
         });
 
         $resolver->setNormalizer('respect_response_cache_directives', function (Options $options, $value) {

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 a pull request may close this issue.

2 participants