Skip to content

Commit

Permalink
Merge branch '6.2' into 6.3
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed May 19, 2023
2 parents 8bf7f41 + 64113df commit f72b2cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Loader/ArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ private function flatten(array $messages): array
foreach ($messages as $key => $value) {
if (\is_array($value)) {
foreach ($this->flatten($value) as $k => $v) {
$result[$key.'.'.$k] = $v;
if (null !== $v) {
$result[$key.'.'.$k] = $v;
}
}
} else {
} elseif (null !== $value) {
$result[$key] = $value;
}
}
Expand Down
9 changes: 9 additions & 0 deletions Tests/Loader/YamlFileLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ public function testLoad()
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}

public function testLoadNonStringMessages()
{
$loader = new YamlFileLoader();
$resource = __DIR__.'/../fixtures/non-string.yml';
$catalogue = $loader->load($resource, 'en', 'domain1');

$this->assertSame(['root.foo2' => '', 'root.bar' => 'bar'], $catalogue->all('domain1'));
}

public function testLoadDoesNothingIfEmpty()
{
$loader = new YamlFileLoader();
Expand Down
4 changes: 4 additions & 0 deletions Tests/fixtures/non-string.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root:
foo1:
foo2: ''
bar: 'bar'

0 comments on commit f72b2cb

Please sign in to comment.