- 
                Notifications
    You must be signed in to change notification settings 
- Fork 9.4k
Add check for object since getHeader can return bool #3251
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
Conversation
| Thank you for the contribution, @hiephm, it looks good. Just one question in the code. Also, looks like travis builds have failures related to this change. Could you please update the unit tests? | 
| Internal ticket created: MAGETWO-49732 | 
| if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) { | ||
| $cacheControl = $cacheControlHeader->getFieldValue(); | ||
| $this->addDebugHeader($result, 'X-Magento-Cache-Control', $cacheControl); | ||
| $this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'MISS', true); | 
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.
If getHeader() returns false, why should the header 'X-Magento-Cache-Control' not be sent?
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.
Because in that case there is no Cache-Control header is set. If we set any value to X-Magento-Cache-Control, it may confuse developers that value is set from Magento, unless we can put a very clear message to identify that fact. That is my thinking.
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 misspoke, I meant X-Magento-Cache-Debug, because it does not rely on the $cacheControl variable. Won't devs still benefit from seeing whether cache was missed? Agree on X-Magento-Cache-Control 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.
I agree. I have changed the code like that. (not sure why the test is failed for PHP 5.5, but it doesn't related to this fix)
[EngCom] Public Pull Requests - GraphQL
This issue happened to me when I used plugin to return
Redirectresult without settingCache-Controlheader.In this case
getHeaderwill returnfalseand cause: