8000 Merge branch '6.4' into 7.0 · symfony/symfony@adcadd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit adcadd1

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: relax assertions for ICU 72.1 [Validator] Fix regression with class metadatada on parent classes [Intl] Fixed directory traversal in emoji compression tool [VarExporter] Fix exporting classes with __serialize() but not __unserialize() [HttpFoundation][HttpKernel] Fix deprecations when `Content-Type` is `null`
2 parents ab06dca + b15e258 commit adcadd1

File tree

18 files changed

+137
-43
lines changed

18 files changed

+137
-43
lines changed

.github/workflows/intl-data-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ jobs:
8484
run: |
8585
[ -f src/Symfony/Component/Intl/Resources/data/locales/en.php ]
8686
[ ! -f src/Symfony/Component/Intl/Resources/data/locales/en.php.gz ]
87+
[ -f src/Symfony/Component/Intl/Resources/data/transliterator/emoji/emoji-en.php ]
88+
[ ! -f src/Symfony/Component/Intl/Resources/data/transliterator/emoji/emoji-en.php.gz ]
8789
src/Symfony/Component/Intl/Resources/bin/compress
8890
[ ! -f src/Symfony/Component/Intl/Resources/data/locales/en.php ]
8991
[ -f src/Symfony/Component/Intl/Resources/data/locales/en.php.gz ]
92+
[ ! -f src/Symfony/Component/Intl/Resources/data/transliterator/emoji/emoji-en.php ]
93+
[ -f src/Symfony/Component/Intl/Resources/data/transliterator/emoji/emoji-en.php.gz ]
9094
./phpunit src/Symfony/Component/Intl

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
@@ -537,7 +537,7 @@ public function testSingleTextWidgetWithCustomNonHtml5Format()
537537
]);
538538
$view = $form->createView();
539539

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

543543
public function testDateTypeChoiceErrorsBubbleUp()

src/Symfony/Component/HttpFoundation/Response.php

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

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

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

551+
public function testContentTypeIsNull()
552+
{
553+
$response = new Response('foo');
554+
$response->headers->set('Content-Type', null);
555+
556+
$response->prepare(new Request());
557+
558+
$this->expectNotToPerformAssertions();
559+
}
560+
551561
public function testPrepareDoesNothingIfContentTypeIsSet()
552562
{
553563
$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
@@ -113,11 +113,11 @@ public function collect(Request $request, Response $response, \Throwable $except
113113
if (!$this->requestStack
114114
|| !$response->headers->has('X-Debug-Token')
115115
|| $response->isRedirection()
116-
|| ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type'), 'html'))
116+
|| ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type') ?? '', 'html'))
117117
|| 'html' !== $request->getRequestFormat()
118118
|| false === strripos($response->getContent(), '</body>')
119119
) {
120-
if ($response->headers->has('Content-Type') && str_contains($response->headers->get('Content-Type'), 'html')) {
120+
if ($response->headers->has('Content-Type') && str_contains($response->headers->get('Content-Type') ?? '', 'html')) {
121121
$dumper = new HtmlDumper('php://output', $this->charset);
122122
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
123123
} 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;
@@ -158,4 +159,22 @@ public function testFlushNothingWhenDataDumperIsProvided()
158159
$collector->__destruct();
159160
$this->assertEmpty(ob_get_clean());
160161
}
162+
163+
public function testNullContentTypeWithNoDebugEnv()
164+
{
165+
$request = new Request();
166+
$requestStack = new RequestStack();
167+
$requestStack->push($request);
168+
169+
$response = new Response('<html><head></head><body></body></html>');
170+
$response->headers->set('Content-Type', null);
171+
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
172+
173+
$collector = new DumpDataCollector(null, null, null, $requestStack);
174+
$collector->collect($request, $response);
175+
176+
ob_start();
177+
$collector->__destruct();
178+
$this->assertEmpty(ob_get_clean());
179+
}
161180
}

src/Symfony/Component/Intl/Resources/bin/compress

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ if (!extension_loaded('zlib')) {
1717
throw new Exception('This script requires the zlib extension.');
1818
}
1919

20-
foreach (glob(dirname(__DIR__).'/data/*/*.php') as $file) {
21-
if ('meta.php' === basename($file)) {
20+
$iterator = new RecursiveIteratorIterator(
21+
new RecursiveDirectoryIterator(
22+
dirname(__DIR__).'/data',
23+
FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS
24+
)
25+
);
26+
27+
foreach ($iterator as $file) {
28+
if ('php' !== $file->getExtension() || 'meta.php' === $file->getFilename()) {
2229
continue;
2330
}
2431

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

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

347347
if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
348348
$property = $member->getPropertyName();
349-
$this->members[$property] = [$member];
349+
$this->members[$property][] = $member;
350350

351-
if ($member instanceof PropertyMetadata) {
351+
if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
352352
$this->properties[$property] = $member;
353-
} elseif ($member instanceof GetterMetadata) {
353+
} elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
354354
$this->getters[$property] = $member;
355355
}
356356
} else {

0 commit comments

Comments
 (0)
102
0