From 3ad0794aa14aa929eb57886973640026ce7f9aa7 Mon Sep 17 00:00:00 2001 From: Tomaz Ahlin Date: Thu, 2 Jul 2015 10:07:17 +0200 Subject: [PATCH 1/5] =?UTF-8?q?[DependencyInjection]=20fixed=20FrozenParam?= =?UTF-8?q?eterBag=20and=20improved=20Parameter=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ParameterBag/FrozenParameterBag.php | 8 ++++++++ .../ParameterBag/ParameterBagInterface.php | 7 +++++++ .../Tests/ParameterBag/FrozenParameterBagTest.php | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php index dc936a0bd6..cb7e481ed2 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php @@ -69,4 +69,12 @@ class FrozenParameterBag extends ParameterBag { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } + + /** + * {@inheritdoc} + */ + public function remove($name) + { + throw new LogicException('Impossible to call remove() on a frozen ParameterBag.'); + } } diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php index 96003547b6..ead76d738d 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\ParameterBag; +use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; /** @@ -25,6 +26,8 @@ interface ParameterBagInterface /** * Clears all parameters. * + * @throws LogicException if the ParameterBagInterface can not be cleared + * * @api */ public function clear(); @@ -34,6 +37,8 @@ interface ParameterBagInterface * * @param array $parameters An array of parameters * + * @throws LogicException if the parameter can not be added + * * @api */ public function add(array $parameters); @@ -66,6 +71,8 @@ interface ParameterBagInterface * @param string $name The parameter name * @param mixed $value The parameter value * + * @throws LogicException if the parameter can not be set + * * @api */ public function set($name, $value); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php index e6e7fea2f1..6d963dc054 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php @@ -57,4 +57,13 @@ class FrozenParameterBagTest extends \PHPUnit_Framework_TestCase $bag = new FrozenParameterBag(array()); $bag->add(array()); } + + /** + * @expectedException \LogicException + */ + public function testRemove() + { + $bag = new FrozenParameterBag(array('foo' => 'bar')); + $bag->remove('foo'); + } } From 32d964ba3946cdc8572f0b95288b5c3446b24cfc Mon Sep 17 00:00:00 2001 From: Matt Farmer Date: Fri, 17 Jul 2015 11:41:22 -0700 Subject: [PATCH 2/5] Fix calls to HttpCache#getSurrogate triggering E_USER_DEPRECATED errors. --- .../Component/HttpKernel/HttpCache/HttpCache.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 445f59c6f0..da90600bba 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -160,7 +160,11 @@ class HttpCache implements HttpKernelInterface, TerminableInterface */ public function getSurrogate() { - return $this->getEsi(); + if (!$this->surrogate instanceof Esi) { + throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate'); + } + + return $this->surrogate; } /** @@ -176,11 +180,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface { @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the getSurrogate() method instead.', E_USER_DEPRECATED); - if (!$this->surrogate instanceof Esi) { - throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate'); - } - - return $this->surrogate; + return $this->getSurrogate(); } /** From 335825363de8bac4d0dd55d9e82e19bdc963a252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Fri, 24 Jul 2015 17:06:07 +0200 Subject: [PATCH 3/5] [Security] Do not save the target path in the session for a stateless firewall --- .../DependencyInjection/SecurityExtension.php | 5 +++-- .../Resources/config/security_listeners.xml | 1 + .../Security/Http/Firewall/ExceptionListener.php | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 00f251765a..972b4f8f90 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -349,7 +349,7 @@ class SecurityExtension extends Extension $listeners[] = new Reference('security.access_listener'); // Exception listener - $exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint)); + $exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint, $firewall['stateless'])); return array($matcher, $listeners, $exceptionListener); } @@ -534,12 +534,13 @@ class SecurityExtension extends Extension return 'security.user.provider.concrete.'.$name; } - private function createExceptionListener($container, $config, $id, $defaultEntryPoint) + private function createExceptionListener($container, $config, $id, $defaultEntryPoint, $stateless) { $exceptionListenerId = 'security.exception_listener.'.$id; $listener = $container->setDefinition($exceptionListenerId, new DefinitionDecorator('security.exception_listener')); $listener->replaceArgument(3, $id); $listener->replaceArgument(4, null === $defaultEntryPoint ? null : new Reference($defaultEntryPoint)); + $listener->replaceArgument(8, $stateless); // access denied handler setup if (isset($config['access_denied_handler'])) { diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml index b7e4adfd2a..543ca38b78 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml @@ -186,6 +186,7 @@ %security.access.denied_url% + false diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index 57321fb24b..8553c75b79 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -46,8 +46,9 @@ class ExceptionListener private $errorPage; private $logger; private $httpUtils; + private $stateless; - public function __construct(SecurityContextInterface $context, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null) + public function __construct(SecurityContextInterface $context, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null, $stateless = false) { $this->context = $context; $this->accessDeniedHandler = $accessDeniedHandler; @@ -57,6 +58,7 @@ class ExceptionListener $this->authenticationTrustResolver = $trustResolver; $this->errorPage = $errorPage; $this->logger = $logger; + $this->stateless = $stateless; } /** @@ -178,7 +180,9 @@ class ExceptionListener $this->logger->debug('Calling Authentication entry point'); } - $this->setTargetPath($request); + if (!$this->stateless) { + $this->setTargetPath($request); + } if ($authException instanceof AccountStatusException) { // remove the security token to prevent infinite redirect loops From 77ee866dd8601300209cc44ab5e2975bdb0b22ed Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 28 Jul 2015 14:35:05 +0200 Subject: [PATCH 4/5] [php7] Fix for substr() always returning a string --- src/Symfony/Component/Console/Input/ArgvInput.php | 4 ++-- src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php | 4 ++-- src/Symfony/Component/Yaml/Parser.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 43cbe725fb..a6c2132797 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -215,8 +215,8 @@ class ArgvInput extends Input $option = $this->definition->getOption($name); - // Convert false values (from a previous call to substr()) to null - if (false === $value) { + // Convert empty values to null + if (!isset($value[0])) { $value = null; } diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 563bd0997e..a3ab18f894 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -121,11 +121,11 @@ PHP $that->assertEquals('->', $trace[0]['type']); $that->assertEquals(__FILE__, $trace[1]['file']); - $that->assertEquals(__CLASS__, $trace[1]['class']); + $that->assertEquals('Symfony\Component\Debug\Tests\ErrorHandlerTest', $trace[1]['class']); $that->assertEquals('triggerNotice', $trace[1]['function']); $that->assertEquals('::', $trace[1]['type']); - $that->assertEquals(__CLASS__, $trace[2]['class']); + $that->assertEquals('Symfony\Component\Debug\Tests\ErrorHandlerTest', $trace[2]['class']); $that->assertEquals('testNotice', $trace[2]['function']); $that->assertEquals('->', $trace[2]['type']); }; diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index fc46ab3caf..08cfac4224 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -320,7 +320,7 @@ class Parser return; } - if ($inSequence && $oldLineIndentation === $newIndent && '-' === $data[0][0]) { + if ($inSequence && $oldLineIndentation === $newIndent && isset($data[0][0]) && '-' === $data[0][0]) { // the previous line contained a dash but no item content, this line is a sequence item with the same indentation // and therefore no nested list or mapping $this->moveToPreviousLine(); From d6dfe9871c4e4e0c2912c8019c75aeccd801a42c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 28 Jul 2015 17:12:55 +0200 Subject: [PATCH 5/5] [php7] Fix for substr() always returning a string --- src/Symfony/Component/Console/Style/SymfonyStyle.php | 2 +- .../Component/VarDumper/Tests/Caster/ReflectionCasterTest.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index b3113a41e2..0d366c7e89 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -379,7 +379,7 @@ class SymfonyStyle extends OutputStyle { $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2); - if (false === $chars) { + if (!isset($chars[0])) { return $this->newLine(); //empty history, so we should start with a new line. } //Prepend new line for each non LF chars (This means no blank line was output before) diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index ecf776d70f..0fcc7e26bb 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -11,8 +11,6 @@ namespace Symfony\Component\VarDumper\Tests\Caster; -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\CliDumper; use Symfony\Component\VarDumper\Test\VarDumperTestCase; /** @@ -34,7 +32,7 @@ ReflectionClass { constants: array:3 [ "IS_IMPLICIT_ABSTRACT" => 16 "IS_EXPLICIT_ABSTRACT" => 32 - "IS_FINAL" => 64 + "IS_FINAL" => %d ] properties: array:%d [ "name" => ReflectionProperty {