Skip to content

Commit 020b689

Browse files
committed
Merge branch '5.4' into 6.2
* 5.4: relax assertions for ICU 72.1 [Validator] Fix regression with class metadatada on parent classes [VarExporter] Fix exporting classes with __serialize() but not __unserialize() [HttpFoundation][HttpKernel] Fix deprecations when `Content-Type` is `null`
2 parents a50480f + 75d6ba0 commit 020b689

File tree

16 files changed

+124
-41
lines changed

16 files changed

+124
-41
lines changed

src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool
105105
if (isset($mapping['originalClass']) && !str_contains($mapping['declaredField'], '.')) {
106106
$metadata->addPropertyConstraint($mapping['declaredField'], new Valid());
107107
$loaded = true;
108-
} elseif (property_exists($className, $mapping['fieldName'])) {
108+
} elseif (property_exists($className, $mapping['fieldName']) && (!$doctrineMetadata->isMappedSuperclass || $metadata->getReflectionClass()->getProperty($mapping['fieldName'])->isPrivate())) {
109109
$metadata->addPropertyConstraint($mapping['fieldName'], new Length(['max' => $mapping['length']]));
110110
$loaded = true;
111111
}

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testTransformToDifferentLocale()
124124

125125
$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');
126126

127-
$this->assertEquals('Feb 3, 2010, 4:05 AM', $transformer->transform($this->dateTime));
127+
$this->assertMatchesRegularExpression('/^Feb 3, 2010, 4:05\s+AM$/u', $transformer->transform($this->dateTime));
128128
}
129129

130130
public function testTransformEmpty()

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ public function testSingleTextWidgetWithCustomNonHtml5Format()
530530
]);
531531
$view = $form->createView();
532532

533-
$this->assertSame('2/13/19, 7:12:13 PM', $view->vars['value']);
533+
$this->assertMatchesRegularExpression('#^2/13/19, 7:12:13\s+PM$#u', $view->vars['value']);
534534
}
535535

536536
public function testDateTypeChoiceErrorsBubbleUp()

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function prepare(Request $request): static
281281
$charset = $this->charset ?: 'UTF-8';
282282
if (!$headers->has('Content-Type')) {
283283
$headers->set('Content-Type', 'text/html; charset='.$charset);
284-
} elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) {
284+
} elseif (0 === stripos($headers->get('Content-Type') ?? '', 'text/') && false === stripos($headers->get('Content-Type') ?? '', 'charset')) {
285285
// add the charset
286286
$headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset);
287287
}

src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,16 @@ public function testContentTypeCharset()
537537
$this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type'));
538538
}
539539

540+
public function testContentTypeIsNull()
541+
{
542+
$response = new Response('foo');
543+
$response->headers->set('Content-Type', null);
544+
545+
$response->prepare(new Request());
546+
547+
$this->expectNotToPerformAssertions();
548+
}
549+
540550
public function testPrepareDoesNothingIfContentTypeIsSet()
541551
{
542552
$response = new Response('foo');

src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public function collect(Request $request, Response $response, \Throwable $except
108108
if (!$this->requestStack
109109
|| !$response->headers->has('X-Debug-Token')
110110
|| $response->isRedirection()
111-
|| ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type'), 'html'))
111+
|| ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type') ?? '', 'html'))
112112
|| 'html' !== $request->getRequestFormat()
113113
|| false === strripos($response->getContent(), '</body>')
114114
) {
115-
if ($response->headers->has('Content-Type') && str_contains($response->headers->get('Content-Type'), 'html')) {
115+
if ($response->headers->has('Content-Type') && str_contains($response->headers->get('Content-Type') ?? '', 'html')) {
116116
$dumper = new HtmlDumper('php://output', $this->charset);
117117
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
118118
} else {

src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\RequestStack;
1617
use Symfony\Component\HttpFoundation\Response;
1718
use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
1819
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
@@ -156,4 +157,22 @@ public function testFlushNothingWhenDataDumperIsProvided()
156157
$collector->__destruct();
157158
$this->assertEmpty(ob_get_clean());
158159
}
160+
161+
public function testNullContentTypeWithNoDebugEnv()
162+
{
163+
$request = new Request();
164+
$requestStack = new RequestStack();
165+
$requestStack->push($request);
166+
167+
$response = new Response('<html><head></head><body></body></html>');
168+
$response->headers->set('Content-Type', null);
169+
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
170+
171+
$collector = new DumpDataCollector(null, null, null, $requestStack);
172+
$collector->collect($request, $response);
173+
174+
ob_start();
175+
$collector->__destruct();
176+
$this->assertEmpty(ob_get_clean());
177+
}
159178
}

src/Symfony/Component/Validator/Mapping/ClassMetadata.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ public function mergeConstraints(self $source)
342342

343343
if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
344344
$property = $member->getPropertyName();
345-
$this->members[$property] = [$member];
345+
$this->members[$property][] = $member;
346346

347-
if ($member instanceof PropertyMetadata) {
347+
if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
348348
$this->properties[$property] = $member;
349-
} elseif ($member instanceof GetterMetadata) {
349+
} elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
350350
$this->getters[$property] = $member;
351351
}
352352
} else {

src/Symfony/Component/Validator/Tests/Fixtures/Annotation/Entity.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class Entity extends EntityParent implements EntityInterfaceB
5555
private $internal;
5656
public $data = 'Overridden data';
5757
public $initialized = false;
58+
/**
59+
* @Assert\Type("integer")
60+
*/
61+
protected $other;
5862

5963
public function __construct($internal = null)
6064
{

src/Symfony/Component/Validator/Tests/Fixtures/Attribute/Entity.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class Entity extends EntityParent implements EntityInterfaceB
5757
private $internal;
5858
public $data = 'Overridden data';
5959
public $initialized = false;
60+
#[Assert\Type('integer')]
61+
protected $other;
6062

6163
public function __construct($internal = null)
6264
{

0 commit comments

Comments
 (0)