Skip to content

Commit 09f28bc

Browse files
Merge branch '6.4' into 7.0
* 6.4: (32 commits) [Validator] Fix registering "is_valid()" for `#[Expression]` [Scheduler] Trigger unique messages at runtime [Scheduler] Fix CHANGELOG [Clock] Add `DatePoint`: an immutable DateTime implementation with stricter error handling and return types [Scheduler] Allow modifying the schedule at runtime and recalculate heap [Cache] Fix Redis6Proxy [Finder] Disable failing test about open_basedir Fix merge Fix merge Minor CS fixes Deprecate `Kernel::stripComments()` Remove setAccessible reflection call in tests [Notifier] Telegram Bridge add escaping for \ [Component][AssertMapper] add type hint of an argument in asset mapper command [Translation] [Phrase] Refacto ReadConfig and WriteConfig into arrays [Routing] Fix routing collection defaults when adding a new route to a collection [Messenger] Fix cloned TraceableStack not unstacking the stack independently [Translation] Add `--as-tree` option to `translation:pull` command [Mime] Allow to add some headers as a strings [Translation] Give current locale to locale switcher runWithLocale callback ...
2 parents 6acb9c5 + 869da98 commit 09f28bc

33 files changed

+344
-72
lines changed

CacheWarmer/ConfigBuilderCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(KernelInterface $kernel, LoggerInterface $logger = n
4242
*/
4343
public function warmUp(string $cacheDir): array
4444
{
45-
$generator = new ConfigBuilderGenerator($cacheDir);
45+
$generator = new ConfigBuilderGenerator($this->kernel->getBuildDir());
4646

4747
foreach ($this->kernel->getBundles() as $bundle) {
4848
$extension = $bundle->getContainerExtension();

Command/ConfigDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private static function buildPathsCompletion(array $paths, string $prefix = ''):
259259
$completionPaths = [];
260260
foreach ($paths as $key => $values) {
261261
if (\is_array($values)) {
262-
$completionPaths = $completionPaths + self::buildPathsCompletion($values, $prefix.$key.'.');
262+
$completionPaths += self::buildPathsCompletion($values, $prefix.$key.'.');
263263
} else {
264264
$completionPaths[$prefix.$key] = null;
265265
}

Command/TranslationDebugCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
212212
$states[] = self::MESSAGE_MISSING;
213213

214214
if (!$input->getOption('only-unused')) {
215-
$exitCode = $exitCode | self::EXIT_CODE_MISSING;
215+
$exitCode |= self::EXIT_CODE_MISSING;
216216
}
217217
}
218218
} elseif ($currentCatalogue->defines($messageId, $domain)) {
219219
$states[] = self::MESSAGE_UNUSED;
220220

221221
if (!$input->getOption('only-missing')) {
222-
$exitCode = $exitCode | self::EXIT_CODE_UNUSED;
222+
$exitCode |= self::EXIT_CODE_UNUSED;
223223
}
224224
}
225225

@@ -233,7 +233,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
233233
if ($fallbackCatalogue->defines($messageId, $domain) && $value === $fallbackCatalogue->get($messageId, $domain)) {
234234
$states[] = self::MESSAGE_EQUALS_FALLBACK;
235235

236-
$exitCode = $exitCode | self::EXIT_CODE_FALLBACK;
236+
$exitCode |= self::EXIT_CODE_FALLBACK;
237237

238238
break;
239239
}

Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
254254
foreach ($tagData as $parameters) {
255255
$output .= "\n".'- Tag: `'.$tagName.'`';
256256
foreach ($parameters as $name => $value) {
257-
$output .= "\n".' - '.ucfirst($name).': '.$value;
257+
$output .= "\n".' - '.ucfirst($name).': '.(\is_array($value) ? $this->formatParameter($value) : $value);
258258
}
259259
}
260260
}

Console/Descriptor/TextDescriptor.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ protected function describeContainerServices(ContainerBuilder $container, array
209209
if (!isset($maxTags[$key])) {
210210
$maxTags[$key] = \strlen($key);
211211
}
212+
if (\is_array($value)) {
213+
$value = $this->formatParameter($value);
214+
}
215+
212216
if (\strlen($value) > $maxTags[$key]) {
213217
$maxTags[$key] = \strlen($value);
214218
}
@@ -233,7 +237,11 @@ protected function describeContainerServices(ContainerBuilder $container, array
233237
foreach ($this->sortByPriority($definition->getTag($showTag)) as $key => $tag) {
234238
$tagValues = [];
235239
foreach ($tagsNames as $tagName) {
236-
$tagValues[] = $tag[$tagName] ?? '';
240+
if (\is_array($tagValue = $tag[$tagName] ?? '')) {
241+
$tagValue = $this->formatParameter($tagValue);
242+
}
243+
244+
$tagValues[] = $tagValue;
237245
}
238246
if (0 === $key) {
239247
$tableRows[] = array_merge([$serviceId], $tagValues, [$definition->getClass()]);
@@ -275,7 +283,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
275283
$tagInformation = [];
276284
foreach ($tags as $tagName => $tagData) {
277285
foreach ($tagData as $tagParameters) {
278-
$parameters = array_map(fn ($key, $value) => sprintf('<info>%s</info>: %s', $key, $value), array_keys($tagParameters), array_values($tagParameters));
286+
$parameters = array_map(fn ($key, $value) => sprintf('<info>%s</info>: %s', $key, \is_array($value) ? $this->formatParameter($value) : $value), array_keys($tagParameters), array_values($tagParameters));
279287
$parameters = implode(', ', $parameters);
280288

281289
if ('' === $parameters) {

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode, callable $e
17161716
continue;
17171717
}
17181718
if (\is_array($scopedConfig['retry_failed'])) {
1719-
$scopedConfig['retry_failed'] = $scopedConfig['retry_failed'] + $config['default_options']['retry_failed'];
1719+
$scopedConfig['retry_failed'] += $config['default_options']['retry_failed'];
17201720
}
17211721
}
17221722

DependencyInjection/FrameworkExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
use Symfony\Component\Translation\Translator;
168168
use Symfony\Component\Uid\Factory\UuidFactory;
169169
use Symfony\Component\Uid\UuidV4;
170+
use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
170171
use Symfony\Component\Validator\ConstraintValidatorInterface;
171172
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
172173
use Symfony\Component\Validator\ObjectInitializerInterface;
@@ -1643,6 +1644,10 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
16431644
if (!class_exists(ExpressionLanguage::class)) {
16441645
$container->removeDefinition('validator.expression_language');
16451646
}
1647+
1648+
if (!class_exists(ExpressionLanguageProvider::class)) {
1649+
$container->removeDefinition('validator.expression_language_provider');
1650+
}
16461651
}
16471652

16481653
private function registerValidatorMapping(ContainerBuilder $container, array $config, array &$files): void

Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@
235235
<xsd:attribute name="logging" type="xsd:boolean" />
236236
<xsd:attribute name="formatter" type="xsd:string" />
237237
<xsd:attribute name="cache-dir" type="xsd:string" />
238+
<xsd:attribute name="default-path" type="xsd:string" />
238239
</xsd:complexType>
239240

240241
<xsd:complexType name="pseudo_localization">

Resources/config/validator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
1616
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1717
use Symfony\Component\Validator\Constraints\EmailValidator;
18+
use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
1819
use Symfony\Component\Validator\Constraints\ExpressionValidator;
1920
use Symfony\Component\Validator\Constraints\NoSuspiciousCharactersValidator;
2021
use Symfony\Component\Validator\Constraints\NotCompromisedPasswordValidator;
@@ -82,11 +83,16 @@
8283

8384
->set('validator.expression_language', ExpressionLanguage::class)
8485
->args([service('cache.validator_expression_language')->nullOnInvalid()])
86+
->call('registerProvider', [
87+
service('validator.expression_language_provider')->ignoreOnInvalid(),
88+
])
8589

8690
->set('cache.validator_expression_language')
8791
->parent('cache.system')
8892
->tag('cache.pool')
8993

94+
->set('validator.expression_language_provider', ExpressionLanguageProvider::class)
95+
9096
->set('validator.email', EmailValidator::class)
9197
->args([
9298
abstract_arg('Default mode'),
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
13+
14+
use Symfony\Bundle\FrameworkBundle\CacheWarmer\ConfigBuilderCacheWarmer;
15+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
16+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
17+
use Symfony\Component\Config\Loader\LoaderInterface;
18+
use Symfony\Component\Filesystem\Filesystem;
19+
use Symfony\Component\HttpKernel\Kernel;
20+
21+
class ConfigBuilderCacheWarmerTest extends TestCase
22+
{
23+
private $varDir;
24+
25+
protected function setUp(): void
26+
{
27+
$this->varDir = sys_get_temp_dir().'/'.uniqid();
28+
$fs = new Filesystem();
29+
$fs->mkdir($this->varDir);
30+
}
31+
32+
protected function tearDown(): void
33+
{
34+
$fs = new Filesystem();
35+
$fs->remove($this->varDir);
36+
unset($this->varDir);
37+
}
38+
39+
public function testBuildDirIsUsedAsConfigBuilderOutputDir()
40+
{
41+
$kernel = new class($this->varDir) extends Kernel {
42+
private $varDir;
43+
44+
public function __construct(string $varDir)
45+
{
46+
parent::__construct('test', false);
47+
48+
$this->varDir = $varDir;
49+
}
50+
51+
public function registerBundles(): iterable
52+
{
53+
yield new FrameworkBundle();
54+
}
55+
56+
public function getBuildDir(): string
57+
{
58+
return $this->varDir.'/build';
59+
}
60+
61+
public function getCacheDir(): string
62+
{
63+
return $this->varDir.'/cache';
64+
}
65+
66+
public function registerContainerConfiguration(LoaderInterface $loader)
67+
{
68+
}
69+
};
70+
$kernel->boot();
71+
72+
$warmer = new ConfigBuilderCacheWarmer($kernel);
73+
$warmer->warmUp($kernel->getCacheDir());
74+
75+
self::assertDirectoryExists($kernel->getBuildDir().'/Symfony');
76+
self::assertDirectoryDoesNotExist($kernel->getCacheDir().'/Symfony');
77+
}
78+
}

0 commit comments

Comments
 (0)