function DatabaseLockBackend::ensureTableExists

Same name in other branches
  1. 9 core/lib/Drupal/Core/Lock/DatabaseLockBackend.php \Drupal\Core\Lock\DatabaseLockBackend::ensureTableExists()
  2. 10 core/lib/Drupal/Core/Lock/DatabaseLockBackend.php \Drupal\Core\Lock\DatabaseLockBackend::ensureTableExists()
  3. 11.x core/lib/Drupal/Core/Lock/DatabaseLockBackend.php \Drupal\Core\Lock\DatabaseLockBackend::ensureTableExists()

Check if the semaphore table exists and create it if not.

1 call to DatabaseLockBackend::ensureTableExists()
DatabaseLockBackend::acquire in core/lib/Drupal/Core/Lock/DatabaseLockBackend.php
Acquires a lock.

File

core/lib/Drupal/Core/Lock/DatabaseLockBackend.php, line 177

Class

DatabaseLockBackend
Defines the database lock backend. This is the default backend in Drupal.

Namespace

Drupal\Core\Lock

Code

protected function ensureTableExists() {
    try {
        $database_schema = $this->database
            ->schema();
        if (!$database_schema->tableExists(static::TABLE_NAME)) {
            $schema_definition = $this->schemaDefinition();
            $database_schema->createTable(static::TABLE_NAME, $schema_definition);
            return TRUE;
        }
    } catch (DatabaseException $e) {
        return TRUE;
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.