Merge branch '2.7' into 2.8

* 2.7:
  [php7] Fix for substr() always returning a string
  [Security] Do not save the target path in the session for a stateless firewall
  Fix calls to HttpCache#getSurrogate triggering E_USER_DEPRECATED errors.
  [DependencyInjection] fixed FrozenParameterBag and improved Parameter…
This commit is contained in:
Nicolas Grekas 2015-07-29 09:12:56 +02:00
commit 2655072bfd
10 changed files with 37 additions and 15 deletions

View File

@ -366,7 +366,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);
}
@ -551,12 +551,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'])) {

View File

@ -244,6 +244,7 @@
<argument>%security.access.denied_url%</argument>
<argument type="service" id="security.access.denied_handler" on-invalid="null" />
<argument type="service" id="logger" on-invalid="null" />
<argument>false</argument> <!-- Stateless -->
</service>
<service id="security.authentication.switchuser_listener" class="%security.authentication.switchuser_listener.class%" public="false" abstract="true">

View File

@ -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;
}

View File

@ -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)

View File

@ -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);

View File

@ -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');
}
}

View File

@ -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();
}
/**

View File

@ -47,8 +47,9 @@ class ExceptionListener
private $errorPage;
private $logger;
private $httpUtils;
private $stateless;
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null)
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null, $stateless = false)
{
$this->tokenStorage = $tokenStorage;
$this->accessDeniedHandler = $accessDeniedHandler;
@ -58,6 +59,7 @@ class ExceptionListener
$this->authenticationTrustResolver = $trustResolver;
$this->errorPage = $errorPage;
$this->logger = $logger;
$this->stateless = $stateless;
}
/**
@ -185,7 +187,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

View File

@ -32,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 {

View File

@ -356,7 +356,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();