10000 [FrameworkBundle][Lock] Allow to disable lock without defining a resource by MatTheCat · Pull Request #48119 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle][Lock] Allow to disable lock without defining a resource #48119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow to disable lock without defining a resource
  • Loading branch information
MatTheCat committed Nov 5, 2022
commit 0aad8c8892f04bac43004088e8e56d83df5307f3
Original file line number Diff line number Diff line change
Expand Up @@ -1117,12 +1117,15 @@ private function addLockSection(ArrayNodeDefinition $rootNode)
})
->end()
->addDefaultsIfNotSet()
->validate()
->ifTrue(static function (array $config) { return $config['enabled'] && !$config['resources']; })
->thenInvalid('At least one resource must be defined.')
->end()
->fixXmlConfig('resource')
->children()
->arrayNode('resources')
->normalizeKeys(false)
->useAttributeAsKey('name')
->requiresAtLeastOneElement()
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
->beforeNormalization()
->ifString()->then(function ($v) { return ['default' => $v]; })
Expand Down
< 4217 td class="blob-code blob-code-context js-file-line"> return [
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,31 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
]);
}

public function testLockCanBeDisabled()
{
$processor = new Processor();
$configuration = new Configuration(true);

$config = $processor->processConfiguration($configuration, [
['lock' => ['enabled' => false]],
]);

$this->assertFalse($config['lock']['enabled']);
}

public function testEnabledLockNeedsResources()
{
$processor = new Processor();
$configuration = new Configuration(true);

$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('Invalid configuration for path "framework.lock": At least one resource must be defined.');

$processor->processConfiguration($configuration, [
['lock' => ['enabled' => true]],
]);
}

protected static function getBundleDefaultConfig()
{
Expand Down
0