8000 Merge branch '5.4' into 6.0 · marphi/symfony@6c0e925 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c0e925

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Mailer] Include all transports' debug messages in RoundRobin transport exception [FrameworkBundle] fix: fix help message 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 symfony#48313 [Mime] Fix MessagePart serialization [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
2 parents 4dd9cef + d38ef67 commit 6c0e925

File tree

46 files changed

+533
-137
lines changed

Some content is hidden

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

46 files changed

+533
-137
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ public function isActivatedProvider(): array
5959
{
6060
return [
6161
['/test', ['level' => Logger::ERROR], true],
62-
['/400', ['level' => Logger::ERROR, 'context' => $this->getContextException(400)], true],
63-
['/400/a', ['level' => Logger::ERROR, 'context' => $this->getContextException(400)], false],
64-
['/400/b', ['level' => Logger::ERROR, 'context' => $this->getContextException(400)], false],
65-
['/400/c', ['level' => Logger::ERROR, 'context' => $this->getContextException(400)], true],
66-
['/401', ['level' => Logger::ERROR, 'context' => $this->getContextException(401)], true],
67-
['/403', ['level' => Logger::ERROR, 'context' => $this->getContextException(403)], false],
68-
['/404', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false],
69-
['/405', ['level' => Logger::ERROR, 'context' => $this->getContextException(405)], false],
70-
['/500', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true],
62+
['/400', ['level' => Logger::ERROR, 'context' => self::getContextException(400)], true],
63+
['/400/a', ['level' => Logger::ERROR, 'context' => self::getContextException(400)], false],
64+
['/400/b', ['level' => Logger::ERROR, 'context' => self::getContextException(400)], false],
65+
['/400/c', ['level' => Logger::ERROR, 'context' => self::getContextException(400)], true],
66+
['/401', ['level' => Logger::ERROR, 'context' => self::getContextException(401)], true],
67+
['/403', ['level' => Logger::ERROR, 'context' => self::getContextException(403)], false],
68+
['/404', ['level' => Logger::ERROR, 'context' => self::getContextException(404)], false],
69+
['/405', ['level' => Logger::ERROR, 'context' => self::getContextException(405)], false],
70+
['/500', ['level' => Logger::ERROR, 'context' => self::getContextException(500)], true],
7171
];
7272
}
7373

74-
private function getContextException(int $code): array
74+
private static function getContextException(int $code): array
7575
{
7676
return ['exception' => new HttpException($code)];
7777
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ public function isActivatedProvider(): array
3838
{
3939
return [
4040
['/test', ['level' => Logger::DEBUG], false],
41-
['/foo', ['level' => Logger::DEBUG, 'context' => $this->getContextException(404)], false],
42-
['/baz/bar', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false],
43-
['/foo', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false],
44-
['/foo', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true],
41+
['/foo', ['level' => Logger::DEBUG, 'context' => self::getContextException(404)], false],
42+
['/baz/bar', ['level' => Logger::ERROR, 'context' => self::getContextException(404)], false],
43+
['/foo', ['level' => Logger::ERROR, 'context' => self::getContextException(404)], false],
44+
['/foo', ['level' => Logger::ERROR, 'context' => self::getContextException(500)], true],
4545

4646
['/test', ['level' => Logger::ERROR], true],
47-
['/baz', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], true],
48-
['/baz', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true],
47+
['/baz', ['level' => Logger::ERROR, 'context' => self::getContextException(404)], true],
48+
['/baz', ['level' => Logger::ERROR, 'context' => self::getContextException(500)], true],
4949
];
5050
}
5151

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

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testDatetimeFormat(array $record, $expectedTimestamp)
3434

3535
public function providerDatetimeFormatTests(): array
3636
{
37-
$record = $this->getRecord();
37+
$record = self::getRecord();
3838

3939
return [
4040
[array_merge($record, ['datetime' => new \DateTime('2019-01-01T00:01:00+00:00')]), 1546300860],
@@ -58,7 +58,7 @@ public function testDatetimeRfc3339Format(array $record, $expectedTimestamp)
5858

5959
public function providerDatetimeRfc3339FormatTests(): array
6060
{
61-
$record = $this->getRecord();
61+
$record = self::getRecord();
6262

6363
return [
6464
[array_merge($record, ['datetime' => new \DateTime('2019-01-01T00:01:00+00:00')]), '2019-01-01T00:01:00.000+00:00'],
@@ -70,8 +70,8 @@ public function providerDatetimeRfc3339FormatTests(): array
7070
public function testDebugProcessor()
7171
{
7272
$processor = new DebugProcessor();
73-
$processor($this->getRecord());
74-
$processor($this->getRecord(Logger::ERROR));
73+
$processor(self::getRecord());
74+
$processor(self::getRecord(Logger::ERROR));
7575

7676
$this->assertCount(2, $processor->getLogs());
7777
$this->assertSame(1, $processor->countErrors());
@@ -89,17 +89,17 @@ public function testWithRequestStack()
8989
{
9090
$stack = new RequestStack();
9191
$processor = new DebugProcessor($stack);
92-
$processor($this->getRecord());
93-
$processor($this->getRecord(Logger::ERROR));
92+
$processor(self::getRecord());
93+
$processor(self::getRecord(Logger::ERROR));
9494

9595
$this->assertCount(2, $processor->getLogs());
9696
$this->assertSame(1, $processor->countErrors());
9797

9898
$request = new Request();
9999
$stack->push($request);
100100

101-
$processor($this->getRecord());
102-
$processor($this->getRecord(Logger::ERROR));
101+
$processor(self::getRecord());
102+
$processor(self::getRecord(Logger::ERROR));
103103

104104
$this->assertCount(4, $processor->getLogs());
105105
$this->assertSame(2, $processor->countErrors());
@@ -123,7 +123,7 @@ public function testInheritedClassCallCountErrorsWithoutArgument()
123123
$this->assertEquals(0, $debugProcessorChild->countErrors());
124124
}
125125

126-
private function getRecord($level = Logger::WARNING, $message = 'test'): array
126+
private static function getRecord($level = Logger::WARNING, $message = 'test'): array
127127
{
128128
return [
129129
'message' => $message,

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php

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

7272
EOF
7373
)

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

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

364-
if ($class = $r->getClosureScopeClass()) {
364+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
365365
$data['class'] = $class->name;
366366
if (!$r->getClosureThis()) {
367367
$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
@@ -377,7 +377,7 @@ protected function describeCallable(mixed $callable, array $options = [])
377377
}
378378
$string .= "\n".sprintf('- Name: `%s`', $r->name);
379379

380-
if ($class = $r->getClosureScopeClass()) {
380+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
381381
$string .= "\n".sprintf('- Class: `%s`', $class->name);
382382
if (!$r->getClosureThis()) {
383383
$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
@@ -614,7 +614,7 @@ private function formatCallable(mixed $callable): string
614614
if (str_contains($r->name, '{closure}')) {
615615
return 'Closure()';
616616
}
617-
if ($class = $r->getClosureScopeClass()) {
617+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
618618
return sprintf('%s::%s()', $class->name, $r->name);
619619
}
620620

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php

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

551-
if ($class = $r->getClosureScopeClass()) {
551+
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
552552
$callableXML->setAttribute('class', $class->name);
553553
if (!$r->getClosureThis()) {
554554
$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
@@ -1165,35 +1165,31 @@ private function addExceptionsSection(ArrayNodeDefinition $rootNode)
11651165
$logLevels = (new \ReflectionClass(LogLevel::class))->getConstants();
11661166

11671167
$rootNode
1168+
->fixXmlConfig('exception')
11681169
->children()
11691170
->arrayNode('exceptions')
11701171
->info('Exception handling configuration')
1172+
->useAttributeAsKey('class')
11711173
->beforeNormalization()
1174+
// Handle legacy XML configuration
11721175
->ifArray()
11731176
->then(function (array $v): array {
11741177
if (!\array_key_exists('exception', $v)) {
11751178
return $v;
11761179
}
11771180

1178-
// Fix XML normalization
1179-
$data = isset($v['exception'][0]) ? $v['exception'] : [$v['exception']];
1180-
$exceptions = [];
1181-
foreach ($data as $exception) {
1182-
$config = [];
1183-
if (\array_key_exists('log-level', $exception)) {
1184-
$config['log_level'] = $exception['log-level'];
1185-
}
1186-
if (\array_key_exists('status-code', $exception)) {
1187-
$config['status_code'] = $exception['status-code'];
1188-
}
1189-
$exceptions[$exception['name']] = $config;
1181+
$v = $v['exception'];
1182+
unset($v['exception']);
1183+
1184+
foreach ($v as &$exception) {
1185+
$exception['class'] = $exception['name'];
1186+
unset($exception['name']);
11901187
}
11911188

1192-
return $exceptions;
1189+
return $v;
11931190
})
11941191
->end()
11951192
->prototype('array')
1196-
->fixXmlConfig('exception')
11971193
->children()
11981194
->scalarNode('log_level')
11991195
->info('The level of log message. Null to let Symfony decide.')

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="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
3536
<xsd:element name="http-client" type="http_client" minOccurs="0" maxOccurs="1" />
@@ -360,14 +361,29 @@
360361

361362
<xsd:complexType name="exceptions">
362363
<xsd:sequence>
363-
<xsd:element name="exception" type="exception" minOccurs="0" maxOccurs="unbounded" />
364+
<xsd:element name="exception" type="old-exception" minOccurs="0" maxOccurs="unbounded" />
364365
</xsd:sequence>
365366
</xsd:complexType>
366367

367-
<xsd:complexType name="exception">
368-
<xsd:attribute name="name" type="xsd:string" use="required" />
368+
<xsd:complexType name="exception" abstract="true">
369369
<xsd:attribute name="log-level" type="xsd:string" />
370-
<xsd:attribute name="status-code" type="xsd:int" />
370+
<xsd:attribute name="status-code" type="xsd:integer" />
371+
</xsd:complexType>
372+
373+
<xsd:complexType name="old-exception">
374+
<xsd:complexContent>
375+
<xsd:extension base="exception">
376+
<xsd:attribute name="name" type="xsd:string" use="required" />
377+
</xsd:extension>
378+
</xsd:complexContent>
379+
</xsd:complexType>
380+
381+
<xsd:complexType name="new-exception">
382+
<xsd:complexContent>
383+
<xsd:extension base="exception">
384+
<xsd:attribute name="class" type="xsd:string" use="required" />
385+
</xsd:extension>
386+
</xsd:complexContent>
371387
</xsd:complexType>
372388

373389
<xsd:complexType name="marking_store">

0 commit comments

Comments
 (0)
0