Skip to content

Conversation

@hiephm
Copy link

@hiephm hiephm commented Feb 2, 2016

This issue happened to me when I used plugin to return Redirect result without setting Cache-Control header.
In this case getHeader will return false and cause:

PHP Fatal error:  Call to a member function getFieldValue() on boolean

@dsikkema-magento
Copy link
Contributor

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?

@dsikkema-magento
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Contributor

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

Copy link
Author

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)

@sshrewz sshrewz added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed Progress: needs update labels Mar 9, 2016
@magento-team magento-team merged commit 552294c into magento:develop Mar 12, 2016
magento-engcom-team pushed a commit that referenced this pull request Oct 4, 2018
[EngCom] Public Pull Requests - GraphQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: accept

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants