8000 purge both http and https from http cache store · symfony/symfony@e2cad29 · GitHub
[go: up one dir, main page]

Skip to content

Commit e2cad29

Browse files
committed
purge both http and https from http cache store
1 parent 5a38804 commit e2cad29

File tree

1 file changed

+19
-2
lines changed
  • src/Symfony/Component/HttpKernel/HttpCache

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,31 @@ private function getMetadata($key)
317317
/**
318318
* Purges data for the given URL.
319319
*
320+
* This method purges both the http and the https version of the cache entry.
321+
*
320322
* @param string $url A URL
321323
*
322-
* @return bool true if the URL exists and has been purged, false otherwise
324+
* @return bool true if the URL exists with either http or https scheme and has been purged, false otherwise
323325
*/
324326
public function purge($url)
325327
{
326-
$key = $this->getCacheKey(Request::create($url));
328+
$url2 = 0 === strpos($url, 'https://')
329+
? preg_replace('https', 'http', $url, 1)
330+
: preg_replace('http', 'https', $url, 1);
327331

332+
return $this->doPurge($url) || $this->doPurge($url2);
333+
}
334+
335+
/**
336+
* Purges data for the given URL.
337+
*
338+
* @param string $url A URL
339+
*
340+
* @return bool true if the URL exists and has been purged, false otherwise
341+
*/
342+
private function doPurge($url)
343+
{
344+
$key = $this->getCacheKey(Request::create($url));
328345
if (isset($this->locks[$key])) {
329346
flock($this->locks[$key], LOCK_UN);
330347
fclose($this->locks[$key]);

0 commit comments

Comments
 (0)
0