Skip to content
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

Open
wants to merge 16 commits into
base: 5.x
Choose a base branch
from

Conversation

hapidjus
Copy link

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

@taylorotwell taylorotwell marked this pull request as draft October 24, 2024 14:01
@crynobone
Copy link
Member

@hapidjus shouldn't we use the new approach only if unserialize() return an exception?

@hapidjus
Copy link
Author

hapidjus commented Oct 25, 2024

@hapidjus shouldn't we use the new approach only if unserialize() return an exception?

Makes sense.
This PR was mainly to confirm that using preg_match is a reasonable approach here.
The PR currently doesn’t handle encrypted data or include any tests.

However I'm not sure we can catch exceptions that happens "inside" the unserialize function. It's not necessarily unserialize() that throws.

@hapidjus
Copy link
Author

I've updated the PR now to try to unserialize first and only use preg_match as fallback.

@crynobone
Copy link
Member

@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]>
@crynobone crynobone marked this pull request as ready for review October 26, 2024 07:11
@crynobone crynobone changed the title Replace unserialize with preg_match in JobWatcher [5.x] Fix JobWatcher when processing deleted instance of SerializesModels Oct 26, 2024
@@ -266,7 +267,7 @@ protected function getBatchId(array $data)
$properties = ExtractProperties::from($command);

return $properties['batchId'] ?? null;
} catch (\Exception|\Error) {
Copy link
Author

@hapidjus hapidjus Oct 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants