Skip to content

Commit b5e1663

Browse files
Merge branch '4.4'
* 4.4: [Messenger] Perform no deep merging of bus middleware [HttpFoundation] Added possibility to configure expiration time in redis session handler [FrameworkBundle] Remove project dir from Translator cache vary scanned directories [HttpFoundation] Allow redirecting to URLs that contain a semicolon Drop useless executable bit [DoctrineBridge] Improve queries parameters display in Profiler catch exceptions when using PDO directly [SecurityBundle] fix failing test
2 parents 3629157 + dbb892f commit b5e1663

File tree

7 files changed

+85
-12
lines changed

7 files changed

+85
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ CHANGELOG
3838
* Overriding the methods `KernelTestCase::tearDown()` and `WebTestCase::tearDown()` without the `void` return-type is deprecated.
3939
* Added new `error_controller` configuration to handle system exceptions
4040
* Added sort option for `translation:update` command.
41-
* [BC Break] The `framework.messenger.routing.senders` config key is not deep merged anymore.
41+
* [BC Break] The `framework.messenger.routing.senders` config key is not deeply merged anymore.
4242
* Added `secrets:*` commands and `%env(secret:...)%` processor to deal with secrets seamlessly.
4343
* Made `framework.session.handler_id` accept a DSN
4444
* Marked the `RouterDataCollector` class as `@final`.
45+
* [BC Break] The `framework.messenger.buses.<name>.middleware` config key is not deeply merged anymore.
4546

4647
4.3.0
4748
-----

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ function ($a) {
11561156
->defaultTrue()
11571157
->end()
11581158
->arrayNode('middleware')
1159+
->performNoDeepMerging()
11591160
->beforeNormalization()
11601161
->ifTrue(function ($v) { return \is_string($v) || (\is_array($v) && !\is_int(key($v))); })
11611162
->then(function ($v) { return [$v]; })

DependencyInjection/FrameworkExtension.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,11 +1115,18 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
11151115
$files[$locale][] = (string) $file;
11161116
}
11171117

1118+
$projectDir = $container->getParameter('kernel.project_dir');
1119+
11181120
$options = array_merge(
11191121
$translator->getArgument(4),
11201122
[
11211123
'resource_files' => $files,
1122-
'scanned_directories' => array_merge($dirs, $nonExistingDirs),
1124+
'scanned_directories' => $scannedDirectories = array_merge($dirs, $nonExistingDirs),
1125+
'cache_vary' => [
1126+
'scanned_directories' => array_map(static function (string $dir) use ($projectDir): string {
1127+
return 0 === strpos($dir, $projectDir.'/') ? substr($dir, 1 + \strlen($projectDir)) : $dir;
1128+
}, $scannedDirectories),
1129+
],
11231130
]
11241131
);
11251132

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,64 @@ public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefau
256256
]);
257257
}
258258

259+
public function testBusMiddlewareDontMerge()
260+
{
261+
$processor = new Processor();
262+
$configuration = new Configuration(true);
263+
$config = $processor->processConfiguration($configuration, [
264+
[
265+
'messenger' => [
266+
'default_bus' => 'existing_bus',
267+
'buses' => [
268+
'existing_bus' => [
269+
'middleware' => 'existing_bus.middleware',
270+
],
271+
'common_bus' => [
272+
'default_middleware' => false,
273+
'middleware' => 'common_bus.old_middleware',
274+
],
275+
],
276+
],
277+
],
278+
[
279+
'messenger' => [
280+
'buses' => [
281+
'common_bus' => [
282+
'middleware' => 'common_bus.new_middleware',
283+
],
284+
'new_bus' => [
285+
'middleware' => 'new_bus.middleware',
286+
],
287+
],
288+
],
289+
],
290+
]);
291+
292+
$this->assertEquals(
293+
[
294+
'existing_bus' => [
295+
'default_middleware' => true,
296+
'middleware' => [
297+
['id' => 'existing_bus.middleware', 'arguments' => []],
298+
],
299+
],
300+
'common_bus' => [
301+
'default_middleware' => false,
302+
'middleware' => [
303+
['id' => 'common_bus.new_middleware', 'arguments' => []],
304+
],
305+
],
306+
'new_bus' => [
307+
'default_middleware' => true,
308+
'middleware' => [
309+
['id' => 'new_bus.middleware', 'arguments' => []],
310+
],
311+
],
312+
],
313+
$config['messenger']['buses']
314+
);
315+
}
316+
259317
protected static function getBundleDefaultConfig()
260318
{
261319
return [

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ function ($directory) {
738738
);
739739

740740
$this->assertNotEmpty($nonExistingDirectories, 'FrameworkBundle should pass non existing directories to Translator');
741+
742+
$this->assertSame('Fixtures/translations', $options['cache_vary']['scanned_directories'][3]);
741743
}
742744

743745
public function testTranslatorMultipleFallbacks()

Tests/Translation/TranslatorTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,10 @@ public function testCachedCatalogueIsReDumpedWhenScannedDirectoriesChange()
217217
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
218218
],
219219
],
220-
'scanned_directories' => [
221-
__DIR__.'/../Fixtures/Resources/translations/',
220+
'cache_vary' => [
221+
'scanned_directories' => [
222+
'/Fixtures/Resources/translations/',
223+
],
222224
],
223225
], 'yml');
224226

@@ -233,9 +235,11 @@ public function testCachedCatalogueIsReDumpedWhenScannedDirectoriesChange()
233235
__DIR__.'/../Fixtures/Resources/translations2/ccc.fr.yml',
234236
],
235237
],
236-
'scanned_directories' => [
237-
__DIR__.'/../Fixtures/Resources/translations/',
238-
__DIR__.'/../Fixtures/Resources/translations2/',
238+
'cache_vary' => [
239+
'scanned_directories' => [
240+
'/Fixtures/Resources/translations/',
241+
'/Fixtures/Resources/translations2/',
242+
],
239243
],
240244
], 'yml');
241245

Translation/Translator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Translator extends BaseTranslator implements WarmableInterface
3434
'debug' => false,
3535
'resource_files' => [],
3636
'scanned_directories' => [],
37+
'cache_vary' => [],
3738
];
3839

3940
/**
@@ -61,9 +62,10 @@ class Translator extends BaseTranslator implements WarmableInterface
6162
*
6263
* Available options:
6364
*
64-
* * cache_dir: The cache directory (or null to disable caching)
65-
* * debug: Whether to enable debugging or not (false by default)
65+
* * cache_dir: The cache directory (or null to disable caching)
66+
* * debug: Whether to enable debugging or not (false by default)
6667
* * resource_files: List of translation resources available grouped by locale.
68+
* * cache_vary: An array of data that is serialized to generate the cached catalogue name.
6769
*
6870
* @throws InvalidArgumentException
6971
*/
@@ -82,9 +84,7 @@ public function __construct(ContainerInterface $container, MessageFormatterInter
8284
$this->resourceFiles = $this->options['resource_files'];
8385
$this->scannedDirectories = $this->options['scanned_directories'];
8486

85-
parent::__construct($defaultLocale, $formatter, $this->options['cache_dir'], $this->options['debug'], [
86-
'scanned_directories' => $this->scannedDirectories,
87-
]);
87+
parent::__construct($defaultLocale, $formatter, $this->options['cache_dir'], $this->options['debug'], $this->options['cache_vary']);
8888
}
8989

9090
/**

0 commit comments

Comments
 (0)