Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f509150

Browse files
ausifabpot
authored andcommitted
[HttpKernel] Fixed bug with purging of HTTPS URLs
1 parent 2ba564d commit f509150

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/Symfony/Component/HttpKernel/HttpCache/Store.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,13 @@ private function getMetadata($key)
325325
*/
326326
public function purge($url)
327327
{
328-
$http = preg_replace('#^https#', 'http', $url);
329-
$https = preg_replace('#^http#', 'https', $url);
328+
$http = preg_replace('#^https:#', 'http:', $url);
329+
$https = preg_replace('#^http:#', 'https:', $url);
330330

331-
return $this->doPurge($http) || $this->doPurge($https);
331+
$purgedHttp = $this->doPurge($http);
332+
$purgedHttps = $this->doPurge($https);
333+
334+
return $purgedHttp || $purgedHttps;
332335
}
333336

334337
/**

src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,33 @@ public function testLocking()
236236
$this->assertFalse($this->store->isLocked($req));
237237
}
238238

239+
public function testPurgeHttps()
240+
{
241+
$request = Request::create('https://example.com/foo');
242+
$this->store->write($request, new Response('foo'));
243+
244+
$this->assertNotEmpty($this->getStoreMetadata($request));
245+
246+
$this->assertTrue($this->store->purge('https://example.com/foo'));
247+
$this->assertEmpty($this->getStoreMetadata($request));
248+
}
249+
250+
public function testPurgeHttpAndHttps()
251+
{
252+
$requestHttp = Request::create('https://example.com/foo');
253+
$this->store->write($requestHttp, new Response('foo'));
254+
255+
$requestHttps = Request::create('http://example.com/foo');
256+
$this->store->write($requestHttps, new Response('foo'));
257+
258+
$this->assertNotEmpty($this->getStoreMetadata($requestHttp));
259+
$this->assertNotEmpty($this->getStoreMetadata($requestHttps));
260+
261+
$this->assertTrue($this->store->purge('http://example.com/foo'));
262+
$this->assertEmpty($this->getStoreMetadata($requestHttp));
263+
$this->assertEmpty($this->getStoreMetadata($requestHttps));
264+
}
265+
239266
protected function storeSimpleEntry($path = null, $headers = array())
240267
{
241268
if (null === $path) {

0 commit comments

Comments
 (0)