Skip to content

Commit 4ababf2

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: Bump Symfony version to 7.2.2 Fix resolve enum in string type resolver Update VERSION for 7.2.1 Update CHANGELOG for 7.2.1 [PropertyInfo] Upmerge symfony#59012 [BeanstalkMessenger] Round delay to an integer to avoid deprecation warning [Console] Fix tests [PropertyInfo] Fix interface handling in `PhpStanTypeHelper` [TypeInfo] Remove useless dependency [HttpClient] Test POST to GET redirects [TypeInfo] Fix outdated README [HttpKernel] Denormalize request data using the csv format when using "#[MapQueryString]" or "#[MapRequestPayload]" (except for content data) [TypeInfo] Fix handle nullable with mixed fix: preserve and nowrap in profiler code highlighting
2 parents 981c3a2 + 3766572 commit 4ababf2

File tree

21 files changed

+318
-32
lines changed

21 files changed

+318
-32
lines changed

CHANGELOG-7.2.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ in 7.2 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v7.2.0...v7.2.1
99

10+
* 7.2.1 (2024-12-11)
11+
12+
* bug #59145 [TypeInfo] Make `Type::nullable` method no-op on every nullable type (mtarld)
13+
* bug #59122 [Notifier] fix desktop channel bus abstract arg (raphael-geffroy)
14+
* bug #59124 [FrameworkBundle] fix: notifier push channel bus abstract arg (raphael-geffroy)
15+
* bug #59069 [Console] Fix division by 0 error (Rindula)
16+
* bug #59086 [FrameworkBundle] Make uri_signer lazy and improve error when kernel.secret is empty (nicolas-grekas)
17+
* bug #59099 [sendgrid-mailer] Fix null check on region (AUDUL)
18+
* bug #59070 [PropertyInfo] evaluate access flags for properties with asymmetric visibility (xabbuh)
19+
* bug #59062 [HttpClient] Always set CURLOPT_CUSTOMREQUEST to the correct HTTP method in CurlHttpClient (KurtThiemann)
20+
* bug #59059 [TwigBridge] generate conflict-free variable names (xabbuh)
21+
1022
* 7.2.0 (2024-11-29)
1123

1224
* bug #59023 [HttpClient] Fix streaming and redirecting with NoPrivateNetworkHttpClient (nicolas-grekas)

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#source .source-content ol li {
4141
margin: 0 0 2px 0;
4242
padding-left: 5px;
43+
white-space: preserve nowrap;
4344
}
4445
#source .source-content ol li::marker {
4546
color: var(--color-muted);

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ protected function tearDown(): void
7979
pcntl_signal(\SIGTERM, \SIG_DFL);
8080
pcntl_signal(\SIGUSR1, \SIG_DFL);
8181
pcntl_signal(\SIGUSR2, \SIG_DFL);
82+
pcntl_signal(\SIGALRM, \SIG_DFL);
8283
}
8384
}
8485

src/Symfony/Component/Console/Tests/ConsoleEventsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function tearDown(): void
3939
pcntl_signal(\SIGTERM, \SIG_DFL);
4040
pcntl_signal(\SIGUSR1, \SIG_DFL);
4141
pcntl_signal(\SIGUSR2, \SIG_DFL);
42+
pcntl_signal(\SIGALRM, \SIG_DFL);
4243
}
4344
}
4445

src/Symfony/Component/Console/Tests/SignalRegistry/SignalRegistryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ protected function tearDown(): void
2727
pcntl_signal(\SIGTERM, \SIG_DFL);
2828
pcntl_signal(\SIGUSR1, \SIG_DFL);
2929
pcntl_signal(\SIGUSR2, \SIG_DFL);
30+
pcntl_signal(\SIGALRM, \SIG_DFL);
3031
}
3132

3233
public function testOneCallbackForASignalSignalIsHandled()

src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,4 +678,26 @@ public function testHeadRequestWithClosureBody()
678678
$this->assertIsArray($vars);
679679
$this->assertSame('HEAD', $vars['REQUEST_METHOD']);
680680
}
681+
682+
/**
683+
* @testWith [301]
684+
* [302]
685+
* [303]
686+
*/
687+
public function testPostToGetRedirect(int $status)
688+
{
689+
$p = TestHttpServer::start(8067);
690+
691+
try {
692+
$client = $this->getHttpClient(__FUNCTION__);
693+
694+
$response = $client->request('POST', 'http://localhost:8057/custom?status=' . $status . '&headers[]=Location%3A%20%2F');
695+
$body = $response->toArray();
696+
} finally {
697+
$p->stop();
698+
}
699+
700+
$this->assertSame('GET', $body['REQUEST_METHOD']);
701+
$this->assertSame('/', $body['REQUEST_URI']);
702+
}
681703
}

src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@
4646
class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscriberInterface
4747
{
4848
/**
49-
* @see \Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT
5049
* @see DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS
5150
*/
5251
private const CONTEXT_DENORMALIZE = [
53-
'disable_type_enforcement' => true,
5452
'collect_denormalization_errors' => true,
5553
];
5654

@@ -190,7 +188,7 @@ private function mapQueryString(Request $request, ArgumentMetadata $argument, Ma
190188
return null;
191189
}
192190

193-
return $this->serializer->denormalize($data, $argument->getType(), null, $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ['filter_bool' => true]);
191+
return $this->serializer->denormalize($data, $argument->getType(), 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ['filter_bool' => true]);
194192
}
195193

196194
private function mapRequestPayload(Request $request, ArgumentMetadata $argument, MapRequestPayload $attribute): object|array|null
@@ -210,7 +208,7 @@ private function mapRequestPayload(Request $request, ArgumentMetadata $argument,
210208
}
211209

212210
if ($data = $request->request->all()) {
213-
return $this->serializer->denormalize($data, $type, null, $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ('form' === $format ? ['filter_bool' => true] : []));
211+
return $this->serializer->denormalize($data, $type, 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE + ('form' === $format ? ['filter_bool' => true] : []));
214212
}
215213

216214
if ('' === ($data = $request->getContent()) && ($argument->isNullable() || $argument->hasDefaultValue())) {

src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\HttpKernel\Exception\HttpException;
2323
use Symfony\Component\HttpKernel\Exception\NearMissValueResolverException;
2424
use Symfony\Component\HttpKernel\HttpKernelInterface;
25+
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
2526
use Symfony\Component\Serializer\Encoder\JsonEncoder;
2627
use Symfony\Component\Serializer\Encoder\XmlEncoder;
2728
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
@@ -395,6 +396,38 @@ public function testQueryStringValidationPassed()
395396
$this->assertEquals([$payload], $event->getArguments());
396397
}
397398

399+
public function testQueryStringParameterTypeMismatch()
400+
{
401+
$query = ['price' => 'not a float'];
402+
403+
$normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor());
404+
$serializer = new Serializer([$normalizer], ['json' => new JsonEncoder()]);
405+
406+
$validator = $this->createMock(ValidatorInterface::class);
407+
$validator->expects($this->never())->method('validate');
408+
409+
$resolver = new RequestPayloadValueResolver($serializer, $validator);
410+
411+
$argument = new ArgumentMetadata('invalid', RequestPayload::class, false, false, null, false, [
412+
MapQueryString::class => new MapQueryString(),
413+
]);
414+
415+
$request = Request::create('/', 'GET', $query);
416+
417+
$kernel = $this->createMock(HttpKernelInterface::class);
418+
$arguments = $resolver->resolve($request, $argument);
419+
$event = new ControllerArgumentsEvent($kernel, function () {}, $arguments, $request, HttpKernelInterface::MAIN_REQUEST);
420+
421+
try {
422+
$resolver->onKernelControllerArguments($event);
423+
$this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class));
424+
} catch (HttpException $e) {
425+
$validationFailedException = $e->getPrevious();
426+
$this->assertInstanceOf(ValidationFailedException::class, $validationFailedException);
427+
$this->assertSame('This value should be of type float.', $validationFailedException->getViolations()[0]->getMessage());
428+
}
429+
}
430+
398431
public function testRequestInputValidationPassed()
399432
{
400433
$input = ['price' => '50'];
@@ -457,6 +490,38 @@ public function testRequestArrayDenormalization()
457490
$this->assertEquals([$payload], $event->getArguments());
458491
}
459492

493+
public function testRequestInputTypeMismatch()
494+
{
495+
$input = ['price' => 'not a float'];
496+
497+
$normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor());
498+
$serializer = new Serializer([$normalizer], ['json' => new JsonEncoder()]);
499+
500+
$validator = $this->createMock(ValidatorInterface::class);
501+
$validator->expects($this->never())->method('validate');
502+
503+
$resolver = new RequestPayloadValueResolver($serializer, $validator);
504+
505+
$argument = new ArgumentMetadata('invalid', RequestPayload::class, false, false, null, false, [
506+
MapRequestPayload::class => new MapRequestPayload(),
507+
]);
508+
509+
$request = Request::create('/', 'POST', $input);
510+
511+
$kernel = $this->createMock(HttpKernelInterface::class);
512+
$arguments = $resolver->resolve($request, $argument);
513+
$event = new ControllerArgumentsEvent($kernel, function () {}, $arguments, $request, HttpKernelInterface::MAIN_REQUEST);
514+
515+
try {
516+
$resolver->onKernelControllerArguments($event);
517+
$this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class));
518+
} catch (HttpException $e) {
519+
$validationFailedException = $e->getPrevious();
520+
$this->assertInstanceOf(ValidationFailedException::class, $validationFailedException);
521+
$this->assertSame('This value should be of type float.', $validationFailedException->getViolations()[0]->getMessage());
522+
}
523+
}
524+
460525
public function testItThrowsOnMissingAttributeType()
461526
{
462527
$serializer = new Serializer();

src/Symfony/Component/Messenger/Bridge/Beanstalkd/Tests/Transport/ConnectionTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,25 @@ public function testKeepaliveWhenABeanstalkdExceptionOccurs()
363363
$this->expectExceptionObject(new TransportException($exception->getMessage(), 0, $exception));
364364
$connection->keepalive((string) $id);
365365
}
366+
367+
public function testSendWithRoundedDelay()
368+
{
369+
$tube = 'xyz';
370+
$body = 'foo';
371+
$headers = ['test' => 'bar'];
372+
$delay = 920;
373+
$expectedDelay = 0;
374+
375+
$client = $this->createMock(PheanstalkInterface::class);
376+
$client->expects($this->once())->method('useTube')->with($tube)->willReturn($client);
377+
$client->expects($this->once())->method('put')->with(
378+
$this->anything(),
379+
$this->anything(),
380+
$expectedDelay,
381+
$this->anything(),
382+
);
383+
384+
$connection = new Connection(['tube_name' => $tube], $client);
385+
$connection->send($body, $headers, $delay);
386+
}
366387
}

src/Symfony/Component/Messenger/Bridge/Beanstalkd/Transport/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function send(string $body, array $headers, int $delay = 0): string
124124
$job = $this->client->useTube($this->tube)->put(
125125
$message,
126126
PheanstalkInterface::DEFAULT_PRIORITY,
127-
$delay / 1000,
127+
(int) ($delay / 1000),
128128
$this->ttr
129129
);
130130
} catch (Exception $exception) {

0 commit comments

Comments
 (0)