Skip to content

Commit db1cf2b

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: 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 b2a35c7 + 7c53e00 commit db1cf2b

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| Bug fix? | yes/no
55
| New feature? | yes/no <!-- please update src/**/CHANGELOG.md files -->
66
| Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
7-
| Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
7+
| Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
88
| License | MIT
99
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
1010
<!--

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,12 +1266,15 @@ private function addLockSection(ArrayNodeDefinition $rootNode, callable $enableI
12661266
})
12671267
->end()
12681268
->addDefaultsIfNotSet()
1269+
->validate()
1270+
->ifTrue(static function (array $config) { return $config['enabled'] && !$config['resources']; })
1271+
->thenInvalid('At least one resource must be defined.')
1272+
->end()
12691273
->fixXmlConfig('resource')
12701274
->children()
12711275
->arrayNode('resources')
12721276
->normalizeKeys(false)
12731277
->useAttributeAsKey('name')
1274-
->requiresAtLeastOneElement()
12751278
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
12761279
->beforeNormalization()
12771280
->ifString()->then(function ($v) { return ['default' => $v]; })

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,31 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
427427
]);
428428
}
429429

430+
public function testLockCanBeDisabled()
431+
{
432+
$processor = new Processor();
433+
$configuration = new Configuration(true);
434+
435+
$config = $processor->processConfiguration($configuration, [
436+
['lock' => ['enabled' => false]],
437+
]);
438+
439+
$this->assertFalse($config['lock']['enabled']);
440+
}
441+
442+
public function testEnabledLockNeedsResources()
443+
{
444+
$processor = new Processor();
445+
$configuration = new Configuration(true);
446+
447+
$this->expectException(InvalidConfigurationException::class);
448+
$this->expectExceptionMessage('Invalid configuration for path "framework.lock": At least one resource must be defined.');
449+
450+
$processor->processConfiguration($configuration, [
451+
['lock' => ['enabled' => true]],
452+
]);
453+
}
454+
430455
protected static function getBundleDefaultConfig()
431456
{
432457
return [

src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseCookieValueSame.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function matches($response): bool
5959
return false;
6060
}
6161

62-
return $this->value === $cookie->getValue();
62+
return $this->value === (string) $cookie->getValue();
6363
}
6464

6565
/**

src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseCookieValueSameTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ public function testConstraint()
4141

4242
$this->fail();
4343
}
44+
45+
public function testCookieWithNullValueIsComparedAsEmptyString()
46+
{
47+
$response = new Response();
48+
$response->headers->setCookie(Cookie::create('foo', null, 0, '/path'));
49+
50+
$this->assertTrue((new ResponseCookieValueSame('foo', '', '/path'))->evaluate($response, '', true));
51+
}
4452
}

0 commit comments

Comments
 (0)