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

Commit 8e3a395

Browse filesBrowse files
romainneutronfabpot
authored andcommitted
Fix #10437: Catch exceptions when reloading a no-cache request
1 parent 1a26d28 commit 8e3a395
Copy full SHA for 8e3a395

File tree

Expand file treeCollapse file tree

3 files changed

+14
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ protected function lookup(Request $request, $catch = false)
308308
if ($this->options['allow_reload'] && $request->isNoCache()) {
309309
$this->record($request, 'reload');
310310

311-
return $this->fetch($request);
311+
return $this->fetch($request, $catch);
312312
}
313313

314314
try {

‎src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,17 @@ public function testShouldCatchExceptions()
934934
$this->assertExceptionsAreCaught();
935935
}
936936

937+
public function testShouldCatchExceptionsWhenReloadingAndNoCacheRequest()
938+
{
939+
$this->catchExceptions();
940+
941+
$this->setNextResponse();
942+
$this->cacheConfig['allow_reload'] = true;
943+
$this->request('GET', '/', array(), array(), false, array('Pragma' => 'no-cache'));
944+
945+
$this->assertExceptionsAreCaught();
946+
}
947+
937948
public function testShouldNotCatchExceptions()
938949
{
939950
$this->catchExceptions(false);

‎src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function assertExceptionsAreNotCaught()
107107
$this->assertFalse($this->kernel->isCatchingExceptions());
108108
}
109109

110-
public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false)
110+
public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false, $headers = array())
111111
{
112112
if (null === $this->kernel) {
113113
throw new \LogicException('You must call setNextResponse() before calling request().');
@@ -122,6 +122,7 @@ public function request($method, $uri = '/', $server = array(), $cookies = array
122122
$this->esi = $esi ? new Esi() : null;
123123
$this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig);
124124
$this->request = Request::create($uri, $method, array(), $cookies, array(), $server);
125+
$this->request->headers->add($headers);
125126

126127
$this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch);
127128

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.