-
Notifications
You must be signed in to change notification settings - Fork 583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x] Fix JobWatcher
when processing deleted instance of SerializesModels
#1539
Conversation
@hapidjus shouldn't we use the new approach only if |
Makes sense. However I'm not sure we can catch exceptions that happens "inside" the unserialize function. It's not necessarily unserialize() that throws. |
I've updated the PR now to try to unserialize first and only use preg_match as fallback. |
@hapidjus Thanks, I'll review it and possibility add some tests to cover the new use case. Will mark it as ready when I'm done with it |
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
JobWatcher
when processing deleted instance of SerializesModels
src/Watchers/JobWatcher.php
Outdated
@@ -266,7 +267,7 @@ protected function getBatchId(array $data) | |||
$properties = ExtractProperties::from($command); | |||
|
|||
return $properties['batchId'] ?? null; | |||
} catch (\Exception|\Error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understrand that catch (\Exception|\Error)
is a bit greedy. But there are other ways that the unserialize can go wrong. For instance when in a multi tenancy context and the database connection has not been set yet. See this issue for instance archtechx/tenancy#1263
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there a use case to include other exceptions we need to see the actual use case and replication steps so we can add tests to cover that usage. Having the scope too wide add a huge risk to this PR getting rejected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I'll see if I can make a minimal reproduction of it. Bur for now I'm happy to have this merged and make another PR later.
If there is a failure when unserializing the command, (for instance if the job deleted a model it received, of the database connection is set dynamically) the jobs will never proceed to processed. See #1479
In this PR unserialize is removed in favor of preg_replace to extract the batch_id