Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21a4345

Browse files
committed
bug#51529 [Mailer] [Mailgun] fix parsing of payload timestamp to event date value (DateTimeImmutable) in MailgunPayloadConverter (ovgray)
This PR was merged into the 6.3 branch.Discussion----------[Mailer] [Mailgun] fix parsing of payload timestamp to event date value (DateTimeImmutable) in MailgunPayloadConverter| Q | A| ------------- | ---| Branch? | 6.3| Bug fix? | yes| Tickets |Fix#51522| License | MITFix parsing of $payload['timestamp'] in Mailer/Bridge/Mailgun/RemoteEvent/MailgunPayloadConverter.phpDetails:MailgunPayloadConverter uses`\DateTimeImmutable::createFromFormat('U.u', $payload['timestamp'])`in line 53 to convert the payload timestamp value to a DateTimeImmutable.`\DateTimeImmutable::createFromFormat expects a string as its second parameter. $payload['timestamp'] is a float.`\DateTimeImmutable::createFromFormat will try to convert a float to a string, but does not always provide a string that the function then recognizes as being in 'U.u' format.This bugfix replaces $payload['timestamp'] with sprintf('%.6F', $payload['timestamp']) in MailgunPayloadConverter, lines 53 and 54.It also changes the timestamp in Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/delivered_messages.json to 1521472262.000002, which provides a case in which \DateTimeImmutable::createFromFormat('U.u', $payload['timestamp']) returns false (at least in my setup). Floats are replaced with strings in calls to \DateTimeImmutable::createFromFormat in Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/*.phpCommits-------3225112 fix parsing of payload timestamp to DateTimeImmutable
2 parents810ad9d +3225112 commit21a4345

File tree

10 files changed

+11
-11
lines changed

10 files changed

+11
-11
lines changed

‎src/Symfony/Component/Mailer/Bridge/Mailgun/RemoteEvent/MailgunPayloadConverter.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function convert(array $payload): AbstractMailerEvent
5050
};
5151
$event =newMailerEngagementEvent($name,$payload['id'],$payload);
5252
}
53-
if (!$date = \DateTimeImmutable::createFromFormat('U.u',$payload['timestamp'])) {
54-
thrownewParseException(sprintf('Invalid date "%s".',$payload['timestamp']));
53+
if (!$date = \DateTimeImmutable::createFromFormat('U.u',sprintf('%.6F',$payload['timestamp']))) {
54+
thrownewParseException(sprintf('Invalid date "%s".',sprintf('%.6F',$payload['timestamp'])));
5555
}
5656
$event->setDate($date);
5757
$event->setRecipientEmail($payload['recipient']);

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/clicks.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
$wh->setRecipientEmail('alice@example.com');
77
$wh->setTags(['my_tag_1','my_tag_2']);
88
$wh->setMetadata(['my_var_1' =>'Mailgun Variable #1','my-var-2' =>'awesome']);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u',1521243339.873676));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u','1521243339.873676'));
1010

1111
return$wh;

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/delivered_messages.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"event-data": {
88
"id":"CPgfbmQMTCKtHW6uIWtuVe",
9-
"timestamp":1521472262.908181,
9+
"timestamp":1521472262.000002,
1010
"log-level":"info",
1111
"event":"delivered",
1212
"delivery-status": {

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/delivered_messages.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$wh->setRecipientEmail('alice@example.com');
77
$wh->setTags(['my_tag_1','my_tag_2']);
88
$wh->setMetadata(['my_var_1' =>'Mailgun Variable #1','my-var-2' =>'awesome']);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u',1521472262.908181));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u','1521472262.000002'));
1010
$wh->setReason('OK');
1111

1212
return$wh;

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/opens.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
$wh->setRecipientEmail('alice@example.com');
77
$wh->setTags(['my_tag_1','my_tag_2']);
88
$wh->setMetadata(['my_var_1' =>'Mailgun Variable #1','my-var-2' =>'awesome']);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u',1521243339.873676));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u','1521243339.873676'));
1010

1111
return$wh;

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/permanent_failure.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$wh->setRecipientEmail('alice@example.com');
77
$wh->setTags(['my_tag_1','my_tag_2']);
88
$wh->setMetadata(['my_var_1' =>'Mailgun Variable #1','my-var-2' =>'awesome']);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u',1521233195.375624));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u','1521233195.375624'));
1010
$wh->setReason('No Such User Here');
1111

1212
return$wh;

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/spam_complaints.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
$wh->setRecipientEmail('alice@example.com');
77
$wh->setTags(['my_tag_1','my_tag_2']);
88
$wh->setMetadata(['my_var_1' =>'Mailgun Variable #1','my-var-2' =>'awesome']);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u',1521233123.501324));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u','1521233123.501324'));
1010

1111
return$wh;

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/suppression_failure.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$wh->setRecipientEmail('alice@example.com');
77
$wh->setTags(['my_tag_1','my_tag_2']);
88
$wh->setMetadata(['my_var_1' =>'Mailgun Variable #1','my-var-2' =>'awesome']);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u',1521233195.375624));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u','1521233195.375624'));
1010
$wh->setReason('Not delivering to previously bounced address');
1111

1212
return$wh;

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/temporary_failure.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$wh->setRecipientEmail('alice@example.com');
77
$wh->setTags(['my_tag_1','my_tag_2']);
88
$wh->setMetadata(['my_var_1' =>'Mailgun Variable #1','my-var-2' =>'awesome']);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u',1521472262.908181));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u','1521472262.908181'));
1010
$wh->setReason("4.2.2 The email account that you tried to reach is over quota. Please direct\n4.2.2 the recipient to\n4.2.2 https://support.example.com/mail/?p=422");
1111

1212
return$wh;

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Webhook/Fixtures/unsubscribes.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
$wh->setRecipientEmail('alice@example.com');
77
$wh->setTags(['my_tag_1','my_tag_2']);
88
$wh->setMetadata(['my_var_1' =>'Mailgun Variable #1','my-var-2' =>'awesome']);
9-
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u',1521243339.873676));
9+
$wh->setDate(\DateTimeImmutable::createFromFormat('U.u','1521243339.873676'));
1010

1111
return$wh;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp