DatabaseBackend::ensureTableExists

protected DatabaseBackend::ensureTableExists()

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

File

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

Class

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

Namespace

Drupal\Core\Flood

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
protected function ensureTableExists() {
  try {
    $database_schema = $this->connection->schema();
    if (!$database_schema->tableExists(static::TABLE_NAME)) {
      $schema_definition = $this->schemaDefinition();
      $database_schema->createTable(static::TABLE_NAME, $schema_definition);
      return TRUE;
    }
  }
  // If another process has already created the table, attempting to create
  // it will throw an exception. In this case just catch the exception and do
  // nothing.
  catch (SchemaObjectExistsException $e) {
    return TRUE;
  }
  return FALSE;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.