Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
CreditAttribution: longwave as a volunteer commented
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.
Comments
Comment #2
mondrakePatch.
Comment #3
longwaveDouble set of brackets in
indexExists(($table, $name))
looks wrong.We use
->schema()
several times (and nothing else from this object) so why not just get that once here?Comment #4
mondrakeThanks for review! Here we go.
Comment #5
voleger\Drupal::database()
in OO code used usually only in static methods. #2991337: Document the recommended ways to obtain the database connection objectI guess we should use
Database::getConnection()
instead.Comment #6
mondrakeOh yes. Thank you!
Comment #7
longwaveLooking good.
Comment #9
mondrakeThis may work better :)
Comment #10
andypostqueued swqlite & pgsql
That will make other patches to reroll
Comment #11
longwave#9 is indeed better ;)
Comment #12
catchCommitted 5e582a6 and pushed to 8.7.x. Thanks!