function Tasks::checkExtensions

Same name in other branches
  1. 10 core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php \Drupal\pgsql\Driver\Database\pgsql\Install\Tasks::checkExtensions()

Generic function to check postgresql extensions.

File

core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php, line 250

Class

Tasks
Specifies installation tasks for PostgreSQL databases.

Namespace

Drupal\pgsql\Driver\Database\pgsql\Install

Code

public function checkExtensions() {
    $connection = Database::getConnection();
    try {
        // Enable pg_trgm for PostgreSQL 13 or higher.
        $connection->query('CREATE EXTENSION IF NOT EXISTS pg_trgm');
        if ($connection->schema()
            ->extensionExists('pg_trgm')) {
            $this->pass(t('PostgreSQL has the pg_trgm extension enabled.'));
        }
        else {
            $this->fail(t('The <a href=":pg_trgm">pg_trgm</a> PostgreSQL extension is not present. The extension is required by Drupal 10 to improve performance when using PostgreSQL. See <a href=":requirements">Drupal database server requirements</a> for more information.', [
                ':pg_trgm' => 'https://www.postgresql.org/docs/current/pgtrgm.html',
                ':requirements' => 'https://www.drupal.org/docs/system-requirements/database-server-requirements',
            ]));
        }
    } catch (\Exception $e) {
        $this->fail(t('Drupal could not check for the pg_trgm extension: @error.', [
            '@error' => $e->getMessage(),
        ]));
    }
}

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