Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Patch.

longwave’s picture

Status: Needs review » Needs work
+++ b/core/includes/database.inc
@@ -649,6 +649,7 @@ function db_field_names($fields) {
+  @trigger_error('db_index_exists() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call indexExists() on it. For example, $injected_database->schema()->indexExists(($table, $name)). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);

Double set of brackets in indexExists(($table, $name)) looks wrong.

+++ b/core/modules/system/tests/src/Functional/Entity/Update/SqlContentEntityStorageSchemaIndexTest.php
@@ -25,19 +25,21 @@ protected function setDatabaseDumpFiles() {
+    $connection = \Drupal::database();

We use ->schema() several times (and nothing else from this object) so why not just get that once here?

mondrake’s picture

voleger’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/tests/src/Functional/Entity/Update/SqlContentEntityStorageSchemaIndexTest.php
@@ -25,19 +25,21 @@ protected function setDatabaseDumpFiles() {
+    $schema = \Drupal::database()->schema();

+++ b/core/modules/system/tests/src/Functional/Update/UpdateSchemaTest.php
@@ -44,9 +44,11 @@ protected function setUp() {
+    $connection = \Drupal::database();

+++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php
@@ -75,11 +75,13 @@ public function testDatabaseLoaded() {
+    $connection = \Drupal::database();

\Drupal::database() in OO code used usually only in static methods. #2991337: Document the recommended ways to obtain the database connection object
I guess we should use Database::getConnection() instead.

mondrake’s picture

Status: Needs work » Needs review
FileSize
9.42 KB
2.73 KB

Oh yes. Thank you!

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Looking good.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: 2999588-6.patch, failed testing. View results

mondrake’s picture

This may work better :)

andypost’s picture

queued swqlite & pgsql

+++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php
@@ -75,11 +76,13 @@ public function testDatabaseLoaded() {
-    $select = \Drupal::database()->select('watchdog');
+    $select = $connection->select('watchdog');

That will make other patches to reroll

longwave’s picture

Status: Needs review » Reviewed & tested by the community

#9 is indeed better ;)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 5e582a6 and pushed to 8.7.x. Thanks!

  • catch committed 5e582a6 on 8.7.x
    Issue #2999588 by mondrake, longwave, voleger: Properly deprecate...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.