Skip to content

Commit 30e559f

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: Remove comment about AppVeyor in `phpunit` [Webhook][RemoteEvent] fix SendgridPayloadConverter category support Update old Appveyor skip conditions sync the Dutch translation file with changes from the 7.2 branch [Yaml] fix inline notation with inline comment fix(property-info): make sure that SerializerExtractor returns null for invalid class metadata [RemoteEvent][Webhook] fix SendgridRequestParser & SendgridPayloadConverter in case of missing sg_message_id fix_50486 - memory leak
2 parents 6724c25 + af68b6e commit 30e559f

File tree

12 files changed

+64
-15
lines changed

12 files changed

+64
-15
lines changed

phpunit

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/usr/bin/env php
22
<?php
33

4-
// Cache-Id: 2021-05-27 20:30 UTC
5-
// For caching to work properly on appveyor, this file
6-
// must be exactly the same in all maintained branches
7-
84
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
95
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
106
exit(1);

src/Symfony/Component/Mailer/Bridge/Sendgrid/RemoteEvent/SendgridPayloadConverter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function convert(array $payload): AbstractMailerEvent
3131
'deferred' => MailerDeliveryEvent::DEFERRED,
3232
'bounce' => MailerDeliveryEvent::BOUNCE,
3333
};
34-
$event = new MailerDeliveryEvent($name, $payload['sg_message_id'], $payload);
34+
$event = new MailerDeliveryEvent($name, $payload['sg_message_id'] ?? $payload['sg_event_id'], $payload);
3535
$event->setReason($payload['reason'] ?? '');
3636
} else {
3737
$name = match ($payload['event']) {
@@ -41,7 +41,7 @@ public function convert(array $payload): AbstractMailerEvent
4141
'spamreport' => MailerEngagementEvent::SPAM,
4242
default => throw new ParseException(\sprintf('Unsupported event "%s".', $payload['event'])),
4343
};
44-
$event = new MailerEngagementEvent($name, $payload['sg_message_id'], $payload);
44+
$event = new MailerEngagementEvent($name, $payload['sg_message_id'] ?? $payload['sg_event_id'], $payload);
4545
}
4646

4747
if (!$date = \DateTimeImmutable::createFromFormat('U', $payload['timestamp'])) {
@@ -51,7 +51,7 @@ public function convert(array $payload): AbstractMailerEvent
5151
$event->setDate($date);
5252
$event->setRecipientEmail($payload['email']);
5353
$event->setMetadata([]);
54-
$event->setTags($payload['category'] ?? []);
54+
$event->setTags((array) ($payload['category'] ?? []));
5555

5656
return $event;
5757
}

src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/RemoteEvent/SendgridPayloadConverterTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,35 @@ public function testInvalidDate()
9797
'email' => 'test@example.com',
9898
]);
9999
}
100+
101+
public function testAsynchronousBounce()
102+
{
103+
$converter = new SendgridPayloadConverter();
104+
105+
$event = $converter->convert([
106+
'event' => 'bounce',
107+
'sg_event_id' => '123456',
108+
'timestamp' => '123456789',
109+
'email' => 'test@example.com',
110+
]);
111+
112+
$this->assertInstanceOf(MailerDeliveryEvent::class, $event);
113+
$this->assertSame('123456', $event->getId());
114+
}
115+
116+
public function testWithStringCategory()
117+
{
118+
$converter = new SendgridPayloadConverter();
119+
120+
$event = $converter->convert([
121+
'event' => 'processed',
122+
'sg_message_id' => '123456',
123+
'timestamp' => '123456789',
124+
'email' => 'test@example.com',
125+
'category' => 'cat facts',
126+
]);
127+
128+
$this->assertInstanceOf(MailerDeliveryEvent::class, $event);
129+
$this->assertSame(['cat facts'], $event->getTags());
130+
}
100131
}

src/Symfony/Component/Mailer/Bridge/Sendgrid/Webhook/SendgridRequestParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function doParse(Request $request, string $secret): array
5151
!isset($content[0]['email'])
5252
|| !isset($content[0]['timestamp'])
5353
|| !isset($content[0]['event'])
54-
|| !isset($content[0]['sg_message_id'])
54+
|| !isset($content[0]['sg_event_id'])
5555
) {
5656
throw new RejectWebhookException(406, 'Payload is malformed.');
5757
}

src/Symfony/Component/Mailer/Transport/SendmailTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected function doSend(SentMessage $message): void
114114
$this->stream->setCommand($command);
115115
$this->stream->initialize();
116116
foreach ($chunks as $chunk) {
117-
$this->stream->write($chunk);
117+
$this->stream->write($chunk, false);
118118
}
119119
$this->stream->flush();
120120
$this->stream->terminate();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getProperties(string $class, array $context = []): ?array
3434
return null;
3535
}
3636

37-
if (!$this->classMetadataFactory->getMetadataFor($class)) {
37+
if (!$this->classMetadataFactory->hasMetadataFor($class)) {
3838
return null;
3939
}
4040

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,9 @@ public function testGetPropertiesWithAnyGroup()
4949
{
5050
$this->assertSame(['analyses', 'feet'], $this->extractor->getProperties(AdderRemoverDummy::class, ['serializer_groups' => null]));
5151
}
52+
53+
public function testGetPropertiesWithNonExistentClassReturnsNull()
54+
{
55+
$this->assertSame(null, $this->extractor->getProperties('NonExistent'));
56+
}
5257
}

src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,10 @@
466466
<source>This value should not be after week "{{ max }}".</source>
467467
<target>Deze waarde mag niet na week "{{ max }}" liggen.</target>
468468
</trans-unit>
469+
<trans-unit id="120">
470+
<source>This value is not a valid slug.</source>
471+
<target state="needs-review-translation">Deze waarde is geen geldige slug.</target>
472+
</trans-unit>
469473
</body>
470474
</file>
471475
</xliff>

src/Symfony/Component/VarDumper/Tests/Dumper/ServerDumperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public function testDumpForwardsToWrappedDumperWhenServerIsUnavailable()
3939

4040
public function testDump()
4141
{
42-
if ('True' === getenv('APPVEYOR')) {
43-
$this->markTestSkipped('Skip transient test on AppVeyor');
42+
if ('\\' === \DIRECTORY_SEPARATOR) {
43+
$this->markTestSkipped('Skip transient test on Windows');
4444
}
4545

4646
$wrappedDumper = $this->createMock(DataDumperInterface::class);

src/Symfony/Component/VarDumper/Tests/Server/ConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class ConnectionTest extends TestCase
2424

2525
public function testDump()
2626
{
27-
if ('True' === getenv('APPVEYOR')) {
28-
$this->markTestSkipped('Skip transient test on AppVeyor');
27+
if ('\\' === \DIRECTORY_SEPARATOR) {
28+
$this->markTestSkipped('Skip transient test on Windows');
2929
}
3030

3131
$cloner = new VarCloner();

0 commit comments

Comments
 (0)