Skip to content

Commit ab186c2

Browse files
authored
Merge pull request #487 from FriendsOfSymfony/clean-tags-after-tagging
clear response tagger after tagging to not leak tags from one response to the next
2 parents 98280a8 + a82a682 commit ab186c2

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
=========
33

4+
2.5.1 (unreleased)
5+
------------------
6+
7+
### Fixed
8+
9+
* Cache Tagging: Clear the SymfonyResponseTagger after we tagged a response.
10+
Usually PHP uses a new instance for every request. But for example the hash
11+
lookup when using Symfony HttpCache does two requests in the same PHP
12+
process.
13+
414
2.5.0
515
-----
616

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
],
2323
"require": {
2424
"php": "^7.1",
25-
"friendsofsymfony/http-cache": "^2.5",
25+
"friendsofsymfony/http-cache": "^2.5.2",
2626
"symfony/framework-bundle": "^3.4.4 || ^4.0",
2727
"symfony/http-foundation": "^3.4.4 || ^4.0",
2828
"symfony/http-kernel": "^3.4.4 || ^4.0"

src/Http/SymfonyResponseTagger.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function tagSymfonyResponse(Response $response, $replace = false)
4040
}
4141

4242
$response->headers->set($this->getTagsHeaderName(), $this->getTagsHeaderValue());
43+
$this->clear();
4344

4445
return $this;
4546
}

tests/Unit/Http/SymfonyResponseTaggerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function testTagResponse()
3030
$symfonyResponseTagger1->tagSymfonyResponse($response);
3131
$this->assertTrue($response->headers->has('X-Cache-Tags'));
3232
$this->assertEquals(implode(',', $tags1), $response->headers->get('X-Cache-Tags'));
33+
$this->assertFalse($symfonyResponseTagger1->hasTags());
3334

3435
$symfonyResponseTagger2 = new SymfonyResponseTagger();
3536
$symfonyResponseTagger2->addTags($tags2);

0 commit comments

Comments
 (0)