Skip to content

Commit e6df8bc

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: fix typo in PULL_REQUEST_TEMPLATE.md Allow to disable lock without defining a resource [HttpFoundation] Compare cookie with null value as empty string in ResponseCookieValueSame
2 parents fac20dc + ebfba25 commit e6df8bc

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,12 +1246,15 @@ private function addLockSection(ArrayNodeDefinition $rootNode, callable $enableI
12461246
})
12471247
->end()
12481248
->addDefaultsIfNotSet()
1249+
->validate()
1250+
->ifTrue(static function (array $config) { return $config['enabled'] && !$config['resources']; })
1251+
->thenInvalid('At least one resource must be defined.')
1252+
->end()
12491253
->fixXmlConfig('resource')
12501254
->children()
12511255
->arrayNode('resources')
12521256
->normalizeKeys(false)
12531257
->useAttributeAsKey('name')
1254-
->requiresAtLeastOneElement()
12551258
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
12561259
->beforeNormalization()
12571260
->ifString()->then(function ($v) { return ['default' => $v]; })

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,31 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
365365
]);
366366
}
367367

368+
public function testLockCanBeDisabled()
369+
{
370+
$processor = new Processor();
371+
$configuration = new Configuration(true);
372+
373+
$config = $processor->processConfiguration($configuration, [
374+
['lock' => ['enabled' => false]],
375+
]);
376+
377+
$this->assertFalse($config['lock']['enabled']);
378+
}
379+
380+
public function testEnabledLockNeedsResources()
381+
{
382+
$processor = new Processor();
383+
$configuration = new Configuration(true);
384+
385+
$this->expectException(InvalidConfigurationException::class);
386+
$this->expectExceptionMessage('Invalid configuration for path "framework.lock": At least one resource must be defined.');
387+
388+
$processor->processConfiguration($configuration, [
389+
['lock' => ['enabled' => true]],
390+
]);
391+
}
392+
368393
protected static function getBundleDefaultConfig()
369394
{
370395
return [

0 commit comments

Comments
 (0)