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

Commit180c4f8

Browse files
committed
feature#47460 [Messenger] add dedicated method for disabling instead of passing boolean flags (xabbuh)
This PR was merged into the 6.2 branch.Discussion----------[Messenger] add dedicated method for disabling instead of passing boolean flags| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | no| New feature? | yes (changes#39622)| Deprecations? | no| Tickets || License | MIT| Doc PR |Commits-------99fac74 add dedicated method for disabling instead of passing boolean flags
2 parentscc4003b +99fac74 commit180c4f8

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

‎src/Symfony/Component/Messenger/Command/FailedMessagesRemoveCommand.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ private function removeMessages(string $failureTransportName, array $ids, Receiv
7474
}
7575

7676
foreach ($idsas$id) {
77-
$this->phpSerializer?->enableClassNotFoundCreation();
77+
$this->phpSerializer?->acceptPhpIncompleteClass();
7878
try {
7979
$envelope =$receiver->find($id);
8080
}finally {
81-
$this->phpSerializer?->enableClassNotFoundCreation(false);
81+
$this->phpSerializer?->rejectPhpIncompleteClass();
8282
}
8383

8484
if (null ===$envelope) {

‎src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ private function runInteractive(string $failureTransportName, SymfonyStyle $io,
135135
// handling the message
136136
while (true) {
137137
$envelopes = [];
138-
$this->phpSerializer?->enableClassNotFoundCreation();
138+
$this->phpSerializer?->acceptPhpIncompleteClass();
139139
try {
140140
foreach ($receiver->all(1)as$envelope) {
141141
++$count;
142142
$envelopes[] =$envelope;
143143
}
144144
}finally {
145-
$this->phpSerializer?->enableClassNotFoundCreation(false);
145+
$this->phpSerializer?->rejectPhpIncompleteClass();
146146
}
147147

148148
// break the loop if all messages are consumed
@@ -212,11 +212,11 @@ private function retrySpecificIds(string $failureTransportName, array $ids, Symf
212212
}
213213

214214
foreach ($idsas$id) {
215-
$this->phpSerializer?->enableClassNotFoundCreation();
215+
$this->phpSerializer?->acceptPhpIncompleteClass();
216216
try {
217217
$envelope =$receiver->find($id);
218218
}finally {
219-
$this->phpSerializer?->enableClassNotFoundCreation(false);
219+
$this->phpSerializer?->rejectPhpIncompleteClass();
220220
}
221221
if (null ===$envelope) {
222222
thrownewRuntimeException(sprintf('The message "%s" was not found.',$id));

‎src/Symfony/Component/Messenger/Command/FailedMessagesShowCommand.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private function listMessages(?string $failedTransportName, SymfonyStyle $io, in
9696
$io->comment(sprintf('Displaying only\'%s\' messages',$classFilter));
9797
}
9898

99-
$this->phpSerializer?->enableClassNotFoundCreation();
99+
$this->phpSerializer?->acceptPhpIncompleteClass();
100100
try {
101101
foreach ($envelopesas$envelope) {
102102
$currentClassName =\get_class($envelope->getMessage());
@@ -118,7 +118,7 @@ private function listMessages(?string $failedTransportName, SymfonyStyle $io, in
118118
];
119119
}
120120
}finally {
121-
$this->phpSerializer?->enableClassNotFoundCreation(false);
121+
$this->phpSerializer?->rejectPhpIncompleteClass();
122122
}
123123

124124
$rowsCount =\count($rows);
@@ -148,7 +148,7 @@ private function listMessagesPerClass(?string $failedTransportName, SymfonyStyle
148148

149149
$countPerClass = [];
150150

151-
$this->phpSerializer?->enableClassNotFoundCreation();
151+
$this->phpSerializer?->acceptPhpIncompleteClass();
152152
try {
153153
foreach ($envelopesas$envelope) {
154154
$c =\get_class($envelope->getMessage());
@@ -160,7 +160,7 @@ private function listMessagesPerClass(?string $failedTransportName, SymfonyStyle
160160
++$countPerClass[$c][1];
161161
}
162162
}finally {
163-
$this->phpSerializer?->enableClassNotFoundCreation(false);
163+
$this->phpSerializer?->rejectPhpIncompleteClass();
164164
}
165165

166166
if (0 ===\count($countPerClass)) {
@@ -176,11 +176,11 @@ private function showMessage(?string $failedTransportName, string $id, SymfonySt
176176
{
177177
/** @var ListableReceiverInterface $receiver */
178178
$receiver =$this->getReceiver($failedTransportName);
179-
$this->phpSerializer?->enableClassNotFoundCreation();
179+
$this->phpSerializer?->acceptPhpIncompleteClass();
180180
try {
181181
$envelope =$receiver->find($id);
182182
}finally {
183-
$this->phpSerializer?->enableClassNotFoundCreation(false);
183+
$this->phpSerializer?->rejectPhpIncompleteClass();
184184
}
185185
if (null ===$envelope) {
186186
thrownewRuntimeException(sprintf('The message "%s" was not found.',$id));

‎src/Symfony/Component/Messenger/Tests/Transport/Serialization/PhpSerializerWithClassNotFoundSupportTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testDecodingFailsButCreateClassNotFound()
6565
protectedfunctioncreatePhpSerializer():PhpSerializer
6666
{
6767
$serializer =newPhpSerializer();
68-
$serializer->enableClassNotFoundCreation();
68+
$serializer->acceptPhpIncompleteClass();
6969

7070
return$serializer;
7171
}

‎src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,22 @@
2121
*/
2222
class PhpSerializerimplements SerializerInterface
2323
{
24-
privatebool$createClassNotFound =false;
24+
privatebool$acceptPhpIncompleteClass =false;
2525

26-
publicfunctionenableClassNotFoundCreation(bool$enable =true):void
26+
/**
27+
* @internal
28+
*/
29+
publicfunctionacceptPhpIncompleteClass():void
30+
{
31+
$this->acceptPhpIncompleteClass =true;
32+
}
33+
34+
/**
35+
* @internal
36+
*/
37+
publicfunctionrejectPhpIncompleteClass():void
2738
{
28-
$this->createClassNotFound =$enable;
39+
$this->acceptPhpIncompleteClass =false;
2940
}
3041

3142
publicfunctiondecode(array$encodedEnvelope):Envelope
@@ -66,7 +77,7 @@ private function safelyUnserialize(string $contents): Envelope
6677

6778
$signalingException =newMessageDecodingFailedException(sprintf('Could not decode message using PHP serialization: %s.',$contents));
6879

69-
if ($this->createClassNotFound) {
80+
if ($this->acceptPhpIncompleteClass) {
7081
$prevUnserializeHandler =ini_set('unserialize_callback_func',null);
7182
}else {
7283
$prevUnserializeHandler =ini_set('unserialize_callback_func',self::class.'::handleUnserializeCallback');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp