bug #10502 [HttpKernel] Fix #10437: Catch exceptions when reloading a no-cache request (romainneutron)
This PR was merged into the 2.3 branch.
Discussion
----------
[HttpKernel] Fix #10437: Catch exceptions when reloading a no-cache request
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #10437
| License | MIT
Commits
-------
8e3a395
Fix #10437: Catch exceptions when reloading a no-cache request
This commit is contained in:
commit
16434b5611
@ -308,7 +308,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
|||||||
if ($this->options['allow_reload'] && $request->isNoCache()) {
|
if ($this->options['allow_reload'] && $request->isNoCache()) {
|
||||||
$this->record($request, 'reload');
|
$this->record($request, 'reload');
|
||||||
|
|
||||||
return $this->fetch($request);
|
return $this->fetch($request, $catch);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -934,6 +934,17 @@ class HttpCacheTest extends HttpCacheTestCase
|
|||||||
$this->assertExceptionsAreCaught();
|
$this->assertExceptionsAreCaught();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testShouldCatchExceptionsWhenReloadingAndNoCacheRequest()
|
||||||
|
{
|
||||||
|
$this->catchExceptions();
|
||||||
|
|
||||||
|
$this->setNextResponse();
|
||||||
|
$this->cacheConfig['allow_reload'] = true;
|
||||||
|
$this->request('GET', '/', array(), array(), false, array('Pragma' => 'no-cache'));
|
||||||
|
|
||||||
|
$this->assertExceptionsAreCaught();
|
||||||
|
}
|
||||||
|
|
||||||
public function testShouldNotCatchExceptions()
|
public function testShouldNotCatchExceptions()
|
||||||
{
|
{
|
||||||
$this->catchExceptions(false);
|
$this->catchExceptions(false);
|
||||||
|
@ -107,7 +107,7 @@ class HttpCacheTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse($this->kernel->isCatchingExceptions());
|
$this->assertFalse($this->kernel->isCatchingExceptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false)
|
public function request($method, $uri = '/', $server = array(), $cookies = array(), $esi = false, $headers = array())
|
||||||
{
|
{
|
||||||
if (null === $this->kernel) {
|
if (null === $this->kernel) {
|
||||||
throw new \LogicException('You must call setNextResponse() before calling request().');
|
throw new \LogicException('You must call setNextResponse() before calling request().');
|
||||||
@ -122,6 +122,7 @@ class HttpCacheTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
$this->esi = $esi ? new Esi() : null;
|
$this->esi = $esi ? new Esi() : null;
|
||||||
$this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig);
|
$this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig);
|
||||||
$this->request = Request::create($uri, $method, array(), $cookies, array(), $server);
|
$this->request = Request::create($uri, $method, array(), $cookies, array(), $server);
|
||||||
|
$this->request->headers->add($headers);
|
||||||
|
|
||||||
$this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch);
|
$this->response = $this->cache->handle($this->request, HttpKernelInterface::MASTER_REQUEST, $this->catch);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user