You are here

protected function Tasks::checkEncoding in Drupal driver for SQL Server and SQL Azure 8.2

Same name and namespace in other branches
  1. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Install/Tasks.php \Drupal\Driver\Database\sqlsrv\Install\Tasks::checkEncoding()
  2. 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Install/Tasks.php \Drupal\Driver\Database\sqlsrv\Install\Tasks::checkEncoding()

Check encoding is UTF8.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Install/Tasks.php, line 125
Definition of Drupal\Driver\Database\sqlsrv\Tasks

Class

Tasks
Specifies installation tasks for PostgreSQL databases.

Namespace

Drupal\Driver\Database\sqlsrv\Install

Code

protected function checkEncoding() {
  try {

    /** @var \Drupal\Driver\Database\sqlsrv\Connection */
    $connection = Database::getConnection();
    $collation = $connection
      ->Scheme()
      ->getCollation($connection
      ->getDatabaseName(), $connection
      ->schema()->defaultSchema);
    if ($collation == Schema::DEFAULT_COLLATION_CI || stristr($collation, '_CI') !== false) {
      $this
        ->pass(t('Database is encoded in case insensitive collation: $collation'));
    }
    else {
      $this
        ->fail(t('The %driver database must use case insensitive encoding (recomended %encoding) to work with Drupal. Recreate the database with %encoding encoding. See !link for more details.', array(
        '%encoding' => Schema::DEFAULT_COLLATION_CI,
        '%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'));
  }
}