8000 Merge branch '5.4' into 6.0 · jschaedl/symfony@7c53e00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c53e00

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 ea41414 + d84aec5 commit 7c53e00

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
@@ -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]; })

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

Lines changed: 25 additions & 0 deletions
@@ -365,6 +365,31 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
Original file line numberDiff line numberDiff line change
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 [

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)
0