Skip to content

Commit 449cdfd

Browse files
committed
improve serialization for workflow interrupt
1 parent 50111fb commit 449cdfd

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

src/Workflow/Persistence/DatabasePersistence.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,13 @@ public function load(string $workflowId): WorkflowInterrupt
4747
throw new WorkflowException("No saved workflow found for ID: {$workflowId}.");
4848
}
4949

50-
$interruptData = @unserialize(
51-
base64_decode((string) $record['interrupt'], true)
52-
);
50+
$interruptData = base64_decode((string) $record['interrupt'], true);
5351

5452
if ($interruptData === false) {
55-
$interruptData = unserialize($record['interrupt']); // This makes sure that previous records still work
53+
$interruptData = $record['interrupt']; // This makes sure that previous records still work
5654
}
5755

58-
if ($interruptData === false) {
59-
throw new WorkflowException("Failed to unserialize saved workflow for ID: {$workflowId}.");
60-
}
61-
62-
return $interruptData;
56+
return unserialize($interruptData);
6357
}
6458

6559
public function delete(string $workflowId): void

src/Workflow/Persistence/EloquentPersistence.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,13 @@ public function load(string $workflowId): WorkflowInterrupt
4343
->where('workflow_id', $workflowId)
4444
->firstOr(['interrupt'], fn () => throw new WorkflowException("No saved workflow found for ID: {$workflowId}."));
4545

46-
$interruptData = @unserialize(
47-
base64_decode($record->interrupt, true)
48-
);
46+
$interruptData = base64_decode($record->interrupt, true);
4947

5048
if ($interruptData === false) {
51-
$interruptData = unserialize($record->interrupt); // This makes sure that previous records still work
49+
$interruptData = $record->interrupt; // This makes sure that previous records still work
5250
}
5351

54-
if ($interruptData === false) {
55-
throw new WorkflowException("Failed to unserialize saved workflow for ID: {$workflowId}.");
56-
}
57-
58-
return $interruptData;
52+
return unserialize($interruptData);
5953
}
6054

6155
public function delete(string $workflowId): void

0 commit comments

Comments
 (0)