DatabaseLock::getCurrentOwner() Does Not Return the Expected Lock Owner
Closed this issue · 3 comments
- Laravel-mongodb Version: #.#.#
- PHP Version: 8.2.24
- Database Driver & Version: Laravel 11
Description:
When using the DatabaseLock::getCurrentOwner() function in Laravel with MongoDB, it always returns null, even when a lock is held. This makes it impossible to verify lock ownership. This happens because getCurrentOwner() expects the database row to be an object, but MongoDB returns an array instead. This mismatch causes the function to fail when retrieving the lock owner.
Steps to reproduce
- Acquire a lock using DatabaseLock.
- Call getCurrentOwner() to check the current owner of the lock.
- The function returns null, even when the lock is active.
Expected behaviour
getCurrentOwner() should return the correct owner of the lock if it is held by a process.
Actual behaviour
Always returns null.
Could you tell what version of the mongodb/laravel-mongodb package you're using?
I added specific lock store for MongoDB, that should be used instead of the DatabaseLock : https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/cache/
We are using Laravel-mongodb 4.8.0
The dedicated cache and lock stores are available in this version: https://github.com/mongodb/laravel-mongodb/tree/4.8/src/Cache
This should solve the problem.