Change record status: 
Project: 
Introduced in branch: 
8.7.x
Introduced in version: 
8.7.0
Description: 

Previously, the result of \Drupal\Core\TempStore\PrivateTempStore::getMetadata() and \Drupal\Core\TempStore\SharedTempStore::getMetadata() would return a \stdClass object with an owner property and an updated property.
Now, a \Drupal\Core\TempStore\Lock object will be returned instead. The owner property is now accessed via Lock::getOwnerId() and the updated property is now accessed via Lock::getUpdated().

Before

$lock = $this->tempStore->getMetadata($key);
if ($lock) {
  $user = $this->entityTypeManager->getStorage('user')->load($lock->owner);
  $age = $this->dateFormatter->formatTimeDiffSince($lock->updated);
}

After

$lock = $this->tempStore->getMetadata($key);
if ($lock) {
  $user = $this->entityTypeManager->getStorage('user')->load($lock->getOwnerId());
  $age = $this->dateFormatter->formatTimeDiffSince($lock->getUpdated());
}

Locks are often accompanied by forms allowing the locks to be broken. In order to help make presenting a message about the lock easier, a new render element is provided:

  $build['examples_lock'] = [
    '#type' => 'break_lock_link',
    '#label' => $this->t('example item'),
    '#lock' => $tempstore->getMetadata('example_key'),
    '#url' => \Drupal\Core\Url::fromRoute('examples.break_lock_form'),
  ];

This will generate a message that says:
This @label is being edited by user @user, and is therefore locked from editing by others. This lock is @age old. Click here to <a href=":url">break this lock</a>.

Impacts: 
Module developers