Skip to content

[Bug]: Second OptimisticLock on one role skips the update silently #57

Open

Description

@roxblnfk

Describe the bug

When a role has more than one OptimisticLock listener, only the first one locks the update; the others skip it silently. The first listener wraps the update command into WrappedStoreCommand, which is not a ScopeCarrierInterface, so every following lock listener finds no scope to add its condition to and does nothing.

Is this a regression?

Not checked.

To Reproduce

  1. A hand-written schema that registers two OptimisticLock listeners for one role, on different fields (the attribute is not repeatable, but the schema format allows it).
  2. Update the entity while the second lock field changed in the database.
  3. The update succeeds; only the first lock field is checked.

Expected behaviour

Every lock listener adds its condition, or a second lock on the same role is rejected with an error.

Media prove

Not applicable.

Database

All of them.

Your environment

cycle/entity-behavior 1.x, src/Listener/OptimisticLock.php.

Additional context

Found while killing escaped mutants in #55. Not reproduced through attributes, since #[OptimisticLock] is not repeatable.

Activity

  1. added
    status:to be verified
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:to be verifiedtype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions