Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2655072

Browse files
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…
2 parents 1fd7089 + 342c4b5 commit 2655072

File tree

10 files changed

+37
-15
lines changed

10 files changed

+37
-15
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
366366
$listeners[] = new Reference('security.access_listener');
367367

368368
// Exception listener
369-
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint));
369+
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint, $firewall['stateless']));
370370

371371
return array($matcher, $listeners, $exceptionListener);
372372
}
@@ -551,12 +551,13 @@ private function getUserProviderId($name)
551551
return 'security.user.provider.concrete.'.$name;
552552
}
553553

554-
private function createExceptionListener($container, $config, $id, $defaultEntryPoint)
554+
private function createExceptionListener($container, $config, $id, $defaultEntryPoint, $stateless)
555555
{
556556
$exceptionListenerId = 'security.exception_listener.'.$id;
557557
$listener = $container->setDefinition($exceptionListenerId, new DefinitionDecorator('security.exception_listener'));
558558
$listener->replaceArgument(3, $id);
559559
$listener->replaceArgument(4, null === $defaultEntryPoint ? null : new Reference($defaultEntryPoint));
560+
$listener->replaceArgument(8, $stateless);
560561

561562
// access denied handler setup
562563
if (isset($config['access_denied_handler'])) {

src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
<argument>%security.access.denied_url%</argument>
245245
<argument type="service" id="security.access.denied_handler" on-invalid="null" />
246246
<argument type="service" id="logger" on-invalid="null" />
247+
<argument>false</argument> <!-- Stateless -->
247248
</service>
248249

249250
<service id="security.authentication.switchuser_listener" class="%security.authentication.switchuser_listener.class%" public="false" abstract="true">

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ private function addLongOption($name, $value)
215215

216216
$option = $this->definition->getOption($name);
217217

218-
// Convert false values (from a previous call to substr()) to null
219-
if (false === $value) {
218+
// Convert empty values to null
219+
if (!isset($value[0])) {
220220
$value = null;
221221
}
222222

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ private function autoPrependBlock()
379379
{
380380
$chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
381381

382-
if (false === $chars) {
382+
if (!isset($chars[0])) {
383383
return $this->newLine(); //empty history, so we should start with a new line.
384384
}
385385
//Prepend new line for each non LF chars (This means no blank line was output before)

src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\ParameterBag;
1313

14+
use Symfony\Component\DependencyInjection\Exception\LogicException;
1415
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
1516

1617
/**
@@ -25,6 +26,8 @@ interface ParameterBagInterface
2526
/**
2627
* Clears all parameters.
2728
*
29+
* @throws LogicException if the ParameterBagInterface can not be cleared
30+
*
2831
* @api
2932
*/
3033
public function clear();
@@ -34,6 +37,8 @@ public function clear();
3437
*
3538
* @param array $parameters An array of parameters
3639
*
40+
* @throws LogicException if the parameter can not be added
41+
*
3742
* @api
3843
*/
3944
public function add(array $parameters);
@@ -66,6 +71,8 @@ public function get($name);
6671
* @param string $name The parameter name
6772
* @param mixed $value The parameter value
6873
*
74+
* @throws LogicException if the parameter can not be set
75+
*
6976
* @api
7077
*/
7178
public function set($name, $value);

src/Symfony/Component/DependencyInjection/Tests/ParameterBag/FrozenParameterBagTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,13 @@ public function testAdd()
5757
$bag = new FrozenParameterBag(array());
5858
$bag->add(array());
5959
}
60+
61+
/**
62+
* @expectedException \LogicException
63+
*/
64+
public function testRemove()
65+
{
66+
$bag = new FrozenParameterBag(array('foo' => 'bar'));
67+
$bag->remove('foo');
68+
}
6069
}

src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ public function getKernel()
160160
*/
161161
public function getSurrogate()
162162
{
163-
return $this->getEsi();
163+
if (!$this->surrogate instanceof Esi) {
164+
throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate');
165+
}
166+
167+
return $this->surrogate;
164168
}
165169

166170
/**
@@ -176,11 +180,7 @@ public function getEsi()
176180
{
177181
@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);
178182

179-
if (!$this->surrogate instanceof Esi) {
180-
throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate');
181-
}
182-
183-
return $this->surrogate;
183+
return $this->getSurrogate();
184184
}
185185

186186
/**

src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ class ExceptionListener
4747
private $errorPage;
4848
private $logger;
4949
private $httpUtils;
50+
private $stateless;
5051

51-
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null)
52+
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null, $stateless = false)
5253
{
5354
$this->tokenStorage = $tokenStorage;
5455
$this->accessDeniedHandler = $accessDeniedHandler;
@@ -58,6 +59,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationT
5859
$this->authenticationTrustResolver = $trustResolver;
5960
$this->errorPage = $errorPage;
6061
$this->logger = $logger;
62+
$this->stateless = $stateless;
6163
}
6264

6365
/**
@@ -185,7 +187,9 @@ private function startAuthentication(Request $request, AuthenticationException $
185187
$this->logger->debug('Calling Authentication entry point.');
186188
}
187189

188-
$this->setTargetPath($request);
190+
if (!$this->stateless) {
191+
$this->setTargetPath($request);
192+
}
189193

190194
if ($authException instanceof AccountStatusException) {
191195
// remove the security token to prevent infinite redirect loops

src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testReflectionCaster()
3232
constants: array:3 [
3333
"IS_IMPLICIT_ABSTRACT" => 16
3434
"IS_EXPLICIT_ABSTRACT" => 32
35-
"IS_FINAL" => 64
35+
"IS_FINAL" => %d
3636
]
3737
properties: array:%d [
3838
"name" => ReflectionProperty {

src/Symfony/Component/Yaml/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
356356
return;
357357
}
358358

359-
if ($inSequence && $oldLineIndentation === $newIndent && '-' === $data[0][0]) {
359+
if ($inSequence && $oldLineIndentation === $newIndent && isset($data[0][0]) && '-' === $data[0][0]) {
360360
// the previous line contained a dash but no item content, this line is a sequence item with the same indentation
361361
// and therefore no nested list or mapping
362362
$this->moveToPreviousLine();

0 commit comments

Comments
 (0)