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

Skip to content

Commit d84aec5

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 4f65a9c + 3752e65 commit d84aec5

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

src/Symfony/Bundle/FrameworkBundle/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 [

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