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

Force cast json decoded failed_job_ids to array in DatabaseBatchRepository #46581

Merged
merged 1 commit into from Mar 25, 2023

Conversation

naciriii
Copy link
Contributor

@naciriii naciriii commented Mar 24, 2023

closes #46580

This PR fixes the referenced issue forcing an array cast of the json decoded from failed_job_ids column in job_batches table.
Mainly here:

  • DatabaseBatchRepository::decrementPendingJobs()
  • DatabaseBatchRepository::incrementFailedJobs()

Thie lines below will be failing if failed_job_ids is null :

// decrementPendingJobs L: 144
json_encode(array_values(array_diff(json_decode($batch->failed_job_ids, true), [$jobId])))
// incrementFailedJobs L:167
json_encode(array_values(array_unique(array_merge(json_decode($batch->failed_job_ids, true), [$jobId])))),

In case if failed_job_ids column has empty or null value for whatever reason (interruption in the issue case, explicit update etc...) it should return an empty array instead of null so the batch won't fail with the exception thrown in the referenced issue.

Thanks.

@taylorotwell taylorotwell merged commit 833f7e8 into laravel:10.x Mar 25, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants