Commit 1b7265e6 authored by catch's avatar catch
Browse files

Issue #3251084 by gidarai, beatrizrodrigues, Tauany Bueno, mr.baileys, daffie,...

Issue #3251084 by gidarai, beatrizrodrigues, Tauany Bueno, mr.baileys, daffie, joachim, alexpott: The method Drupal\Core\Database\Driver\mysql\Connection::__construct() cannot be called without the second parameter being set
parent 33366362
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ public function __construct(\PDO $connection, array $connection_options) {
    // @see https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_ansi_quotes
    $ansi_quotes_modes = ['ANSI_QUOTES', 'ANSI', 'DB2', 'MAXDB', 'MSSQL', 'ORACLE', 'POSTGRESQL'];
    $is_ansi_quotes_mode = FALSE;
    if (isset($connection_options['init_commands']['sql_mode'])) {
      foreach ($ansi_quotes_modes as $mode) {
        // None of the modes in $ansi_quotes_modes are substrings of other modes
        // that are not in $ansi_quotes_modes, so a simple stripos() does not
@@ -106,6 +107,8 @@ public function __construct(\PDO $connection, array $connection_options) {
          break;
        }
      }
    }

    if ($this->identifierQuotes === ['"', '"'] && !$is_ansi_quotes_mode) {
      $this->identifierQuotes = ['`', '`'];
    }
+24 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\mysql\Kernel\mysql;

use Drupal\mysql\Driver\Database\mysql\Connection;
use Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase;
use Drupal\Tests\Core\Database\Stub\StubPDO;

/**
 * Tests the deprecations of the MySQL database driver classes in Core.
 *
 * @group Database
 */
class MysqlDriverTest extends DriverSpecificKernelTestBase {

  /**
   * @covers \Drupal\mysql\Driver\Database\mysql\Connection
   */
  public function testConnection() {
    $connection = new Connection($this->createMock(StubPDO::class), []);
    $this->assertInstanceOf(Connection::class, $connection);
  }

}