Skip to content

Commit ebfba25

Browse files
committed
Merge branch '4.4' into 5.4
* 4.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 00ac4d7 + d8cf255 commit ebfba25

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
@@ -1275,12 +1275,15 @@ private function addLockSection(ArrayNodeDefinition $rootNode, callable $enableI
12751275
})
12761276
->end()
12771277
->addDefaultsIfNotSet()
1278+
->validate()
1279+
->ifTrue(static function (array $config) { return $config['enabled'] && !$config['resources']; })
1280+
->thenInvalid('At least one resource must be defined.')
1281+
->end()
12781282
->fixXmlConfig('resource')
12791283
->children()
12801284
->arrayNode('resources')
12811285
->normalizeKeys(false)
12821286
->useAttributeAsKey('name')
1283-
->requiresAtLeastOneElement()
12841287
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
12851288
->beforeNormalization()
12861289
->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)