From e8073004ed72a4b831157c7e978effd32669de17 Mon Sep 17 00:00:00 2001
From: Dave Long <dave@longwaveconsulting.com>
Date: Sat, 22 Jul 2023 11:46:24 +0200
Subject: [PATCH] Issue #3375919 by mondrake, daffie: Deprecate usage of
 Connection::getDriverClass for 'Install\Tasks'

---
 core/lib/Drupal/Core/Database/Connection.php             | 1 +
 core/modules/system/system.install                       | 2 +-
 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index 5b2a8dff0e5f..39a856e966eb 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -900,6 +900,7 @@ protected function expandArguments(&$query, &$args) {
    */
   public function getDriverClass($class) {
     match($class) {
+      'Install\\Tasks',
       'ExceptionHandler',
       'Select',
       'Insert',
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 7cd9079266f3..027a6ab90360 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -555,7 +555,7 @@ function system_requirements($phase) {
 
   if ($phase === 'runtime' || $phase === 'update') {
     // Database information.
-    $class = Database::getConnection()->getDriverClass('Install\\Tasks');
+    $class = Database::getConnection()->getConnectionOptions()['namespace'] . '\\Install\\Tasks';
     /** @var \Drupal\Core\Database\Install\Tasks $tasks */
     $tasks = new $class();
     $requirements['database_system'] = [
diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
index e48d3aa5f612..28670b717533 100644
--- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
@@ -326,6 +326,7 @@ public function testGetDriverClass($expected, $namespace, $class) {
     $mock_pdo = $this->createMock('Drupal\Tests\Core\Database\Stub\StubPDO');
     $connection = new StubConnection($mock_pdo, ['namespace' => $namespace]);
     match($class) {
+      'Install\\Tasks',
       'ExceptionHandler',
       'Select',
       'Insert',
-- 
GitLab