8000 Merge branch '6.2' into 6.3 · symfony/symfony@6d97baa · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d97baa

Browse files
Merge branch '6.2' into 6.3
* 6.2: Fix merge [Translation] Fix handling of null messages in `ArrayLoader` [Console] Remove exec and replace it by shell_exec [Security] Skip clearing CSRF Token on stateless logout
2 parents 54a3b84 + 684fdd2 commit 6d97baa

File tree

10 files changed

+37
-22
lines changed

10 files changed

+37
-22
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function testWorkflowDefaultMarkingStoreDefinition()
9292
{
9393
$container = $this->createContainerFromClosure(function ($container) {
9494
$container->loadFromExtension('framework', [
95+
'http_method_override' => false,
9596
'workflows' => [
9697
'workflow_a' => [
9798
'type' => 'state_machine',

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,11 @@ private function isInteractiveInput($inputStream): bool
498498
return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
499499
}
500500

501-
if (!\function_exists('exec')) {
501+
if (!\function_exists('shell_exec')) {
502502
return self::$stdinIsInteractive = true;
503503
}
504504

505-
exec('stty 2> /dev/null', $output, $status);
506-
507-
return self::$stdinIsInteractive = 1 !== $status;
505+
return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
508506
}
509507

510508
/**

src/Symfony/Component/Console/Terminal.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,12 @@ public static function hasSttyAvailable(): bool
123123
return self::$stty;
124124
}
125125

126-
// skip check if exec function is disabled
127-
if (!\function_exists('exec')) {
126+
// skip check if shell_exec function is disabled
127+
if (!\function_exists('shell_exec')) {
128128
return false;
129129
}
130130

131-
exec('stty 2>&1', $output, $exitcode);
132-
133-
return self::$stty = 0 === $exitcode;
131+
return self::$stty = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
134132
}
135133

136134
private static function initDimensions(): void

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public function testAskHiddenResponse()
428428
$this->assertEquals('8AM', $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("8AM\n")), $this->createOutputInterface(), $question));
429429
}
430430

431-
public function testAskHiddenResponseTrimmed()
431+
public function testAskHiddenResponseNotTrimmed()
432432
{
433433
if ('\\' === \DIRECTORY_SEPARATOR) {
434434
$this->markTestSkipped('This test is not supported on Windows');
@@ -440,7 +440,7 @@ public function testAskHiddenResponseTrimmed()
440440
$question->setHidden(true);
441441
$question->setTrimmable(false);
442442

443-
$this->assertEquals(' 8AM', $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream(' 8AM')), $this->createOutputInterface(), $question));
443+
$this->assertEquals(' 8AM'.\PHP_EOL, $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream(' 8AM'.\PHP_EOL)), $this->createOutputInterface(), $question));
444444
}
445445

446446
public function testAskMultilineResponseWithEOF()

src/Symfony/Component/Console/Tests/TerminalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public function testSttyOnWindows()
7777
$this->markTestSkipped('Must be on windows');
7878
}
7979

80-
$sttyString = exec('(stty -a | grep columns) 2>&1', $output, $exitcode);
81-
if (0 !== $exitcode) {
80+
$sttyString = shell_exec('(stty -a | grep columns) 2> NUL');
81+
if (!$sttyString) {
8282
$this->markTestSkipped('Must have stty support');
8383
}
8484

src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,17 @@ public function testGenerateAbsoluteUrlWithRequestContextAwareInterface($path, $
8282

8383
$requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path);
8484
$contextAware = new class($requestContext) implements RequestContextAwareInterface {
85-
private $requestContext;
86-
87-
public function __construct($requestContext)
88-
{
89-
$this->requestContext = $requestContext;
85+
public function __construct(
86+
private RequestContext $requestContext,
87+
) {
9088
}
9189

92-
public function setContext(RequestContext $context)
90+
public function setContext(RequestContext $context): void
9391
{
9492
$this->requestContext = $context;
9593
}
9694

97-
public function getContext()
95+
public function getContext(): RequestContext
9896
{
9997
return $this->requestContext;
10098
}

src/Symfony/Component/Security/Http/EventListener/CsrfTokenClearingLogoutListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1515
use Symfony\Component\Security\Csrf\TokenStorage\ClearableTokenStorageInterface;
16+
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
1617
use Symfony\Component\Security\Http\Event\LogoutEvent;
1718

1819
/**
@@ -31,6 +32,10 @@ public function __construct(ClearableTokenStorageInterface $csrfTokenStorage)
3132

3233
public function onLogout(LogoutEvent $event): void
3334
{
35+
if ($this->csrfTokenStorage instanceof SessionTokenStorage && !$event->getRequest()->hasPreviousSession()) {
36+
return;
37+
}
38+
3439
$this->csrfTokenStorage->clear();
3540
}
3641

src/Symfony/Component/Translation/Loader/ArrayLoader.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ private function flatten(array $messages): array
4343
foreach ($messages as $key => $value) {
4444
if (\is_array($value)) {
4545
foreach ($this->flatten($value) as $k => $v) {
46-
$result[$key.'.'.$k] = $v;
46+
if (null !== $v) {
47+
$result[$key.'.'.$k] = $v;
48+
}
4749
}
48-
} else {
50+
} elseif (null !== $value) {
4951
$result[$key] = $value;
5052
}
5153
}

src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ public function testLoad()
3030
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
3131
}
3232

33+
public function testLoadNonStringMessages()
34+
{
35+
$loader = new YamlFileLoader();
36+
$resource = __DIR__.'/../fixtures/non-string.yml';
37+
$catalogue = $loader->load($resource, 'en', 'domain1');
38+
39+
$this->assertSame(['root.foo2' => '', 'root.bar' => 'bar'], $catalogue->all('domain1'));
40+
}
41+
3342
public function testLoadDoesNothingIfEmpty()
3443
{
3544
$loader = new YamlFileLoader();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root:
2+
foo1:
3+
foo2: ''
4+
bar: 'bar'

0 commit comments

Comments
 (0)
0