Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DoctrineDbalStore.php

function DoctrineDbalStore::putOffExpiration

Overrides PersistingStoreInterface::putOffExpiration

1 call to DoctrineDbalStore::putOffExpiration()
DoctrineDbalStore::save in vendor/symfony/lock/Store/DoctrineDbalStore.php
Stores the resource if it's not locked by someone else.

File

vendor/symfony/lock/Store/DoctrineDbalStore.php, line 132

Class

DoctrineDbalStore
DbalStore is a PersistingStoreInterface implementation using a Doctrine DBAL connection.

Namespace

Symfony\Component\Lock\Store

Code

public function putOffExpiration(Key $key, $ttl) : void {
    if ($ttl < 1) {
        throw new InvalidTtlException(\sprintf('"%s()" expects a TTL greater or equals to 1 second. Got "%s".', __METHOD__, $ttl));
    }
    $key->reduceLifetime($ttl);
    $sql = "UPDATE {$this->table} SET {$this->expirationCol} = {$this->getCurrentTimestampStatement()} + ?, {$this->tokenCol} = ? WHERE {$this->idCol} = ? AND ({$this->tokenCol} = ? OR {$this->expirationCol} <= {$this->getCurrentTimestampStatement()})";
    $uniqueToken = $this->getUniqueToken($key);
    $result = $this->conn
        ->executeQuery($sql, [
        $ttl,
        $uniqueToken,
        $this->getHashedKey($key),
        $uniqueToken,
    ], [
        ParameterType::INTEGER,
        ParameterType::STRING,
        ParameterType::STRING,
        ParameterType::STRING,
    ]);
    // If this method is called twice in the same second, the row wouldn't be updated. We have to call exists to know if we are the owner
    if (!$result->rowCount() && !$this->exists($key)) {
        throw new LockConflictedException();
    }
    $this->checkNotExpired($key);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal