Skip to content

Commit b7c2bd0

Browse files
Merge branch '6.1' into 6.2
* 6.1: [Mailer] Include all transports' debug messages in RoundRobin transport exception [FrameworkBundle] fix: fix help message Fix HtmlSanitizer default configuration behavior for allowed schemes Use relative timestamps [Cache] Fix dealing with ext-redis' multi/exec returning a bool [Messenger][Amqp] Added missing rpc_timeout option [Serializer] Prevent GetSetMethodNormalizer from creating invalid magic method call [HttpFoundation] Fix dumping array cookies [WebProfilerBundle] Fix dump header not being displayed TraceableHttpClient: increase decorator's priority Use static methods inside data providers [FrameworkBundle] Allow configuring `framework.exceptions` with a config builder bug #48313 [Mime] Fix MessagePart serialization [HttpKernel][ErrorHandler] Fix reading the SYMFONY_IDE env var [ErrorHandler][DebugClassLoader] Fix some new return types support Fix getting the name of closures on PHP 8.1.11+ [Translator] Fix typo "internal" / "interval" fix dumping top-level tagged values [Console] Fix clear line with question in section
2 parents b3c4053 + 70198b6 commit b7c2bd0

File tree

13 files changed

+141
-48
lines changed

13 files changed

+141
-48
lines changed

Command/ConfigDumpReferenceCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function configure()
6464
6565
For dumping a specific option, add its path as second argument (only available for the yaml format):
6666
67-
<info>php %command.full_name% framework profiler.matcher</info>
67+
<info>php %command.full_name% framework http_client.default_options</info>
6868

6969
EOF
7070
)

Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private function getCallableData(mixed $callable): array
370370
}
371371
$data['name'] = $r->name;
372372

373-
if ($class = $r->getClosureScopeClass()) {
373+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
374374
$data['class'] = $class->name;
375375
if (!$r->getClosureThis()) {
376376
$data['static'] = true;

Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ protected function describeCallable(mixed $callable, array $options = [])
387387
}
388388
$string .= "\n".sprintf('- Name: `%s`', $r->name);
389389

390-
if ($class = $r->getClosureScopeClass()) {
390+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
391391
$string .= "\n".sprintf('- Class: `%s`', $class->name);
392392
if (!$r->getClosureThis()) {
393393
$string .= "\n- Static: yes";

Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ private function formatCallable(mixed $callable): string
617617
if (str_contains($r->name, '{closure}')) {
618618
return 'Closure()';
619619
}
620-
if ($class = $r->getClosureScopeClass()) {
620+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
621621
return sprintf('%s::%s()', $class->name, $r->name);
622622
}
623623

Console/Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ private function getCallableDocument(mixed $callable): \DOMDocument
565565
}
566566
$callableXML->setAttribute('name', $r->name);
567567

568-
if ($class = $r->getClosureScopeClass()) {
568+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
569569
$callableXML->setAttribute('class', $class->name);
570570
if (!$r->getClosureThis()) {
571571
$callableXML->setAttribute('static', 'true');

DependencyInjection/Configuration.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,35 +1189,31 @@ private function addExceptionsSection(ArrayNodeDefinition $rootNode)
11891189
$logLevels = (new \ReflectionClass(LogLevel::class))->getConstants();
11901190

11911191
$rootNode
1192+
->fixXmlConfig('exception')
11921193
->children()
11931194
->arrayNode('exceptions')
11941195
->info('Exception handling configuration')
1196+
->useAttributeAsKey('class')
11951197
->beforeNormalization()
1198+
// Handle legacy XML configuration
11961199
->ifArray()
11971200
->then(function (array $v): array {
11981201
if (!\array_key_exists('exception', $v)) {
11991202
return $v;
12001203
}
12011204

1202-
// Fix XML normalization
1203-
$data = isset($v['exception'][0]) ? $v['exception'] : [$v['exception']];
1204-
$exceptions = [];
1205-
foreach ($data as $exception) {
1206-
$config = [];
1207-
if (\array_key_exists('log-level', $exception)) {
1208-
$config['log_level'] = $exception['log-level'];
1209-
}
1210-
if (\array_key_exists('status-code', $exception)) {
1211-
$config['status_code'] = $exception['status-code'];
1212-
}
1213-
$exceptions[$exception['name']] = $config;
1205+
$v = $v['exception'];
1206+
unset($v['exception']);
1207+
1208+
foreach ($v as &$exception) {
1209+
$exception['class'] = $exception['name'];
1210+
unset($exception['name']);
12141211
}
12151212

1216-
return $exceptions;
1213+
return $v;
12171214
})
12181215
->end()
12191216
->prototype('array')
1220-
->fixXmlConfig('exception')
12211217
->children()
12221218
->scalarNode('log_level')
12231219
->info('The level of log message. Null to let Symfony decide.')

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,10 +2787,14 @@ private function registerHtmlSanitizerConfiguration(array $config, ContainerBuil
27872787

27882788
// Settings
27892789
$def->addMethodCall('forceHttpsUrls', [$sanitizerConfig['force_https_urls']], true);
2790-
$def->addMethodCall('allowLinkSchemes', [$sanitizerConfig['allowed_link_schemes']], true);
2790+
if ($sanitizerConfig['allowed_link_schemes']) {
2791+
$def->addMethodCall('allowLinkSchemes', [$sanitizerConfig['allowed_link_schemes']], true);
2792+
}
27912793
$def->addMethodCall('allowLinkHosts', [$sanitizerConfig['allowed_link_hosts']], true);
27922794
$def->addMethodCall('allowRelativeLinks', [$sanitizerConfig['allow_relative_links']], true);
2793-
$def->addMethodCall('allowMediaSchemes', [$sanitizerConfig['allowed_media_schemes']], true);
2795+
if ($sanitizerConfig['allowed_media_schemes']) {
2796+
$def->addMethodCall('allowMediaSchemes', [$sanitizerConfig['allowed_media_schemes']], true);
2797+
}
27942798
$def->addMethodCall('allowMediaHosts', [$sanitizerConfig['allowed_media_hosts']], true);
27952799
$def->addMethodCall('allowRelativeMedias', [$sanitizerConfig['allow_relative_medias']], true);
27962800

Resources/config/schema/symfony-1.0.xsd

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<xsd:element name="workflow" type="workflow" minOccurs="0" maxOccurs="unbounded" />
3131
<xsd:element name="php-errors" type="php-errors" minOccurs="0" maxOccurs="1" />
3232
<xsd:element name="exceptions" type="exceptions" minOccurs="0" maxOccurs="1" />
33+
<xsd:element name="exception" type="new-exception" minOccurs="0" maxOccurs="unbounded" />
3334
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
3435
<xsd:element name="semaphore" type="semaphore" minOccurs="0" maxOccurs="1" />
3536
<xsd:element name="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
@@ -365,14 +366,29 @@
365366

366367
<xsd:complexType name="exceptions">
367368
<xsd:sequence>
368-
<xsd:element name="exception" type="exception" minOccurs="0" maxOccurs="unbounded" />
369+
<xsd:element name="exception" type="old-exception" minOccurs="0" maxOccurs="unbounded" />
369370
</xsd:sequence>
370371
</xsd:complexType>
371372

372-
<xsd:complexType name="exception">
373-
<xsd:attribute name="name" type="xsd:string" use="required" />
373+
<xsd:complexType name="exception" abstract="true">
374374
<xsd:attribute name="log-level" type="xsd:string" />
375-
<xsd:attribute name="status-code" type="xsd:int" />
375+
<xsd:attribute name="status-code" type="xsd:integer" />
376+
</xsd:complexType>
377+
378+
<xsd:complexType name="old-exception">
379+
<xsd:complexContent>
380+
<xsd:extension base="exception">
381+
<xsd:attribute name="name" type="xsd:string" use="required" />
382+
</xsd:extension>
383+
</xsd:complexContent>
384+
</xsd:complexType>
385+
386+
<xsd:complexType name="new-exception">
387+
<xsd:complexContent>
388+
<xsd:extension base="exception">
389+
<xsd:attribute name="class" type="xsd:string" use="required" />
390+
</xsd:extension>
391+
</xsd:complexContent>
376392
</xsd:complexType>
377393

378394
<xsd:complexType name="marking_store">

Tests/DependencyInjection/Fixtures/xml/exceptions.xml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,25 @@
66
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
77

88
<framework:config http-method-override="false">
9-
<framework:exceptions>
10-
<framework:exception name="Symfony\Component\HttpKernel\Exception\BadRequestHttpException" log-level="info" status-code="422" />
11-
<framework:exception name="Symfony\Component\HttpKernel\Exception\NotFoundHttpException" log-level="info" status-code="0" />
12-
<framework:exception name="Symfony\Component\HttpKernel\Exception\ConflictHttpException" log-level="info" status-code="0" />
13-
<framework:exception name="Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException" log-level="null" status-code="500" />
14-
</framework:exceptions>
9+
<framework:exception
10+
class="Symfony\Component\HttpKernel\Exception\BadRequestHttpException"
11+
log-level="info"
12+
status-code="422"
13+
/>
14+
15+
<framework:exception
16+
class="Symfony\Component\HttpKernel\Exception\NotFoundHttpException"
17+
log-level="info"
18+
/>
19+
20+
<framework:exception
21+
class="Symfony\Component\HttpKernel\Exception\ConflictHttpException"
22+
log-level="info"
23+
/>
24+
25+
<framework:exception
26+
class="Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException"
27+
status-code="500"
28+
/>
1529
</framework:config>
1630
</container>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config http-method-override="false">
9+
<framework:exceptions>
10+
<framework:exception name="Symfony\Component\HttpKernel\Exception\BadRequestHttpException" log-level="info" status-code="422" />
11+
<framework:exception name="Symfony\Component\HttpKernel\Exception\NotFoundHttpException" log-level="info" status-code="0" />
12+
<framework:exception name="Symfony\Component\HttpKernel\Exception\ConflictHttpException" log-level="info" status-code="0" />
13+
<framework:exception name="Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException" log-level="null" status-code="500" />
14+
</framework:exceptions>
15+
</framework:config>
16+
</container>

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -580,24 +580,34 @@ public function testExceptionsConfig()
580580
{
581581
$container = $this->createContainerFromFile('exceptions');
582582

583+
$configuration = $container->getDefinition('exception_listener')->getArgument(3);
584+
583585
$this->assertSame([
584-
\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class => [
585-
'log_level' => 'info',
586-
'status_code' => 422,
587-
],
588-
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class => [
589-
'log_level' => 'info',
590-
'status_code' => null,
591-
],
592-
\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class => [
593-
'log_level' => 'info',
594-
'status_code' => null,
595-
],
596-
\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class => [
597-
'log_level' => null,
598-
'status_code' => 500,
599-
],
600-
], $container->getDefinition('exception_listener')->getArgument(3));
586+
\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class,
587+
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
588+
\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class,
589+
\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class,
590+
], array_keys($configuration));
591+
592+
$this->assertEqualsCanonicalizing([
593+
'log_level' => 'info',
594+
'status_code' => 422,
595+
], $configuration[\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class]);
596+
597+
$this->assertEqualsCanonicalizing([
598+
'log_level' => 'info',
599+
'status_code' => null,
600+
], $configuration[\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class]);
601+
602+
$this->assertEqualsCanonicalizing([
603+
'log_level' => 'info',
604+
'status_code' => null,
605+
], $configuration[\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class]);
606+
607+
$this->assertEqualsCanonicalizing([
608+
'log_level' => null,
609+
'status_code' => 500,
610+
], $configuration[\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class]);
601611
}
602612

603613
public function testRouter()
@@ -2150,7 +2160,9 @@ public function testHtmlSanitizerDefaultNullAllowedLinkMediaHost()
21502160

21512161
$calls = $container->getDefinition('html_sanitizer.config.custom_default')->getMethodCalls();
21522162
$this->assertContains(['allowLinkHosts', [null], true], $calls);
2163+
$this->assertContains(['allowRelativeLinks', [false], true], $calls);
21532164
$this->assertContains(['allowMediaHosts', [null], true], $calls);
2165+
$this->assertContains(['allowRelativeMedias', [false], true], $calls);
21542166
}
21552167

21562168
public function testHtmlSanitizerDefaultConfig()

Tests/DependencyInjection/XmlFrameworkExtensionTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,38 @@ public function testMessengerMiddlewareFactoryErroneousFormat()
3232
{
3333
$this->markTestSkipped('XML configuration will not allow erroneous format.');
3434
}
35+
36+
public function testLegacyExceptionsConfig()
37+
{
38+
$container = $this->createContainerFromFile('exceptions_legacy');
39+
40+
$configuration = $container->getDefinition('exception_listener')->getArgument(3);
41+
42+
$this->assertSame([
43+
\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class,
44+
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class,
45+
\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class,
46+
\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class,
47+
], array_keys($configuration));
48+
49+
$this->assertEqualsCanonicalizing([
50+
'log_level' => 'info',
51+
'status_code' => 422,
52+
], $configuration[\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class]);
53+
54+
$this->assertEqualsCanonicalizing([
55+
'log_level' => 'info',
56+
'status_code' => null,
57+
], $configuration[\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class]);
58+
59+
$this->assertEqualsCanonicalizing([
60+
'log_level' => 'info',
61+
'status_code' => null,
62+
], $configuration[\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class]);
63+
64+
$this->assertEqualsCanonicalizing([
65+
'log_level' => null,
66+
'status_code' => 500,
67+
], $configuration[\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class]);
68+
}
3569
}

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
>
1111
<php>
1212
<ini name="error_reporting" value="-1" />
13+
<env name="SYMFONY_IDE" value="" force="true" />
1314
<env name="REDIS_HOST" value="localhost" />
1415
<env name="MEMCACHED_HOST" value="localhost" />
1516
</php>

0 commit comments

Comments
 (0)