8000 Merge branch '5.2' into 5.x · symfony/symfony@48a191c · GitHub
[go: up one dir, main page]

Skip to content

Commit 48a191c

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [WebProfiler] Use ControllerReference instead of URL in twig render() [Serializer][Validator] Update some phpDoc relative to "getters" Update README.md [SecurityBundle] Empty line starting with dash under "access_control" causes all rules to be skipped [Cache] Apply NullAdapter as Null Object
2 parents c69cc3f + 255283c commit 48a191c

File tree

10 files changed

+71
-15
lines changed

10 files changed

+71
-15
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ private function createAuthorization(array $config, ContainerBuilder $container)
231231
$attributes[] = $this->createExpression($container, $access['allow_if']);
232232
}
233233

234+
$emptyAccess = 0 === \count(array_filter($access));
235+
236+
if ($emptyAccess) {
237+
throw new InvalidConfigurationException('One or more access control items are empty. Did you accidentally add lines only containing a "-" under "security.access_control"?');
238+
}
239+
234240
$container->getDefinition('security.access_map')
235241
->addMethodCall('add', [$matcher, $attributes, $access['requires_channel']]);
236242
}

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,56 @@ public function testSwitchUserWithSeveralDefinedProvidersButNoFirewallRootProvid
454454
$this->assertEquals(new Reference('security.user.provider.concrete.second'), $container->getDefinition('security.authentication.switchuser_listener.foobar')->getArgument(1));
455455
}
456456

457+
public function testInvalidAccessControlWithEmptyRow()
458+
{
459+
$container = $this->getRawContainer();
460+
461+
$container->loadFromExtension('security', [
462+
'providers' => [
463+
'default' => ['id' => 'foo'],
464+
],
465+
'firewalls' => [
466+
'some_firewall' => [
467+
'pattern' => '/.*',
468+
'http_basic' => [],
469+
],
470+
],
471+
'access_control' => [
472+
[],
473+
['path' => '/admin', 'roles' => 'ROLE_ADMIN'],
474+
],
475+
]);
476+
477+
$this->expectException(InvalidConfigurationException::class);
478+
$this->expectExceptionMessage('One or more access control items are empty. Did you accidentally add lines only containing a "-" under "security.access_control"?');
479+
$container->compile();
480+
}
481+
482+
public function testValidAccessControlWithEmptyRow()
483+
{
484+
$container = $this->getRawContainer();
485+
486+
$container->loadFromExtension('security', [
487+
'providers' => [
488+
'default' => ['id' => 'foo'],
489+
],
490+
'firewalls' => [
491+
'some_firewall' => [
492+
'pattern' => '/.*',
493+
'http_basic' => [],
494+
],
495+
],
496+
'access_control' => [
497+
['path' => '^/login'],
498+
['path' => '^/', 'roles' => 'ROLE_USER'],
499+
],
500+
]);
501+
502+
$container->compile();
503+
504+
$this->assertTrue(true, 'extension throws an InvalidConfigurationException if there is one more more empty access control items');
505+
}
506+
457507
/**
458508
* @dataProvider provideEntryPointFirewalls
459509
*/

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block head %}
44
{% if collector.hasexception %}
55
<style>
6-
{{ render(path('_profiler_exception_css', { token: token })) }}
6+
{{ render(controller('web_profiler.controller.exception_panel::stylesheet', { token: token })) }}
77
{{ include('@WebProfiler/Collector/exception.css.twig') }}
88
</style>
99
{% endif %}
@@ -31,7 +31,7 @@
3131
</div>
3232
{% else %}
3333
<div class="sf-reset">
34-
{{ render(path('_profiler_exception', { token: token })) }}
34+
{{ render(controller('web_profiler.controller.exception_panel::body', { token: token })) }}
3535
</div>
3636
{% endif %}
3737
{% endblock %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
{% endblock %}
1111

1212
{% block panel %}
13-
{{ render(path('_profiler_router', { token: token })) }}
13+
{{ render(controller('web_profiler.controller.router::panelAction', { token: token })) }}
1414
{% endblock %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
{{ include('@WebProfiler/Icon/search.svg') }} <span class="hidden-small">Search</span>
109109
</a>
110110

111-
10000 {{ render(path('_profiler_search_bar', request.query.all)) }}
111+
{{ render(controller('web_profiler.controller.profiler::searchBarAction', request.query.all)) }}
112112
</div>
113113
</div>
114114

src/Symfony/Component/Cache/Adapter/NullAdapter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function deleteItems(array $keys)
110110
*/
111111
public function save(CacheItemInterface $item)
112112
{
113-
return false;
113+
return true;
114114
}
115115

116116
/**
@@ -120,7 +120,7 @@ public function save(CacheItemInterface $item)
120120
*/
121121
public function saveDeferred(CacheItemInterface $item)
122122
{
123-
return false;
123+
return true;
124124
}
125125

126126
/**
@@ -130,7 +130,7 @@ public function saveDeferred(CacheItemInterface $item)
130130
*/
131131
public function commit()
132132
{
133-
return false;
133+
return true;
134134
}
135135

136136
/**

src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testSave()
113113
$this->assertFalse($item->isHit());
114114
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");
115115

116-
$this->assertFalse($adapter->save($item));
116+
$this->assertTrue($adapter->save($item));
117117
}
118118

119119
public function testDeferredSave()
@@ -124,7 +124,7 @@ public function testDeferredSave()
124124
$this->assertFalse($item->isHit());
125125
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");
126126

127-
$this->assertFalse($adapter->saveDeferred($item));
127+
$this->assertTrue($adapter->saveDeferred($item));
128128
}
129129

130130
public function testCommit()
@@ -135,7 +135,7 @@ public function testCommit()
135135
$this->assertFalse($item->isHit());
136136
$this->assertNull($item->get(), "Item's value must be null when isHit is false.");
137137

138-
$this->assertFalse($adapter->saveDeferred($item));
139-
$this->assertFalse($this->createCachePool()->commit());
138+
$this->assertTrue($adapter->saveDeferred($item));
139+
$this->assertTrue($this->createCachePool()->commit());
140140
}
141141
}

src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function hasCacheableSupportsMethod(): bool
6161
}
6262

6363
/**
64-
* Checks if the given class has any get{Property} method.
64+
* Checks if the given class has any getter method.
6565
*/
6666
private function supports(string $class): bool
6767
{
@@ -77,7 +77,7 @@ private function supports(string $class): bool
7777
}
7878

7979
/**
80-
* Checks if a method's name is get.* or is.*, and can be called without parameters.
80+
* Checks if a method's name matches /^(get|is|has).+$/ and can be called non-statically without parameters.
8181
*/
8282
private function isGetMethod(\ReflectionMethod $method): bool
8383
{

src/Symfony/Component/Validator/Mapping/ClassMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function addPropertyConstraints(string $property, array $constraints)
264264
* Adds a constraint to the getter of the given property.
265265
*
266266
* The name of the getter is assumed to be the name of the property with an
267-
* uppercased first letter and either the prefix "get" or "is".
267+
* uppercased first letter and the prefix "get", "is" or "has".
268268
*
269269
* @return $this
270270
*/

src/Symfony/Component/Validator/Mapping/GetterMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* method.
1919
*
2020
* A property getter is any method that is equal to the property's name,
21-
* prefixed with either "get" or "is". That method will be used to access the
21+
* prefixed with "get", "is" or "has". That method will be used to access the
2222
* property's value.
2323
*
2424
* The getter will be invoked by reflection, so the access of private and

0 commit comments

Comments
 (0)
0