You are here

protected function Tasks::checkEncoding in Drupal driver for SQL Server and SQL Azure 3.1.x

Same name and namespace in other branches
  1. 4.2.x src/Driver/Database/sqlsrv/Install/Tasks.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Install\Tasks::checkEncoding()
  2. 4.0.x src/Driver/Database/sqlsrv/Install/Tasks.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Install\Tasks::checkEncoding()
  3. 4.1.x src/Driver/Database/sqlsrv/Install/Tasks.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Install\Tasks::checkEncoding()

Check encoding is UTF8.

File

src/Driver/Database/sqlsrv/Install/Tasks.php, line 121

Class

Tasks
Specifies installation tasks for PostgreSQL databases.

Namespace

Drupal\sqlsrv\Driver\Database\sqlsrv\Install

Code

protected function checkEncoding() {
  try {
    $database = Database::getConnection();

    /** @var \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema $schema */
    $schema = $database
      ->schema();
    $collation = $schema
      ->getCollation();
    if (stristr($collation, '_CI_') !== FALSE) {
      $this
        ->pass(t('Database is encoded in case insensitive collation: $collation'));
    }
    else {
      $this
        ->fail(t('The %driver database is using %current collation, but must use case insensitive collation to work with Drupal. Recreate the database with this collation. See !link for more details.', [
        '%current' => $collation,
        '%driver' => $this
          ->name(),
        ':link' => '<a href="INSTALL.sqlsrv.txt">INSTALL.sqlsrv.txt</a>',
      ]));
    }
  } catch (\Exception $e) {
    $this
      ->fail(t('Drupal could not determine the encoding of the database was set to UTF-8'));
  }
}