Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpKernel] Fixed bug with purging of HTTPS URLs #22079

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

Closed
wants to merge 2 commits into from
Closed
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
9 changes: 6 additions & 3 deletions 9 src/Symfony/Component/HttpKernel/HttpCache/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,13 @@ private function getMetadata($key)
*/
public function purge($url)
{
$http = preg_replace('#^https#', 'http', $url);
$https = preg_replace('#^http#', 'https', $url);
$http = preg_replace('#^https:#', 'http:', $url);
$https = preg_replace('#^http:#', 'https:', $url);

return $this->doPurge($http) || $this->doPurge($https);
$purgedHttp = $this->doPurge($http);
$purgedHttps = $this->doPurge($https);

return $purgedHttp || $purgedHttps;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why changing this? The old version was better IMO as it doesn't execute the second purge if the one is properly done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the problem. Both versions of the cache entry – http AND https – should get purged. Before this change only the http version was purged.

Copy link
Contributor

@Nek- Nek- Mar 20, 2017

Choose a reason for hiding this comment

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

My bad. I was disturbed by the : change in the regex..

}

/**
Expand Down
27 changes: 27 additions & 0 deletions 27 src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,33 @@ public function testLocking()
$this->assertFalse($this->store->isLocked($req));
}

public function testPurgeHttps()
{
$request = Request::create('https://example.com/foo');
$this->store->write($request, new Response('foo'));

$this->assertNotEmpty($this->getStoreMetadata($request));

$this->assertTrue($this->store->purge('https://example.com/foo'));
$this->assertEmpty($this->getStoreMetadata($request));
}

public function testPurgeHttpAndHttps()
{
$requestHttp = Request::create('https://example.com/foo');
$this->store->write($requestHttp, new Response('foo'));

$requestHttps = Request::create('http://example.com/foo');
$this->store->write($requestHttps, new Response('foo'));

$this->assertNotEmpty($this->getStoreMetadata($requestHttp));
$this->assertNotEmpty($this->getStoreMetadata($requestHttps));

$this->assertTrue($this->store->purge('http://example.com/foo'));
$this->assertEmpty($this->getStoreMetadata($requestHttp));
$this->assertEmpty($this->getStoreMetadata($requestHttps));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I wrong or the non-regression test is missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by non-regression test? I added two tests, one for each bug described in the initial issue comment.


protected function storeSimpleEntry($path = null, $headers = array())
{
if (null === $path) {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.