Skip to content

Commit 3ba7a48

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: [AssetMapper] Fix `JavaScriptImportPathCompiler` regex for non-latin characters Definition::$class may not be class-string require Cache component versions compatible with Redis 6.1 [Twitter][Notifier] Fix post INIT upload [Messenger][RateLimiter] fix additional message handled when using a rate limiter [Serializer] Revert default groups [Serializer] fixed object normalizer for a class with `cancel` method Fix bucket size reduce when previously created with bigger size
2 parents 4e682e4 + ffd60b6 commit 3ba7a48

27 files changed

+268
-144
lines changed

src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface
5050
)
5151
\s*[\'"`](\.\/[^\'"`\n]++|(\.\.\/)*+[^\'"`\n]++)[\'"`]\s*[;\)]
5252
?
53-
/mx';
53+
/mxu';
5454

5555
public function __construct(
5656
private readonly ImportMapConfigReader $importMapConfigReader,

src/Symfony/Component/AssetMapper/Tests/Compiler/JavaScriptImportPathCompilerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ public static function provideCompileTests(): iterable
172172
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
173173
];
174174

175+
yield 'static_named_import_with_unicode_character' => [
176+
'input' => 'import { ɵmyFunction } from "./other.js";',
177+
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
178+
];
179+
180+
yield 'static_multiple_named_imports' => [
181+
'input' => <<<EOF
182+
import {
183+
myFunction,
184+
helperFunction
185+
} from "./other.js";
186+
EOF
187+
,
188+
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
189+
];
190+
175191
yield 'static_import_everything' => [
176192
'input' => 'import * as myModule from "./other.js";',
177193
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],

src/Symfony/Component/DependencyInjection/Definition.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ public function setClass(?string $class): static
180180

181181
/**
182182
* Gets the service class.
183-
*
184-
* @return class-string|null
185183
*/
186184
public function getClass(): ?string
187185
{

src/Symfony/Component/HttpFoundation/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"require-dev": {
2525
"doctrine/dbal": "^3.6|^4",
2626
"predis/predis": "^1.1|^2.0",
27-
"symfony/cache": "^6.4|^7.0",
27+
"symfony/cache": "^6.4.12|^7.1.5",
2828
"symfony/dependency-injection": "^6.4|^7.0",
2929
"symfony/http-kernel": "^6.4|^7.0",
3030
"symfony/mime": "^6.4|^7.0",
@@ -33,7 +33,7 @@
3333
},
3434
"conflict": {
3535
"doctrine/dbal": "<3.6",
36-
"symfony/cache": "<6.4"
36+
"symfony/cache": "<6.4.12|>=7.0,<7.1.5"
3737
},
3838
"autoload": {
3939
"psr-4": { "Symfony\\Component\\HttpFoundation\\": "" },

src/Symfony/Component/Messenger/Tests/WorkerTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
5050
use Symfony\Component\Messenger\Worker;
5151
use Symfony\Component\RateLimiter\RateLimiterFactory;
52+
use Symfony\Component\RateLimiter\Reservation;
5253
use Symfony\Component\RateLimiter\Storage\InMemoryStorage;
5354

5455
/**
@@ -439,21 +440,21 @@ public function testWorkerRateLimitMessages()
439440
$envelope = [
440441
new Envelope(new DummyMessage('message1')),
441442
new Envelope(new DummyMessage('message2')),
443+
new Envelope(new DummyMessage('message3')),
444+
new Envelope(new DummyMessage('message4')),
442445
];
443446
$receiver = new DummyReceiver([$envelope]);
444447

445448
$bus = $this->createMock(MessageBusInterface::class);
446449
$bus->method('dispatch')->willReturnArgument(0);
447450

448451
$eventDispatcher = new EventDispatcher();
449-
$eventDispatcher->addSubscriber(new StopWorkerOnMessageLimitListener(2));
452+
$eventDispatcher->addSubscriber(new StopWorkerOnMessageLimitListener(4));
450453

451454
$rateLimitCount = 0;
452-
$listener = function (WorkerRateLimitedEvent $event) use (&$rateLimitCount) {
455+
$eventDispatcher->addListener(WorkerRateLimitedEvent::class, static function () use (&$rateLimitCount) {
453456
++$rateLimitCount;
454-
$event->getLimiter()->reset(); // Reset limiter to continue test
455-
};
456-
$eventDispatcher->addListener(WorkerRateLimitedEvent::class, $listener);
457+
});
457458

458459
$rateLimitFactory = new RateLimiterFactory([
459460
'id' => 'bus',
@@ -462,11 +463,14 @@ public function testWorkerRateLimitMessages()
462463
'interval' => '1 minute',
463464
], new InMemoryStorage());
464465

466+
ClockMock::register(Reservation::class);
467+
ClockMock::register(InMemoryStorage::class);
468+
465469
$worker = new Worker(['bus' => $receiver], $bus, $eventDispatcher, null, ['bus' => $rateLimitFactory], new MockClock());
466470
$worker->run();
467471

468-
$this->assertCount(2, $receiver->getAcknowledgedEnvelopes());
469-
$this->assertEquals(1, $rateLimitCount);
472+
$this->assertSame(4, $receiver->getAcknowledgeCount());
473+
$this->assertSame(3, $rateLimitCount);
470474
}
471475

472476
public function testWorkerShouldLogOnStop()

src/Symfony/Component/Messenger/Worker.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ private function rateLimit(string $transportName): void
257257

258258
$this->eventDispatcher?->dispatch(new WorkerRateLimitedEvent($rateLimiter, $transportName));
259259
$rateLimiter->reserve()->wait();
260+
$rateLimiter->consume();
260261
}
261262

262263
private function flush(bool $force): bool

src/Symfony/Component/Notifier/Bridge/Twitter/Tests/TwitterTransportTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ public function testTweetImage()
6666
$transport = $this->createTransport(new MockHttpClient((function () {
6767
yield function (string $method, string $url, array $options) {
6868
$this->assertSame('POST', $method);
69-
$this->assertSame('https://upload.twitter.com/1.1/media/upload.json?command=INIT&total_bytes=185&media_type=image/gif&media_category=tweet_image', $url);
69+
$this->assertSame('https://upload.twitter.com/1.1/media/upload.json', $url);
70+
$this->assertArrayHasKey('body', $options);
71+
$this->assertSame($options['body'], 'command=INIT&total_bytes=185&media_type=image%2Fgif&media_category=tweet_image');
7072
$this->assertArrayHasKey('authorization', $options['normalized_headers']);
7173

7274
return new MockResponse('{"media_id_string":"gif123"}');
@@ -127,15 +129,19 @@ public function testTweetVideo()
127129
$transport = $this->createTransport(new MockHttpClient((function () {
128130
yield function (string $method, string $url, array $options) {
129131
$this->assertSame('POST', $method);
130-
$this->assertSame('https://upload.twitter.com/1.1/media/upload.json?command=INIT&total_bytes=185&media_type=image/gif&media_category=tweet_video', $url);
132+
$this->assertSame('https://upload.twitter.com/1.1/media/upload.json', $url);
133+
$this->assertArrayHasKey('body', $options);
134+
$this->assertSame($options['body'], 'command=INIT&total_bytes=185&media_type=image%2Fgif&media_category=tweet_video');
131135
$this->assertArrayHasKey('authorization', $options['normalized_headers']);
132136

133137
return new MockResponse('{"media_id_string":"gif123"}');
134138
};
135139

136140
yield function (string $method, string $url, array $options) {
137141
$this->assertSame('POST', $method);
138-
$this->assertSame('https://upload.twitter.com/1.1/media/upload.json?command=INIT&total_bytes=185&media_type=image/gif&media_category=subtitles', $url);
142+
$this->assertSame('https://upload.twitter.com/1.1/media/upload.json', $url);
143+
$this->assertArrayHasKey('body', $options);
144+
$this->assertSame($options['body'], 'command=INIT&total_bytes=185&media_type=image%2Fgif&media_category=subtitles');
139145
$this->assertArrayHasKey('authorization', $options['normalized_headers']);
140146

141147
return new MockResponse('{"media_id_string":"sub234"}');

src/Symfony/Component/Notifier/Bridge/Twitter/TwitterTransport.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,32 +156,32 @@ private function uploadMedia(array $media): array
156156
'category' => $category,
157157
'owners' => $extraOwners,
158158
]) {
159-
$query = [
159+
$body = [
160160
'command' => 'INIT',
161161
'total_bytes' => $file->getSize(),
162162
'media_type' => $file->getContentType(),
163163
];
164164

165165
if ($category) {
166-
$query['media_category'] = $category;
166+
$body['media_category'] = $category;
167167
}
168168

169169
if ($extraOwners) {
170-
$query['additional_owners'] = implode(',', $extraOwners);
170+
$body['additional_owners'] = implode(',', $extraOwners);
171171
}
172172

173173
$pool[++$i] = $this->request('POST', '/1.1/media/upload.json', [
174-
'query' => $query,
174+
'body' => $body,
175175
'user_data' => [$i, null, 0, fopen($file->getPath(), 'r'), $alt, $subtitles],
176176
]);
177177

178178
if ($subtitles) {
179-
$query['total_bytes'] = $subtitles->getSize();
180-
$query['media_type'] = $subtitles->getContentType();
181-
$query['media_category'] = 'subtitles';
179+
$body['total_bytes'] = $subtitles->getSize();
180+
$body['media_type'] = $subtitles->getContentType();
181+
$body['media_category'] = 'subtitles';
182182

183183
$pool[++$i] = $this->request('POST', '/1.1/media/upload.json', [
184-
'query' => $query,
184+
'body' => $body,
185185
'user_data' => [$i, null, 0, fopen($subtitles->getPath(), 'r'), null, $subtitles],
186186
]);
187187
}

src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@ public function getProperties(string $class, array $context = []): ?array
3838
return null;
3939
}
4040

41-
$groups = $context['serializer_groups'] ?? [];
42-
$groupsHasBeenDefined = [] !== $groups;
43-
$groups = array_merge($groups, ['Default', (false !== $nsSep = strrpos($class, '\\')) ? substr($class, $nsSep + 1) : $class]);
44-
4541
$properties = [];
4642
$serializerClassMetadata = $this->classMetadataFactory->getMetadataFor($class);
4743

4844
foreach ($serializerClassMetadata->getAttributesMetadata() as $serializerAttributeMetadata) {
49-
if (!$serializerAttributeMetadata->isIgnored() && (!$groupsHasBeenDefined || array_intersect(array_merge($serializerAttributeMetadata->getGroups(), ['*']), $groups))) {
45+
if (!$serializerAttributeMetadata->isIgnored() && (null === $context['serializer_groups'] || \in_array('*', $context['serializer_groups'], true) || array_intersect($serializerAttributeMetadata->getGroups(), $context['serializer_groups']))) {
5046
$properties[] = $serializerAttributeMetadata->getName();
5147
}
5248
}

src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public function testGetProperties()
4343
public function testGetPropertiesWithIgnoredProperties()
4444
{
4545
$this->assertSame(['visibleProperty'], $this->extractor->getProperties(IgnorePropertyDummy::class, ['serializer_groups' => ['a']]));
46-
$this->assertSame(['visibleProperty'], $this->extractor->getProperties(IgnorePropertyDummy::class, ['serializer_groups' => ['Default']]));
47-
$this->assertSame(['visibleProperty'], $this->extractor->getProperties(IgnorePropertyDummy::class, ['serializer_groups' => ['IgnorePropertyDummy']]));
4846
}
4947

5048
public function testGetPropertiesWithAnyGroup()

0 commit comments

Comments
 (0)