Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 52bdd04

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 f3ed8cd + e872a0f commit 52bdd04

File tree

57 files changed

+620
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+620
-139
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<ini name="intl.default_locale" value="en" />
1414
<ini name="intl.error_level" value="0" />
1515
<ini name="memory_limit" value="-1" />
16+
<env name="SYMFONY_IDE" value="" force="true" />
1617
<env name="DUMP_LIGHT_ARRAY" value="" />
1718
<env name="DUMP_STRING_LENGTH" value="" />
1819
<env name="LDAP_HOST" value="localhost" />

src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ public function isActivatedProvider(): array
6060
{
6161
return [
6262
['/test', RecordFactory::create(Logger::ERROR), true],
63-
['/400', RecordFactory::create(Logger::ERROR, context: $this->getContextException(400)), true],
64-
['/400/a', RecordFactory::create(Logger::ERROR, context: $this->getContextException(400)), false],
65-
['/400/b', RecordFactory::create(Logger::ERROR, context: $this->getContextException(400)), false],
66-
['/400/c', RecordFactory::create(Logger::ERROR, context: $this->getContextException(400)), true],
67-
['/401', RecordFactory::create(Logger::ERROR, context: $this->getContextException(401)), true],
68-
['/403', RecordFactory::create(Logger::ERROR, context: $this->getContextException(403)), false],
69-
['/404', RecordFactory::create(Logger::ERROR, context: $this->getContextException(404)), false],
70-
['/405', RecordFactory::create(Logger::ERROR, context: $this->getContextException(405)), false],
71-
['/500', RecordFactory::create(Logger::ERROR, context: $this->getContextException(500)), true],
63+
['/400', RecordFactory::create(Logger::ERROR, context: self::getContextException(400)), true],
64+
['/400/a', RecordFactory::create(Logger::ERROR, context: self::getContextException(400)), false],
65+
['/400/b', RecordFactory::create(Logger::ERROR, context: self::getContextException(400)), false],
66+
['/400/c', RecordFactory::create(Logger::ERROR, context: self::getContextException(400)), true],
67+
['/401', RecordFactory::create(Logger::ERROR, context: self::getContextException(401)), true],
68+
['/403', RecordFactory::create(Logger::ERROR, context: self::getContextException(403)), false],
69+
['/404', RecordFactory::create(Logger::ERROR, context: self::getContextException(404)), false],
70+
['/405', RecordFactory::create(Logger::ERROR, context: self::getContextException(405)), false],
71+
['/500', RecordFactory::create(Logger::ERROR, context: self::getContextException(500)), true],
7272
];
7373
}
7474

src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ public function isActivatedProvider(): array
4040
{
4141
return [
4242
['/test', RecordFactory::create(Logger::DEBUG), false],
43-
['/foo', RecordFactory::create(Logger::DEBUG, context: $this->getContextException(404)), false],
44-
['/baz/bar', RecordFactory::create(Logger::ERROR, context: $this->getContextException(404)), false],
45-
['/foo', RecordFactory::create(Logger::ERROR, context: $this->getContextException(404)), false],
46-
['/foo', RecordFactory::create(Logger::ERROR, context: $this->getContextException(500)), true],
43+
['/foo', RecordFactory::create(Logger::DEBUG, context: self::getContextException(404)), false],
44+
['/baz/bar', RecordFactory::create(Logger::ERROR, context: self::getContextException(404)), false],
45+
['/foo', RecordFactory::create(Logger::ERROR, context: self::getContextException(404)), false],
46+
['/foo', RecordFactory::create(Logger::ERROR, context: self::getContextException(500)), true],
4747

4848
['/test', RecordFactory::create(Logger::ERROR), true],
49-
['/baz', RecordFactory::create(Logger::ERROR, context: $this->getContextException(404)), true],
50-
['/baz', RecordFactory::create(Logger::ERROR, context: $this->getContextException(500)), true],
49+
['/baz', RecordFactory::create(Logger::ERROR, context: self::getContextException(404)), true],
50+
['/baz', RecordFactory::create(Logger::ERROR, context: self::getContextException(500)), true],
5151
];
5252
}
5353

54-
protected function getContextException(int $code): array
54+
protected static function getContextException(int $code): array
5555
{
5656
return ['exception' => new HttpException($code)];
5757
}

src/Symfony/Bridge/Monolog/Tests/Processor/DebugProcessorTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function testDatetimeRfc3339Format()
4646
public function testDebugProcessor()
4747
{
4848
$processor = new DebugProcessor();
49-
$processor($this->getRecord());
50-
$processor($this->getRecord(Logger::ERROR));
49+
$processor(self::getRecord());
50+
$processor(self::getRecord(Logger::ERROR));
5151

5252
$this->assertCount(2, $processor->getLogs());
5353
$this->assertSame(1, $processor->countErrors());
@@ -65,17 +65,17 @@ public function testWithRequestStack()
6565
{
6666
$stack = new RequestStack();
6767
$processor = new DebugProcessor($stack);
68-
$processor($this->getRecord());
69-
$processor($this->getRecord(Logger::ERROR));
68+
$processor(self::getRecord());
69+
$processor(self::getRecord(Logger::ERROR));
7070

7171
$this->assertCount(2, $processor->getLogs());
7272
$this->assertSame(1, $processor->countErrors());
7373

7474
$request = new Request();
7575
$stack->push($request);
7676

77-
$processor($this->getRecord());
78-
$processor($this->getRecord(Logger::ERROR));
77+
$processor(self::getRecord());
78+
$processor(self::getRecord(Logger::ERROR));
7979

8080
$this->assertCount(4, $processor->getLogs());
8181
$this->assertSame(2, $processor->countErrors());
@@ -99,7 +99,7 @@ public function testInheritedClassCallCountErrorsWithoutArgument()
9999
$this->assertEquals(0, $debugProcessorChild->countErrors());
100100
}
101101

102-
private function getRecord($level = Logger::WARNING, $message = 'test'): array|LogRecord
102+
private static function getRecord($level = Logger::WARNING, $message = 'test'): array|LogRecord
103103
{
104104
return RecordFactory::create($level, $message);
105105
}

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

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

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

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

src/Symfony/Bundle/FrameworkBundle/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');

src/Symfony/Bundle/FrameworkBundle/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.')

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

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

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

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

0 commit comments

Comments
 (0)