function DatabaseBackend::ensureTableExists

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::ensureTableExists()
  2. 8.9.x core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::ensureTableExists()
  3. 11.x core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::ensureTableExists()

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

2 calls to DatabaseBackend::ensureTableExists()
DatabaseBackend::isAllowed in core/lib/Drupal/Core/Flood/DatabaseBackend.php
DatabaseBackend::register in core/lib/Drupal/Core/Flood/DatabaseBackend.php

File

core/lib/Drupal/Core/Flood/DatabaseBackend.php, line 174

Class

DatabaseBackend
Defines the database flood backend. This is the default Drupal backend.

Namespace

Drupal\Core\Flood

Code

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

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