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.
Problem/Motivation
#3112476: Always set $info['namespace'] on database connection info results in \Drupal\Core\Database\Database::getDatabaseDriverNamespace not being needed. Let's deprecate it for removal in D10.
Also we should deprecate calling \Drupal\Core\Database\Connection::__construct() without a 'namespace' key in the $connection_options array. Which will allow us to simplify \Drupal\Core\Database\Connection::getDriverClass and remove the override in \Drupal\database_statement_monitoring_test\LoggedStatementsTrait
Proposed resolution
Do it.
Remaining tasks
User interface changes
None
API changes
\Drupal\Core\Database\Database::getDatabaseDriverNamespace is deprecated.
Data model changes
None
Release notes snippet
N/a
Comment | File | Size | Author |
---|---|---|---|
#20 | interdiff-19-20-3115388.txt | 1.96 KB | salah1 |
#20 | 3115388-20-deprecate-getDatabaseDriverNamespace.patch | 6.37 KB | salah1 |
#19 | interdiff-16-19-3115388.txt | 2.67 KB | salah1 |
#19 | 3115388-19-deprecate-getDatabaseDriverNamespace.patch | 4.72 KB | salah1 |
#16 | 3115388-16-deprecate-getDatabaseDriverNamespace.patch | 2.05 KB | salah1 |
Comments
Comment #2
alexpottComment #3
salah1Here is patch to deprecate the method \Drupal\Core\Database\Database::getDatabaseDriverNamespace.
Thanks for reviewing it.
Comment #4
alexpottThanks for working on this patch.
This should actually remove the usages.
We're trying to only add new deprecations in 9.1.0. This needs point to a change record (see link in the sidebar).
Comment #5
salah1So, you mean on 1) remove that part as it relates to usage and 2) add the change record link instead of the issue link?
Comment #6
salah1Made the changes in #4(atleast the way i understood it).
Let me know if we need to tweak it more.
Thanks
Comment #7
alexpottHere we actually need to remove the calls to the method as we've deprecated it.
Comment #8
salah1Correcting some quote issues caused the error in #3.
Comment #9
salah1@Alexpott, thanks for the review. Does this patch take care of the changes in #7?
Patch assumes
$info['namespace']
is set already.if
$info['namespace'])
is not set already, i can put in check like the following?Comment #10
alexpottThis should be
$driver_class = self::$databaseInfo[$key][$target]['namespace'] . '\\Connnection';
. There no need to assign a namespace var any more.This should be...
$connection_class = $db_info['default']['namespace'] . '\\Connection';
Note that since #3112476: Always set $info['namespace'] on database connection info you don't need to check for the existence of the array key - that was the point of that change.
Comment #11
neelam_wadhwani CreditAttribution: neelam_wadhwani at Valuebound for Valuebound commentedHello @alexpott
Done changes as asked for.
Kindly review patch.
Comment #12
neelam_wadhwani CreditAttribution: neelam_wadhwani at Valuebound for Valuebound commentedComment #13
alexpottNote that before we can actually do this issue we need to do #3112476: Always set $info['namespace'] on database connection info first. This is a follow-up to that one. Reviews of that issue would be appreciated.
Too many N's.
We still need to deprecate the method as is done in #9.
Comment #14
salah1@neelam_wadhwani,
Thanks for helping.
I was working on this and it was assigned to me :)
Community guide says, “avoid issues being worked on and assigned to others”.
https://www.drupal.org/node/1319140
[under assign the issue...]
I only raise this because it’s better etiquette and not to duplicate work.
And it happened to me before.
Thanks for making this good experience for all.
Comment #15
salah1Will work on this.
Comment #16
salah1This should take care of the changes raised on #10.
I reviewed the related issue and understand context.
Just wanted to load this patch so when the issue is active again, it can move forward.
Comment #17
alexpottAdded some more tasks to the issue summary.
Comment #18
salah1Leaving this un-assigned so anybody with time can jump on it.
Comment #19
salah1Of the remaining tasks below, i crossed out the done parts.
This patch, includes few fixes for coding standards in (/core/lib/Drupal/Core/Database/Connection.php)
Comment #20
salah1This patch should take care of ALL the added tasks as well.
It ncludes few fixes for coding standards in (/core/lib/Drupal/Core/Database/Connection.php)
Comment #21
alexpottAs 9.1.x is now open we're doing this in #3112476: Always set $info['namespace'] on database connection info