Skip to content
Snippets Groups Projects
Commit 5730ee6d authored by catch's avatar catch
Browse files

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
No related branches found
No related tags found
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -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']);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment