Skip to content

clear response tagger after tagging to not leak tags from one response to the next #487

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 1 commit into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

2.5.1 (unreleased)
------------------

### Fixed

* Cache Tagging: Clear the SymfonyResponseTagger after we tagged a response.
Usually PHP uses a new instance for every request. But for example the hash
lookup when using Symfony HttpCache does two requests in the same PHP
process.

2.5.0
-----

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"require": {
"php": "^7.1",
"friendsofsymfony/http-cache": "^2.5",
"friendsofsymfony/http-cache": "^2.5.2",
"symfony/framework-bundle": "^3.4.4 || ^4.0",
"symfony/http-foundation": "^3.4.4 || ^4.0",
"symfony/http-kernel": "^3.4.4 || ^4.0"
Expand Down
1 change: 1 addition & 0 deletions src/Http/SymfonyResponseTagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function tagSymfonyResponse(Response $response, $replace = false)
}

$response->headers->set($this->getTagsHeaderName(), $this->getTagsHeaderValue());
$this->clear();

return $this;
}
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Http/SymfonyResponseTaggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function testTagResponse()
$symfonyResponseTagger1->tagSymfonyResponse($response);
$this->assertTrue($response->headers->has('X-Cache-Tags'));
$this->assertEquals(implode(',', $tags1), $response->headers->get('X-Cache-Tags'));
$this->assertFalse($symfonyResponseTagger1->hasTags());

$symfonyResponseTagger2 = new SymfonyResponseTagger();
$symfonyResponseTagger2->addTags($tags2);
Expand Down