Skip to content

Commit 78479ca

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [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 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
2 parents 763f099 + 4b9e1e4 commit 78479ca

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
@@ -1198,15 +1198,19 @@ private function addExceptionsSection(ArrayNodeDefinition $rootNode)
11981198
->scalarNode('log_level')
11991199
->info('The level of log message. Null to let Symfony decide.')
12001200
->validate()
1201-
->ifTrue(function ($v) use ($logLevels) { return !\in_array($v, $logLevels); })
1201+
->ifTrue(function ($v) use ($logLevels) { return null !== $v && !\in_array($v, $logLevels, true); })
12021202
->thenInvalid(sprintf('The log level is not valid. Pick one among "%s".', implode('", "', $logLevels)))
12031203
->end()
12041204
->defaultNull()
12051205
->end()
12061206
->scalarNode('status_code')
1207-
->info('The status code of the response. Null to let Symfony decide.')
1207+
->info('The status code of the response. Null or 0 to let Symfony decide.')
1208+
->beforeNormalization()
1209+
->ifTrue(function ($v) { return 0 === $v; })
1210+
->then(function ($v) { return null; })
1211+
->end()
12081212
->validate()
1209-
->ifTrue(function ($v) { return $v < 100 || $v > 599; })
1213+
->ifTrue(function ($v) { return null !== $v && ($v < 100 || $v > 599); })
12101214
->thenInvalid('The status code is not valid. Pick a value between 100 and 599.')
12111215
->end()
12121216
->defaultNull()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
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
'exceptions' => [
710
BadRequestHttpException::class => [
811
'log_level' => 'info',
912
'status_code' => 422,
1013
],
14+
NotFoundHttpException::class => [
15+
'log_level' => 'info',
16+
'status_code' => null,
17+
],
18+
ConflictHttpException::class => [
19+
'log_level' => 'info',
20+
'status_code' => 0,
21+
],
22+
ServiceUnavailableHttpException::class => [
23+
'log_level' => null,
24+
'status_code' => 500,
25+
],
1126
],
1227
]);

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>
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
@@ -3,3 +3,12 @@ framework:
33
Symfony\Component\HttpKernel\Exception\BadRequestHttpException:
44
log_level: info
55
status_code: 422
6+
Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
7+
log_level: info
8+
status_code: null
9+
Symfony\Component\HttpKernel\Exception\ConflictHttpException:
10+
log_level: info
11+
status_code: 0
12+
Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException:
13+
log_level: null
14+
status_code: 500

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,18 @@ public function testExceptionsConfig()
547547
'log_level' => 'info',
548548
'status_code' => 422,
549549
],
550+
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class => [
551+
'log_level' => 'info',
552+
'status_code' => null,
553+
],
554+
\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class => [
555+
'log_level' => 'info',
556+
'status_code' => null,
557+
],
558+
\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class => [
559+
'log_level' => null,
560+
'status_code' => 500,
561+
],
550562
], $container->getDefinition('exception_listener')->getArgument(3));
551563
}
552564

0 commit comments

Comments
 (0)