symfony/lock
Symfony Lock provides a simple, reliable way to create and manage locks, giving exclusive access to shared resources across processes and servers. It supports multiple stores like files, Redis, and databases, with blocking and non-blocking lock modes.
Lock facade, Jobs, and Service Container, reducing boilerplate and leveraging Laravel's ecosystem (e.g., dispatch() with locks, handle() in jobs).#65721) hardens RedisStore so the reserved __write__ hash member can never be issued as a lock token. In the Redis backend, lock metadata is stored in a hash alongside per-token members; a token colliding with a reserved member name is a mutual-exclusion correctness and security defect (potential ownership confusion / unintended release of another holder's lock). Our architecture fit is unchanged — but the assumption "the lock primitive is trustworthy by default" now carries an explicit minimum-version precondition.Lock facade and dependency injection simplify integration (e.g., LockFactory for custom stores).symfony/lock >= 5.4.54 on the 5.4 line, or the equivalent patched release on whichever maintained branch we pin).LockKeyNormalizer in v8.1+) to avoid edge cases in distributed systems.symfony/lock v6.x).StoreInterface implementations or hand-rolled acquire()/release() calls that pass an explicit token — these bypass the library's token generation and must be audited independently, and (c) any code that treats lock state as a Redis hash and reads/writes it directly.dispatch()), resource-level (e.g., user:inventory:123), or workflow-level (e.g., payment:transaction:abc)?composer audit / SCA currently surface this?Lock facade in handle() or dispatch() with Lock middleware.Horizon workers or dispatch() calls with LockStore.Artisan commands with Lock (e.g., php artisan migrate --lock=database).Event listeners across workers with Lock.LockFactory for custom stores (e.g., RedisStore, PdoStore).LockKeyNormalizer (v8.1+) for consistent key generation across distributed systems.flock()).acquire($ttl, $token), custom StoreInterface classes, direct Redis hash access for lock state.symfony/lock >= 5.4.54 (or the patched equivalent on our pinned branch) via Composer.composer audit in CI to confirm the advisory clears; add a guard so the constraint cannot regress.Lock.config(['lock.store' => env('LOCK_STORE', 'redis')])).Lock facade calls (e.g., Lock::acquire('resource:123')).symfony/lock v6.x.Lock facade support (minimal integration needed).composer require symfony/lock.config/lock.php (e.g., Redis DSN, PDO connection)."symfony/lock": "^5.4.54" (or the branch-appropriate equivalent).composer audit is clean in CI.php artisan vendor:publish --tag=lock-config.LockFactory in AppServiceProvider if using custom stores.Lock to job handle():
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\Store\RedisStore;
public function handle(LockFactory $lockFactory)
{
$lock = $lockFactory->createLock('inventory:update:123', new RedisStore());
$acquired = $lock->acquire(true); // Block until acquired
if ($acquired) {
// Critical section
$lock->release();
}
}
Lock middleware in Horizon or dispatch():
$job
composer show symfony/lock, confirm patched version), second diagnostic (were explicit tokens or a custom Redis store used?).__write__ member could corrupt the lock hash or cause ownership confusion — presenting as intermittent duplicate critical-section execution (double-charge, double-decrement of inventory) that is extremely hard to reproduce and easy to misattribute to application logic. This is the highest-severity failure mode the release addresses.composer audit is clean, and — where we hold lock-critical workflows — run the existing concurrency test suite (or a short manual duplicate-execution check on a payment/inventory path) rather than assuming a point release is inert.How can I help you explore Laravel packages today?