Skip to content

Commit ac574f5

Browse files
committed
Merge branch '6.1' into 6.2
* 6.1: fix merge [FrameworkBundle] Allow to specify `null` for exception mapping configuration values Fix BinaryFileResponse content type detection logic [Notifier] [Expo] Throw exception on error-response from expo api Bump Symfony version to 6.1.6 Update VERSION for 6.1.5 Update CHANGELOG for 6.1.5 Bump Symfony version to 6.0.14 Update VERSION for 6.0.13 Update CHANGELOG for 6.0.13 Bump Symfony version to 5.4.14 Update VERSION for 5.4.13 Update CHANGELOG for 5.4.13 Bump Symfony version to 4.4.47 Update VERSION for 4.4.46 Update CONTRIBUTORS for 4.4.46 Update CHANGELOG for 4.4.46 [Security] Fix login url matching when app is not run with url rewriting or from a sub folder [symfony/mailjet-mailer] Fix bug #47701
2 parents 081f508 + 6f3ca27 commit ac574f5

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

DependencyInjection/Configuration.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,15 +1222,19 @@ private function addExceptionsSection(ArrayNodeDefinition $rootNode)
12221222
->scalarNode('log_level')
12231223
->info('The level of log message. Null to let Symfony decide.')
12241224
->validate()
1225-
->ifTrue(function ($v) use ($logLevels) { return !\in_array($v, $logLevels); })
1225+
->ifTrue(function ($v) use ($logLevels) { return null !== $v && !\in_array($v, $logLevels, true); })
12261226
->thenInvalid(sprintf('The log level is not valid. Pick one among "%s".', implode('", "', $logLevels)))
12271227
->end()
12281228
->defaultNull()
12291229
->end()
12301230
->scalarNode('status_code')
1231-
->info('The status code of the response. Null to let Symfony decide.')
1231+
->info('The status code of the response. Null or 0 to let Symfony decide.')
1232+
->beforeNormalization()
1233+
->ifTrue(function ($v) { return 0 === $v; })
1234+
->then(function ($v) { return null; })
1235+
->end()
12321236
->validate()
1233-
->ifTrue(function ($v) { return $v < 100 || $v > 599; })
1237+
->ifTrue(function ($v) { return null !== $v && ($v < 100 || $v > 599); })
12341238
->thenInvalid('The status code is not valid. Pick a value between 100 and 599.')
12351239
->end()
12361240
->defaultNull()

Tests/DependencyInjection/Fixtures/php/exceptions.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

33
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
4+
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
5+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
6+
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
47

58
$container->loadFromExtension('framework', [
69
'http_method_override' => false,
@@ -9,5 +12,17 @@
912
'log_level' => 'info',
1013
'status_code' => 422,
1114
],
15+
NotFoundHttpException::class => [
16+
'log_level' => 'info',
17+
'status_code' => null,
18+
],
19+
ConflictHttpException::class => [
20+
'log_level' => 'info',
21+
'status_code' => 0,
22+
],
23+
ServiceUnavailableHttpException::class => [
24+
'log_level' => null,
25+
'status_code' => 500,
26+
],
1227
],
1328
]);

Tests/DependencyInjection/Fixtures/xml/exceptions.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<framework:config http-method-override="false">
99
<framework:exceptions>
1010
<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" />
1114
</framework:exceptions>
1215
</framework:config>
1316
</container>

Tests/DependencyInjection/Fixtures/yml/exceptions.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@ framework:
44
Symfony\Component\HttpKernel\Exception\BadRequestHttpException:
55
log_level: info
66
status_code: 422
7+
Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
8+
log_level: info
9+
status_code: null
10+
Symfony\Component\HttpKernel\Exception\ConflictHttpException:
11+
log_level: info
12+
status_code: 0
13+
Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException:
14+
log_level: null
15+
status_code: 500

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,18 @@ public function testExceptionsConfig()
584584
'log_level' => 'info',
585585
'status_code' => 422,
586586
],
587+
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class => [
588+
'log_level' => 'info',
589+
'status_code' => null,
590+
],
591+
\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class => [
592+
'log_level' => 'info',
593+
'status_code' => null,
594+
],
595+
\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class => [
596+
'log_level' => null,
597+
'status_code' => 500,
598+
],
587599
], $container->getDefinition('exception_listener')->getArgument(3));
588600
}
589601

0 commit comments

Comments
 (0)