Commit 5730ee6d authored by catch's avatar catch

Issue #3123461 by daffie, Kristen Pol, alexpott, xjm: Deprecate support for...

Issue #3123461 by daffie, Kristen Pol, alexpott, xjm: Deprecate support for database drivers placed in DRUPAL_ROOT/drivers
parent 661d8a83
......@@ -214,6 +214,7 @@ public function __construct(\PDO $connection, array $connection_options) {
@trigger_error('In drupal:10.0.0 not setting the $identifierQuotes property in the concrete Connection class will result in an RuntimeException. See https://www.drupal.org/node/2986894', E_USER_DEPRECATED);
$this->identifierQuotes = ['', ''];
}
assert(count($this->identifierQuotes) === 2 && Inspector::assertAllStrings($this->identifierQuotes), '\Drupal\Core\Database\Connection::$identifierQuotes must contain 2 string values');
// The 'transactions' option is deprecated.
if (isset($connection_options['transactions'])) {
......@@ -228,6 +229,12 @@ public function __construct(\PDO $connection, array $connection_options) {
$connection_options['namespace'] = (new \ReflectionObject($this))->getNamespaceName();
}
// The support for database drivers where the namespace that starts with
// Drupal\\Driver\\Database\\ is deprecated.
if (strpos($connection_options['namespace'], 'Drupal\Driver\Database') === 0) {
@trigger_error('Support for database drivers located in the "drivers/lib/Drupal/Driver/Database" directory is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Contributed and custom database drivers should be provided by modules and use the namespace "Drupal\MODULE_NAME\Driver\Database\DRIVER_NAME". See https://www.drupal.org/node/3123251', E_USER_DEPRECATED);
}
// Initialize and prepare the connection prefix.
$this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : '');
......
......@@ -187,7 +187,7 @@ public function testContribCondition() {
->setConstructorArgs([NULL])
->disableOriginalConstructor()
->getMock();
$contrib_namespace = 'Drupal\Driver\Database\mock';
$contrib_namespace = 'Drupal\mock\Driver\Database\mock';
$mocked_namespace = $contrib_namespace . '\\Condition';
class_alias('MockCondition', $mocked_namespace);
......
......@@ -668,7 +668,20 @@ public function provideQueriesToTrim() {
'SELECT * FROM test; ',
['allow_delimiter_in_query' => TRUE],
],
];
];
}
/**
* Tests the deprecation of Drupal 8 style database drivers.
*
* @group legacy
* @expectedDeprecation Support for database drivers located in the "drivers/lib/Drupal/Driver/Database" directory is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Contributed and custom database drivers should be provided by modules and use the namespace "Drupal\MODULE_NAME\Driver\Database\DRIVER_NAME". See https://www.drupal.org/node/3123251
*/
public function testLegacyDatabaseDriverInRootDriversDirectory() {
$namespace = 'Drupal\\Driver\\Database\\Stub';
$mock_pdo = $this->createMock(StubPDO::class);
$connection = new StubConnection($mock_pdo, ['namespace' => $namespace], ['"', '"']);
$this->assertEquals($namespace, $connection->getConnectionOptions()['namespace']);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment