bug #18812 Catch \Throwable (fprochazka)

This PR was squashed before being merged into the 2.3 branch (closes #18812).

Discussion
----------

Catch \Throwable

| Q             | A
| ------------- | ---
| Branch?       | 2.3, 2.7, 2.8, 3.0
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | Yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Related symfony/symfony#18765, symfony/symfony#15949

Commits
-------

893cf00 Catch \Throwable
This commit is contained in:
Nicolas Grekas 2016-05-30 10:14:44 +02:00
commit a60c3551b0
6 changed files with 24 additions and 3 deletions

View File

@ -77,6 +77,9 @@ class DelegatingLoader extends BaseDelegatingLoader
} catch (\Exception $e) {
$this->loading = false;
throw $e;
} catch (\Throwable $e) {
$this->loading = false;
throw $e;
}
$this->loading = false;
@ -85,7 +88,7 @@ class DelegatingLoader extends BaseDelegatingLoader
if ($controller = $route->getDefault('_controller')) {
try {
$controller = $this->parser->parse($controller);
} catch (\Exception $e) {
} catch (\InvalidArgumentException $e) {
// unable to optimize unknown notation
}

View File

@ -18,6 +18,7 @@ use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
@ -193,8 +194,8 @@ class ProfilerController
$url = null;
try {
$url = $this->generator->generate('_profiler', array('token' => $token));
} catch (\Exception $e) {
// the profiler is not enabled
} catch (RouteNotFoundException $e) {
// the named route doesn't exist => the profiler is not enabled
}
return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(

View File

@ -108,6 +108,9 @@ abstract class FileLoader extends Loader
} catch (\Exception $e) {
unset(self::$loading[$resource]);
throw $e;
} catch (\Throwable $e) {
unset(self::$loading[$resource]);
throw $e;
}
unset(self::$loading[$resource]);

View File

@ -320,6 +320,11 @@ class Container implements IntrospectableContainerInterface
return;
}
throw $e;
} catch (\Throwable $e) {
unset($this->loading[$id]);
unset($this->services[$id]);
throw $e;
}

View File

@ -461,6 +461,10 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
return;
}
throw $e;
} catch (\Throwable $e) {
unset($this->loading[$id]);
throw $e;
}

View File

@ -64,6 +64,11 @@ class ContainerAwareHttpKernel extends HttpKernel
$this->container->set('request', null, 'request');
$this->container->leaveScope('request');
throw $e;
} catch (\Throwable $e) {
$this->container->set('request', null, 'request');
$this->container->leaveScope('request');
throw $e;
}