From da29e38fd335d3cc3ff1c74254580227d652ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Sun, 19 Dec 2021 20:21:24 +0100
Subject: [PATCH] [TASK] Avoid deprecated doctrine/dbal method
 'executeUpdate()'

doctrine/dbal deprecated quite some methods to cleanup
their codebase and provided replacements with more
speaking method names.

Most depcrecated method usages have been replaced in
the core, but we missed some.

The patch replaces the depcrecated method 'executeUpdate()'
with the corresponding 'executeStatement()' method in
several places to cleanup this up.

This can be done also in 11.5 too, the required minimum
version of doctrine/dbal provides these new methods as
upwards compatible layer.

Resolves: #96389
Releases: main, 11.5
Change-Id: Ibf8f49a27a1c8c4b34bda88a20f4fba6afe45cb8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72710
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 typo3/sysext/core/Classes/Database/Connection.php             | 2 +-
 typo3/sysext/core/Classes/Database/Query/BulkInsertQuery.php  | 2 +-
 .../core/Classes/Database/Schema/ConnectionMigrator.php       | 2 +-
 typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php  | 2 +-
 .../Tests/Functional/Database/Schema/SchemaMigratorTest.php   | 2 +-
 typo3/sysext/core/Tests/Unit/Database/ConnectionTest.php      | 4 ++--
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/typo3/sysext/core/Classes/Database/Connection.php b/typo3/sysext/core/Classes/Database/Connection.php
index 27f4af430ca9..7e70c6b812d8 100644
--- a/typo3/sysext/core/Classes/Database/Connection.php
+++ b/typo3/sysext/core/Classes/Database/Connection.php
@@ -335,7 +335,7 @@ class Connection extends \Doctrine\DBAL\Connection implements LoggerAwareInterfa
      */
     public function truncate(string $tableName, bool $cascade = false): int
     {
-        return $this->executeUpdate(
+        return $this->executeStatement(
             $this->getDatabasePlatform()->getTruncateTableSQL(
                 $this->quoteIdentifier($tableName),
                 $cascade
diff --git a/typo3/sysext/core/Classes/Database/Query/BulkInsertQuery.php b/typo3/sysext/core/Classes/Database/Query/BulkInsertQuery.php
index e6a8651a17c1..af689e65b9bd 100644
--- a/typo3/sysext/core/Classes/Database/Query/BulkInsertQuery.php
+++ b/typo3/sysext/core/Classes/Database/Query/BulkInsertQuery.php
@@ -200,7 +200,7 @@ class BulkInsertQuery
             );
         }
 
-        return $this->connection->executeUpdate($this->getSQL(), $this->parameters, $this->types);
+        return $this->connection->executeStatement($this->getSQL(), $this->parameters, $this->types);
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php b/typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php
index 20ba6f5b9b2d..15e560e07bcc 100644
--- a/typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php
+++ b/typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php
@@ -190,7 +190,7 @@ class ConnectionMigrator
 
         foreach ($statements as $statement) {
             try {
-                $this->connection->executeUpdate($statement);
+                $this->connection->executeStatement($statement);
                 $result[$statement] = '';
             } catch (DBALException $e) {
                 $result[$statement] = $e->getPrevious()->getMessage();
diff --git a/typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php b/typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php
index 5c404e4a399b..b991842de49d 100644
--- a/typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php
+++ b/typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php
@@ -217,7 +217,7 @@ class SchemaMigrator
 
             foreach ((array)$perTableStatements as $statement) {
                 try {
-                    $connection->executeUpdate($statement);
+                    $connection->executeStatement($statement);
                     $result[$statement] = '';
                 } catch (DBALException $e) {
                     $result[$statement] = $e->getPrevious()->getMessage();
diff --git a/typo3/sysext/core/Tests/Functional/Database/Schema/SchemaMigratorTest.php b/typo3/sysext/core/Tests/Functional/Database/Schema/SchemaMigratorTest.php
index 684178d54fcf..e280cff0a973 100644
--- a/typo3/sysext/core/Tests/Functional/Database/Schema/SchemaMigratorTest.php
+++ b/typo3/sysext/core/Tests/Functional/Database/Schema/SchemaMigratorTest.php
@@ -253,7 +253,7 @@ class SchemaMigratorTest extends FunctionalTestCase
             $toSchema,
             $connection->getDatabasePlatform()
         );
-        $connection->executeUpdate($statements[0]);
+        $connection->executeStatement($statements[0]);
         self::assertTrue($this->getTableDetails()->hasColumn('zzz_deleted_testfield'));
 
         $statements = $this->readFixtureFile('newTable');
diff --git a/typo3/sysext/core/Tests/Unit/Database/ConnectionTest.php b/typo3/sysext/core/Tests/Unit/Database/ConnectionTest.php
index 6ce6f495b4b3..411fd178b05a 100644
--- a/typo3/sysext/core/Tests/Unit/Database/ConnectionTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/ConnectionTest.php
@@ -237,7 +237,7 @@ class ConnectionTest extends UnitTestCase
     public function bulkInsert(): void
     {
         $this->connection->expects(self::once())
-            ->method('executeUpdate')
+            ->method('executeStatement')
             ->with('INSERT INTO "aTestTable" ("aField") VALUES (?), (?)', ['aValue', 'anotherValue'])
             ->willReturn(2);
 
@@ -504,7 +504,7 @@ class ConnectionTest extends UnitTestCase
     public function truncateQuery(): void
     {
         $this->connection->expects(self::once())
-            ->method('executeUpdate')
+            ->method('executeStatement')
             ->with('TRUNCATE "aTestTable"')
             ->willReturn(0);
 
-- 
GitLab