Commit 1a9bc67d authored by Christian Kuhn's avatar Christian Kuhn Committed by Benni Mack
Browse files

[BUGFIX] Install tool database row updater works with mssql

SqlServer can not handle a transaction for a table, if the
same table is queried currently. The install tool database
row updater does this. Solution is to skip the transaction
on this platform. Additionally, an update query is fixed
to hint for proper field types.

Resolves: #92832
Releases: master, 10.4
Change-Id: I5fc76705088a727dc1ff41410d6e2cd02b3d9655
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/66622


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent e859ce49
......@@ -17,6 +17,7 @@ declare(strict_types=1);
namespace TYPO3\CMS\Install\Updates;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Registry;
......@@ -226,8 +227,10 @@ class DatabaseRowsUpdateWizard implements UpgradeWizardInterface, RepeatableInte
'table' => $table,
'uid' => $rowBefore['uid'],
];
if ($connectionForSysRegistry === $connectionForTable) {
// Target table and sys_registry table are on the same connection, use a transaction
if ($connectionForSysRegistry === $connectionForTable
&& !($connectionForSysRegistry->getDatabasePlatform() instanceof SQLServerPlatform)
) {
// Target table and sys_registry table are on the same connection and not mssql, use a transaction
$connectionForTable->beginTransaction();
try {
$this->updateOrDeleteRow(
......@@ -244,8 +247,10 @@ class DatabaseRowsUpdateWizard implements UpgradeWizardInterface, RepeatableInte
throw $up;
}
} else {
// Different connections for table and sys_registry -> execute two
// distinct queries and hope for the best.
// Either different connections for table and sys_registry, or mssql.
// SqlServer can not run a transaction for a table if the same table is queried
// currently - our above ->fetch() main loop.
// So, execute two distinct queries and hope for the best.
$this->updateOrDeleteRow(
$connectionForTable,
$connectionForSysRegistry,
......@@ -349,6 +354,12 @@ class DatabaseRowsUpdateWizard implements UpgradeWizardInterface, RepeatableInte
[
'entry_namespace' => 'installUpdateRows',
'entry_key' => 'rowUpdatePosition',
],
[
// Needs to be declared LOB, so MSSQL can handle the conversion from string (nvarchar) to blob (varbinary)
'entry_value' => \PDO::PARAM_LOB,
'entry_namespace' => \PDO::PARAM_STR,
'entry_key' => \PDO::PARAM_STR,
]
);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment