diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 771c8e4847..d8d35902c7 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -594,7 +594,7 @@ public function query($query, array $args = [], $options = []) { // Use default values if not already set. $options += $this->defaultOptions(); if (isset($options['target'])) { - @trigger_error('Passing a \'target\' key to Connection::query $options is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Instead, get the target connection via Database::getConnection() passing the target in input and execute query() on it. See xxxx', E_USER_DEPRECATED); + @trigger_error('Passing a \'target\' key to Connection::query $options argument is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Instead, get the target connection via Database::getConnection() passing the target in input and execute query() on it. See xxxx'), E_USER_DEPRECATED); } try { diff --git a/core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php b/core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php index 1724f1475d..e340513639 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php @@ -427,6 +427,15 @@ public function testDbTruncate() { $this->assertInstanceOf(Truncate::class, db_truncate('test')); } + /** + * Tests deprecation of the $options 'target' key in Connection::query. + * + * @expectedDeprecation Passing a 'target' key to Connection::query $options argument is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Instead, get the target connection via Database::getConnection() passing the target in input and execute query() on it. See xxxx + */ + public function testDbQueryTemporary() { + $this->assertNotNull($this->connection->query('SELECT * FROM {test}', [], ['target' => 'bar'])); + } + /** * Tests deprecation of the db_query_temporary() function. *