DatabaseCacheTagsChecksum::ensureTableExists

protected DatabaseCacheTagsChecksum::ensureTableExists()

Check if the cache tags table exists and create it if not.

File

core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php, line 144

Class

DatabaseCacheTagsChecksum
Cache tags invalidations checksum implementation that uses the database.

Namespace

Drupal\Core\Cache

Code

protected function ensureTableExists() {
  try {
    $database_schema = $this->connection->schema();
    // Create the cache tags table if it does not exist.
    if (!$database_schema->tableExists('cachetags')) {
      $schema_definition = $this->schemaDefinition();
      $database_schema->createTable('cachetags', $schema_definition);

      return TRUE;
    }
  }
  // If another process has already created the cachetags table, attempting to
  // recreate it will throw an exception. In this case just catch the
  // exception and do nothing.
  catch (SchemaObjectExistsException $e) {
    return TRUE;
  }
  return FALSE;
}
doc_Drupal
2016-10-29 08:59:43
Comments
Leave a Comment

Please login to continue.