API page: https://api.drupal.org/api/drupal/includes%21lock.inc/function/lock_acqu...

lock_acquire() lets you pick an arbitrary name for your lock. But this obviously has some sort of limit on its length. The docs should say what that is.

Looking at my dev site's database, it looks like it's 255 chars.

Comments

pushpinderchauhan’s picture

Status: Active » Needs review
StatusFileSize
new451 bytes

Please review.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Looks good! Thanks!

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs review

Does this limit exist in Drupal 8 as well? There is a LocakBackendInterface::acquire() function that probably does the same thing?

jhodgdon’s picture

Version: 7.x-dev » 8.0.x-dev
Status: Needs review » Needs work
pushpinderchauhan’s picture

Status: Needs work » Needs review
StatusFileSize
new500 bytes

Patch for D8.

jhodgdon’s picture

Component: documentation » base system
Status: Needs review » Reviewed & tested by the community

Patch looks fine to me. My only question is since this is going on the Interface documentation, whether the length limit only applies to some implementations or really does apply to the Interface. Moving to "base system" so the maintainers of the Lock system can comment. Meanwhile, marking RTBC...

joachim’s picture

There is only one actual implementation of this interface in core that does anything, DatabaseLockBackend. That's what has this character limit.
If we say that the limit applies to the implementation, then we're watering down the purpose of the interface, which is to define the way this is used. So it makes sense to me to define the length limit on the interface. Otherwise, we're breaking the pluggable nature of the backends, as we could have ContribLockBackend that has either a longer or a shorter limit, and then a site changing its backend could find its locks don't work properly any more.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed e8b5a65 and pushed to 8.0.x. Thanks!

  • alexpott committed e8b5a65 on 8.0.x
    Issue #2334689 by er.pushpinderrana | joachim: Fixed lock_acquire()...
jhodgdon’s picture

Version: 8.0.x-dev » 7.x-dev
Status: Fixed » Reviewed & tested by the community

Thanks! Patch in #1 is RTBC for 7.x.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: drupal8-character-limit-for-the-lock-name-2334689-5.patch, failed testing.

joachim’s picture

Status: Needs work » Reviewed & tested by the community

The test failure is for the D8 patch. D7 patch is green.

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Committed patch in #1 to Drupal 7.x. Thanks again!

  • jhodgdon committed 3bd008b on 7.x
    Issue #2334689 by er.pushpinderrana, joachim: Document character limit...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.