File tree Expand file tree Collapse file tree 4 files changed +11
-14
lines changed
src/Symfony/Component/Messenger Expand file tree Collapse file tree 4 files changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public function testDecodingFailsWithMissingBodyKey()
36
36
$ serializer = new AmazonSqsSerializer ();
37
37
38
38
$ this ->expectException (MessageDecodingFailedException::class);
39
- $ this ->expectExceptionMessage ('Encoded envelope should have at least a "body", or maybe you should implement your own serializer ' );
39
+ $ this ->expectExceptionMessage ('Encoded envelope should have at least a "body" ' );
40
40
41
41
$ serializer ->decode ([]);
42
42
}
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Messenger \Bridge \AmazonSqs \Transport ;
13
13
14
+ use Symfony \Component \Messenger \Envelope ;
14
15
use Symfony \Component \Messenger \Transport \Serialization \PhpSerializer ;
15
16
16
17
class AmazonSqsSerializer extends PhpSerializer
17
18
{
18
- protected function shouldBeEncoded ( string $ body ): bool
19
+ public function encode ( Envelope $ envelope ): array
19
20
{
20
- return parent ::shouldBeEncoded ($ body )
21
- || preg_match ('/[^\x20-\x{D7FF}\xA\xD\x9\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u ' , $ body );
21
+ $ encoded = parent ::encode ($ envelope );
22
+ if (preg_match ('/[^\x20-\x{D7FF}\xA\xD\x9\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u ' , $ encoded ['body ' ])) {
23
+ $ encoded ['body ' ] = base64_encode ($ encoded ['body ' ]);
24
+ }
25
+
26
+ return $ encoded ;
22
27
}
23
28
}
Original file line number Diff line number Diff line change 19
19
"php" : " >=7.2.5" ,
20
20
"async-aws/core" : " ^1.5" ,
21
21
"async-aws/sqs" : " ^1.0|^2.0" ,
22
- "symfony/messenger" : " ^5 .4.40|^6.4.8 " ,
22
+ "symfony/messenger" : " ^4 .4.19|^5.0|^6.0 " ,
23
23
"symfony/service-contracts" : " ^1.1|^2|^3" ,
24
24
"psr/log" : " ^1|^2|^3"
25
25
},
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public function encode(Envelope $envelope): array
41
41
42
42
$ body = addslashes (serialize ($ envelope ));
43
43
44
- if ($ this -> shouldBeEncoded ( $ body )) {
44
+ if (! preg_match ( ' //u ' , $ body )) {
45
45
$ body = base64_encode ($ body );
46
46
}
47
47
@@ -50,14 +50,6 @@ public function encode(Envelope $envelope): array
50
50
];
51
51
}
52
52
53
- /**
54
- * Entry point to use stricter condition for base64 encoding.
55
- */
56
- protected function shouldBeEncoded (string $ body ): bool
57
- {
58
- return !preg_match ('//u ' , $ body );
59
- }
60
-
61
53
private function safelyUnserialize (string $ contents )
62
54
{
63
55
if ('' === $ contents ) {
You can’t perform that action at this time.
0 commit comments