-
Couldn't load subscription status.
- Fork 1.4k
PHPORM-167 Fix and test MongoDB failed queue provider #2838
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
Conversation
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.
Suggested comment change.
Also a question about _id types. If the assumption is correct, then just resolve my comment there.
| ->collection('failed_jobs') | ||
| ->raw() | ||
| ->insertMany(array_map(static fn ($i) => [ | ||
| '_id' => new ObjectId(sprintf('%024d', $i)), |
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.
Are _id fields within jobs always an ObjectId? I saw that MongoFailedJobProvider made some assumptions about that by using string for type hints and casting.
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.
Documents are added by the log method which doesn't specify _id. So we get an automatic ObjectId.
Fix PHPORM-167
In Laravel 11.35, the
DatabaseFailedJobProvider::idswas added in order to optimize loading this ids only instead of the full documents. laravel/framework#49186This implementation is not compatible with MongoDB since it references the field
idinstead of_id.Also, the method
DatabaseFailedJobProvider::pruneis not compatible with MongoDB because it tries to delete document by bulks of 1000, which is not supported. MongoDB can only delete one or all documents matching a criteria.I'm also adding tests to the methods inherited from the parent
DatabaseFailedJobProviderto ensure they work with a MongoDB connection.Checklist