Skip to content
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

Fix for CHttpCacheFilter's Cache-Control headers being overwritten by started sessions #1628

Merged
merged 6 commits into from
Nov 10, 2012

Conversation

DaSourcerer
Copy link
Contributor

As reported here, there is a problem with the Cache-Control header being overwritten by PHP's session logic. This can result into situations where http caching loses its effects.

This PR sets a header via session_cache_limiter() which will be immediately overwritten. In addition, the Pragma header will be cleared as well. This seems to work well in PHP v5.4.x and according to this comment, it should work with previous versions of PHP too. I'd still appreciate some review by others.

@ghost ghost assigned samdark Oct 29, 2012
@DaSourcerer
Copy link
Contributor Author

Are there any objections? If not, I'd like to add a line to CHANGELOG now ...

@mdomba
Copy link
Member

mdomba commented Nov 5, 2012

as you wrote... this still needs to be tested... "it should work" does not mean it works.

@DaSourcerer
Copy link
Contributor Author

True. I'm a bit worried, though: Except for @samdark assigning himself, this PR hasn't seen any attention in a week. I realize that the issue resolved by this is not the most pressing one, but it clearly impairs the operation of CHttpCacheFilter for logged-in users, so I'd like to see this tested and pulled asap (or at least timely enough to be included in v1.1.13).

I just realized that I've got a box left which is locked at PHP v5.3, so I could actually test this myself. I'll report back soon.

@samdark
Copy link
Member

samdark commented Nov 6, 2012

@DaSourcerer it will be very helpful.

@resurtm
Copy link
Contributor

resurtm commented Nov 8, 2012

Solution works as expected on 5.2.17. Feel free to request additional tests on 5.2.17.

@@ -181,6 +181,11 @@ protected function send304Header()
*/
protected function sendCacheControlHeader()
{
if(Yii::app()->session->isStarted)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget about indentation. ✋

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like this diff has been whitespace-damaged while it looked ok in my editor... Thanks for pointing this out.

@DaSourcerer
Copy link
Contributor Author

I can now confirm that this works on PHP v5.3.18 as well.

@samdark
Copy link
Member

samdark commented Nov 9, 2012

Nice. Add a changelog line, update and we will merge it.

@DaSourcerer
Copy link
Contributor Author

Done with 686480e

@@ -35,6 +35,7 @@ Version 1.1.13 work in progress
- Bug #1652: Fixed incorrect syntax of CDbSchema::renameTable() for SQLite, added CSqliteSchema::renameTable() method (Sarke)
- Bug: Table schema is refreshed on Gii model generation when schemaCachingDuration is used (SonkoDmitry)
- Bug: CDbCommand::setFetchMode wasn't accepting additional arguments needed for PDO::FETCH_CLASS (samdark)
- Bug: Active HTTP sessions overwrote the Cache-Control header set by CHttpCacheFilter (DaSourcerer)
Copy link
Member

Choose a reason for hiding this comment

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

Need issue number here. In this case it's 1628. That's one last thing. Can't do it myself since using iPhone currently :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I thought since #1628 is "just" the PR, I could leave it out. Adding right away ...

samdark added a commit that referenced this pull request Nov 10, 2012
Fix for CHttpCacheFilter's Cache-Control headers being overwritten by started sessions
@samdark samdark merged commit 446bb67 into yiisoft:master Nov 10, 2012
@samdark
Copy link
Member

samdark commented Nov 10, 2012

Thanks!

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