Skip to content

[HttpFoundation] Fix erasing cookies issue #29676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function process(ContainerBuilder $container)
}

$debug = $container->getParameter('kernel.debug');

$voterServices = array();
foreach ($voters as $voter) {
$voterServiceId = (string) $voter;
$definition = $container->getDefinition($voterServiceId);
Expand All @@ -56,17 +56,18 @@ public function process(ContainerBuilder $container)
}

if ($debug) {
// Decorate original voters with TraceableVoter
$debugVoterServiceId = 'debug.security.voter.'.$voterServiceId;
$voterServices[] = new Reference($debugVoterServiceId = 'debug.security.voter.'.$voterServiceId);

$container
->register($debugVoterServiceId, TraceableVoter::class)
->setDecoratedService($voterServiceId)
->addArgument(new Reference($debugVoterServiceId.'.inner'))
->addArgument($voter)
->addArgument(new Reference('event_dispatcher'));
} else {
$voterServices[] = $voter;
}
}

$adm = $container->getDefinition('security.access.decision_manager');
$adm->replaceArgument(0, new IteratorArgument($voters));
$container->getDefinition('security.access.decision_manager')
->replaceArgument(0, new IteratorArgument($voterServices));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ public function testThatSecurityVotersAreProcessedInPriorityOrder()
$this->assertCount(4, $refs);
}

/**
* Test that in debug mode, voters are correctly decorated.
*/
public function testThatVotersAreDecoratedInDebugMode(): void
public function testThatVotersAreTraceableInDebugMode(): void
{
$container = new ContainerBuilder();

Expand All @@ -96,21 +93,18 @@ public function testThatVotersAreDecoratedInDebugMode(): void
$compilerPass->process($container);

$def1 = $container->getDefinition('debug.security.voter.voter1');
$this->assertEquals(array('voter1', null, 0), $def1->getDecoratedService(), 'voter1: wrong return from getDecoratedService');
$this->assertEquals(new Reference('debug.security.voter.voter1.inner'), $def1->getArgument(0), 'voter1: wrong decorator argument');
$this->assertNull($def1->getDecoratedService(), 'voter1: should not be decorated');
$this->assertEquals(new Reference('voter1'), $def1->getArgument(0), 'voter1: wrong argument');

$def2 = $container->getDefinition('debug.security.voter.voter2');
$this->assertEquals(array('voter2', null, 0), $def2->getDecoratedService(), 'voter2: wrong return from getDecoratedService');
$this->assertEquals(new Reference('debug.security.voter.voter2.inner'), $def2->getArgument(0), 'voter2: wrong decorator argument');
$this->assertNull($def2->getDecoratedService(), 'voter2: should not be decorated');
$this->assertEquals(new Reference('voter2'), $def2->getArgument(0), 'voter2: wrong argument');

$voters = $container->findTaggedServiceIds('security.voter');
$this->assertCount(2, $voters, 'Incorrect count of voters');
}

/**
* Test that voters are not decorated if the application is not in debug mode.
*/
public function testThatVotersAreNotDecoratedWithoutDebugMode(): void
public function testThatVotersAreNotTraceableWithoutDebugMode(): void
{
$container = new ContainerBuilder();
$container->setParameter('kernel.debug', false);
Expand All @@ -130,8 +124,8 @@ public function testThatVotersAreNotDecoratedWithoutDebugMode(): void
$compilerPass = new AddSecurityVotersPass();
$compilerPass->process($container);

$this->assertFalse($container->has('debug.security.voter.voter1'), 'voter1 should not be decorated');
$this->assertFalse($container->has('debug.security.voter.voter2'), 'voter2 should not be decorated');
$this->assertFalse($container->has('debug.security.voter.voter1'), 'voter1 should not be traced');
$this->assertFalse($container->has('debug.security.voter.voter2'), 'voter2 should not be traced');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Helper/ProcessHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function run(OutputInterface $output, $cmd, $error = null, callable $call
$process = $cmd[0];
unset($cmd[0]);
} else {
throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should an array whose first is element is either the path to the binary to run of a "Process" object.', __METHOD__));
throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__));
}

if ($verbosity <= $output->getVerbosity()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function start()
if (null !== $this->emulateSameSite) {
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
if (null !== $originalCookie) {
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite));
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite), false);
}
}

Expand Down Expand Up @@ -225,7 +225,7 @@ public function regenerate($destroy = false, $lifetime = null)
if (null !== $this->emulateSameSite) {
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
if (null !== $originalCookie) {
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite));
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite), false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarExporter/Internal/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static function export($value, $indent = '')
if (!\is_int($k) || 1 !== $k - $j) {
$code .= self::export($k, $subIndent).' => ';
}
if (\is_int($k)) {
if (\is_int($k) && $k > $j) {
$j = $k;
}
$code .= self::export($v, $subIndent).",\n";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
5 => true,
1 => true,
2 => true,
true,
];
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function provideExport()

yield array('bool', true, true);
yield array('simple-array', array(123, array('abc')), true);
yield array('partially-indexed-array', array(5 => true, 1 => true, 2 => true, 6 => true), true);
yield array('datetime', \DateTime::createFromFormat('U', 0));

$value = new \ArrayObject();
Expand Down