Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fb08d9c

Browse filesBrowse files
committed
Merge branch '4.4' into 5.0
* 4.4: Fixed translations file dumper behavior When set, get secret from config variable [FrameworkBundle] Set the parameter bag as resolved in ContainerLintCommand [SecurityBundle] Fix switch_user provider configuration handling
2 parents 9dbeab9 + 4af59c2 commit fb08d9c
Copy full SHA for fb08d9c

File tree

Expand file treeCollapse file tree

6 files changed

+66
-33
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+66
-33
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ContainerLintCommand.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
2121
use Symfony\Component\DependencyInjection\ContainerBuilder;
2222
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
23+
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
2324

2425
final class ContainerLintCommand extends Command
2526
{
@@ -71,7 +72,11 @@ private function getContainerBuilder(): ContainerBuilder
7172
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
7273
$container = $buildContainer();
7374
} else {
74-
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
75+
(new XmlFileLoader($container = new ContainerBuilder($parameterBag = new EnvPlaceholderParameterBag()), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
76+
77+
$refl = new \ReflectionProperty($parameterBag, 'resolved');
78+
$refl->setAccessible(true);
79+
$refl->setValue($parameterBag, true);
7580
}
7681

7782
return $this->containerBuilder = $container;

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AnonymousFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AnonymousFactory.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ class AnonymousFactory implements SecurityFactoryInterface
2424
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
2525
{
2626
if (null === $config['secret']) {
27-
$firewall['anonymous']['secret'] = new Parameter('container.build_hash');
27+
$config['secret'] = new Parameter('container.build_hash');
2828
}
2929

3030
$listenerId = 'security.authentication.listener.anonymous.'.$id;
3131
$container
3232
->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.anonymous'))
33-
->replaceArgument(1, $firewall['anonymous']['secret'])
33+
->replaceArgument(1, $config['secret'])
3434
;
3535

3636
$providerId = 'security.authentication.provider.anonymous.'.$id;
3737
$container
3838
->setDefinition($providerId, new ChildDefinition('security.authentication.provider.anonymous'))
39-
->replaceArgument(0, $firewall['anonymous']['secret'])
39+
->replaceArgument(0, $config['secret'])
4040
;
4141

4242
return [$providerId, $listenerId, $defaultEntryPoint];

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ private function createExceptionListener(ContainerBuilder $container, array $con
676676
return $exceptionListenerId;
677677
}
678678

679-
private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, string $defaultProvider, bool $stateless): string
679+
private function createSwitchUserListener(ContainerBuilder $container, string $id, array $config, ?string $defaultProvider, bool $stateless): string
680680
{
681681
$userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider;
682682

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,30 @@ public function sessionConfigurationProvider()
389389
];
390390
}
391391

392+
public function testSwitchUserWithSeveralDefinedProvidersButNoFirewallRootProviderConfigured()
393+
{
394+
$container = $this->getRawContainer();
395+
$container->loadFromExtension('security', [
396+
'providers' => [
397+
'first' => ['id' => 'foo'],
398+
'second' => ['id' => 'bar'],
399+
],
400+
401+
'firewalls' => [
402+
'foobar' => [
403+
'switch_user' => [
404+
'provider' => 'second',
405+
],
406+
'anonymous' => true,
407+
],
408+
],
409+
]);
410+
411+
$container->compile();
412+
413+
$this->assertEquals(new Reference('security.user.provider.concrete.second'), $container->getDefinition('security.authentication.switchuser_listener.foobar')->getArgument(1));
414+
}
415+
392416
protected function getRawContainer()
393417
{
394418
$container = new ContainerBuilder();

‎src/Symfony/Component/Translation/Dumper/FileDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Dumper/FileDumper.php
+22-21Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,37 @@ public function dump(MessageCatalogue $messages, array $options = [])
5151
throw new InvalidArgumentException('The file dumper needs a path option.');
5252
}
5353

54+
$hasMessageFormatter = class_exists(\MessageFormatter::class);
55+
5456
// save a file for each domain
5557
foreach ($messages->getDomains() as $domain) {
56-
$fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale());
57-
if (!file_exists($fullpath)) {
58-
$directory = \dirname($fullpath);
58+
if ($hasMessageFormatter) {
59+
$defaultDomain = $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX;
60+
$altDomain = $domain;
61+
} else {
62+
$defaultDomain = $domain;
63+
$altDomain = $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX;
64+
}
65+
$defaultPath = $options['path'].'/'.$this->getRelativePath($defaultDomain, $messages->getLocale());
66+
$altPath = $options['path'].'/'.$this->getRelativePath($altDomain, $messages->getLocale());
67+
68+
if (!file_exists($defaultPath) && file_exists($altPath)) {
69+
[$defaultPath, $altPath] = [$altPath, $defaultPath];
70+
}
71+
72+
if (!file_exists($defaultPath)) {
73+
$directory = \dirname($defaultPath);
5974
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {
6075
throw new RuntimeException(sprintf('Unable to create directory "%s".', $directory));
6176
}
6277
}
6378

64-
$intlDomain = $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX;
65-
$intlMessages = $messages->all($intlDomain);
66-
67-
if ($intlMessages) {
68-
$intlPath = $options['path'].'/'.$this->getRelativePath($intlDomain, $messages->getLocale());
69-
file_put_contents($intlPath, $this->formatCatalogue($messages, $intlDomain, $options));
70-
71-
$messages->replace([], $intlDomain);
72-
73-
try {
74-
if ($messages->all($domain)) {
75-
file_put_contents($fullpath, $this->formatCatalogue($messages, $domain, $options));
76-
}
77-
continue;
78-
} finally {
79-
$messages->replace($intlMessages, $intlDomain);
80-
}
79+
if (file_exists($altPath)) {
80+
// clear alternative translation file
81+
file_put_contents($altPath, $this->formatCatalogue(new MessageCatalogue($messages->getLocale()), $altDomain, $options));
8182
}
8283

83-
file_put_contents($fullpath, $this->formatCatalogue($messages, $domain, $options));
84+
file_put_contents($defaultPath, $this->formatCatalogue($messages, $domain, $options));
8485
}
8586
}
8687

‎src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ public function testDump()
2727
$dumper = new ConcreteFileDumper();
2828
$dumper->dump($catalogue, ['path' => $tempDir]);
2929

30-
$this->assertFileExists($tempDir.'/messages.en.concrete');
30+
$suffix = class_exists(\MessageFormatter::class) ? '+intl-icu' : '';
31+
$this->assertFileExists($tempDir."/messages$suffix.en.concrete");
3132

32-
@unlink($tempDir.'/messages.en.concrete');
33+
@unlink($tempDir."/messages$suffix.en.concrete");
3334
}
3435

36+
/**
37+
* @requires extension intl
38+
*/
3539
public function testDumpIntl()
3640
{
3741
$tempDir = sys_get_temp_dir();
@@ -42,13 +46,11 @@ public function testDumpIntl()
4246
$catalogue->add(['bar' => 'foo'], 'd2+intl-icu');
4347

4448
$dumper = new ConcreteFileDumper();
45-
@unlink($tempDir.'/d2.en.concrete');
4649
$dumper->dump($catalogue, ['path' => $tempDir]);
4750

48-
$this->assertStringEqualsFile($tempDir.'/d1.en.concrete', 'foo=bar');
49-
@unlink($tempDir.'/d1.en.concrete');
51+
$this->assertFileNotExists($tempDir.'/d1.en.concrete');
5052

51-
$this->assertStringEqualsFile($tempDir.'/d1+intl-icu.en.concrete', 'bar=foo');
53+
$this->assertStringEqualsFile($tempDir.'/d1+intl-icu.en.concrete', 'bar=foo&foo=bar');
5254
@unlink($tempDir.'/d1+intl-icu.en.concrete');
5355

5456
$this->assertFileNotExists($tempDir.'/d2.en.concrete');
@@ -60,7 +62,8 @@ public function testDumpCreatesNestedDirectoriesAndFile()
6062
{
6163
$tempDir = sys_get_temp_dir();
6264
$translationsDir = $tempDir.'/test/translations';
63-
$file = $translationsDir.'/messages.en.concrete';
65+
$suffix = class_exists(\MessageFormatter::class) ? '+intl-icu' : '';
66+
$file = $translationsDir."/messages$suffix.en.concrete";
6467

6568
$catalogue = new MessageCatalogue('en');
6669
$catalogue->add(['foo' => 'bar']);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.