Skip to content

Commit 4c2db0e

Browse files
committed
Fix exception
1 parent 65d0ba4 commit 4c2db0e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Actions/MakeQueueTenantAwareAction.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,21 @@ protected function isTenantAware(JobProcessing|JobRetryRequested $event): bool
4747
{
4848
$payload = $this->getEventPayload($event);
4949

50-
$command = unserialize($payload['data']['command']);
50+
try {
51+
$command = unserialize($payload['data']['command']);
52+
} catch (\Throwable) {
53+
/**
54+
* We might need the tenant to unserialize jobs as models could
55+
* have global scopes set that require a current tenant to
56+
* be active. bindOrForgetCurrentTenant wil reset it.
57+
*/
58+
if ($tenantId = Context::get($this->currentTenantContextKey())) {
59+
$tenant = app(IsTenant::class)::find($tenantId);
60+
$tenant?->makeCurrent();
61+
}
62+
63+
$command = unserialize($payload['data']['command']);
64+
}
5165

5266
$job = $this->getJobFromQueueable($command);
5367

0 commit comments

Comments
 (0)