Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 2.7:
  Fix errors not rethrown even if not handled by console.error listeners
  [VarDumper] Fix dumping of non-nested stubs
  [Security] Avoid unnecessary route lookup for empty logout path
  • Loading branch information
nicolas-grekas committed May 15, 2017
2 parents 433dfd4 + 1c2c3fc commit 6ef78ec
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Application.php
Expand Up @@ -132,7 +132,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
}

if (null !== $e) {
if (!$this->catchExceptions) {
if (!$this->catchExceptions || !$x instanceof \Exception) {
throw $x;
}

Expand Down
23 changes: 23 additions & 0 deletions src/Symfony/Component/Console/Tests/ApplicationTest.php
Expand Up @@ -1231,6 +1231,29 @@ protected function getDispatcher($skipCommand = false)

return $dispatcher;
}

/**
* @requires PHP 7
*/
public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEnabled()
{
$application = new Application();
$application->setAutoExit(false);
$application->setDispatcher(new EventDispatcher());

$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
new \UnknownClass();
});

$tester = new ApplicationTester($application);

try {
$tester->run(array('command' => 'dym'));
$this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.');
} catch (\Error $e) {
$this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found');
}
}
}

class CustomApplication extends Application
Expand Down
Expand Up @@ -146,6 +146,6 @@ public function handle(GetResponseEvent $event)
*/
protected function requiresLogout(Request $request)
{
return $this->httpUtils->checkRequestPath($request, $this->options['logout_path']);
return isset($this->options['logout_path']) && $this->httpUtils->checkRequestPath($request, $this->options['logout_path']);
}
}
Expand Up @@ -112,6 +112,10 @@ private function generateLogoutUrl($key, $referenceType)

list($logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager) = $this->listeners[$key];

if (null === $logoutPath) {
throw new \LogicException('Unable to generate the logout URL without a path.');
}

$parameters = null !== $csrfTokenManager ? array($csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)) : array();

if ('/' === $logoutPath[0]) {
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/VarDumper/Caster/StubCaster.php
Expand Up @@ -29,8 +29,10 @@ public static function castStub(Stub $c, array $a, Stub $stub, $isNested)
$stub->handle = $c->handle;
$stub->cut = $c->cut;

return array();
$a = array();
}

return $a;
}

public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, $isNested)
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/VarDumper/Tests/CliDumperTest.php
Expand Up @@ -230,7 +230,6 @@ public function testThrowingCaster()
}
};'),
));
$line = __LINE__ - 2;
$ref = (int) $out;

$data = $cloner->cloneVar($out);
Expand Down Expand Up @@ -295,7 +294,7 @@ public function testThrowingCaster()
}
%d. %slosure%s() ==> Twig_Template->render(): {
src: {
%sCliDumperTest.php:{$line}: """
%sCliDumperTest.php:%d: """
%A
"""
}
Expand Down

0 comments on commit 6ef78ec

Please sign in to comment.