Skip to content
Snippets Groups Projects
Commit cff4c3c2 authored by tobiasadolph's avatar tobiasadolph Committed by Benni Mack
Browse files

[TASK] Doctrine: Migrate MigrateShortcutUrlsAgainUpdate

Resolves: #77483
Releases: master
Change-Id: Ib7eb6d27c4fa5d6fc7946806e98fdd86ed02aef0
Reviewed-on: https://review.typo3.org/49454


Tested-by: default avatarBamboo TYPO3com <info@typo3.com>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
parent 36cb9b04
Branches
Tags
No related merge requests found
...@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Install\Updates; ...@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Install\Updates;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/** /**
* Migrate backend shortcut urls * Migrate backend shortcut urls
*/ */
...@@ -32,14 +35,16 @@ class MigrateShortcutUrlsAgainUpdate extends AbstractUpdate ...@@ -32,14 +35,16 @@ class MigrateShortcutUrlsAgainUpdate extends AbstractUpdate
*/ */
public function checkForUpdate(&$description) public function checkForUpdate(&$description)
{ {
$shortcutsCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', 'sys_be_shortcuts'); if ($this->isWizardDone()) {
if ($this->isWizardDone() || $shortcutsCount === 0) {
return false; return false;
} }
$shortcutsCount = GeneralUtility::makeInstance(ConnectionPool::class)
$description = 'Migrate old shortcut urls to the new module urls.'; ->getConnectionForTable('sys_be_shortcuts')
->count('uid', 'sys_be_shortcuts', []);
return true; if ($shortcutsCount > 0) {
$description = 'Migrate old shortcut urls to the new module urls.';
}
return (bool)$shortcutsCount;
} }
/** /**
...@@ -51,40 +56,34 @@ class MigrateShortcutUrlsAgainUpdate extends AbstractUpdate ...@@ -51,40 +56,34 @@ class MigrateShortcutUrlsAgainUpdate extends AbstractUpdate
*/ */
public function performUpdate(array &$databaseQueries, &$customMessages) public function performUpdate(array &$databaseQueries, &$customMessages)
{ {
$db = $this->getDatabaseConnection(); $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_be_shortcuts');
$shortcuts = $db->exec_SELECTgetRows('uid,url', 'sys_be_shortcuts', '1=1'); $statement = $connection->select(['uid', 'url'], 'sys_be_shortcuts', []);
if (!empty($shortcuts)) { while ($shortcut = $statement->fetch()) {
foreach ($shortcuts as $shortcut) { $decodedUrl = urldecode($shortcut['url']);
$decodedUrl = urldecode($shortcut['url']); $encodedUrl = str_replace(
$encodedUrl = str_replace( [
array( '/typo3/sysext/cms/layout/db_layout.php?&',
'/typo3/sysext/cms/layout/db_layout.php?&', '/typo3/sysext/cms/layout/db_layout.php?',
'/typo3/sysext/cms/layout/db_layout.php?', '/typo3/file_edit.php?&',
'/typo3/file_edit.php?&', // From 7.2 to 7.4
// From 7.2 to 7.4 'mod.php',
'mod.php', ],
), [
array( '/typo3/index.php?&M=web_layout&',
'/typo3/index.php?&M=web_layout&', urlencode('/typo3/index.php?&M=web_layout&'),
urlencode('/typo3/index.php?&M=web_layout&'), '/typo3/index.php?&M=file_edit&',
'/typo3/index.php?&M=file_edit&', // From 7.2 to 7.4
// From 7.2 to 7.4 'index.php',
'index.php', ],
), $decodedUrl
$decodedUrl );
); $queryBuilder = $connection->createQueryBuilder();
$queryBuilder->update('sys_be_shortcuts')
$db->exec_UPDATEquery( ->set('url', $queryBuilder->quote($encodedUrl), false)
'sys_be_shortcuts', ->where($queryBuilder->expr()->eq('uid', (int)$shortcut['uid']));
'uid=' . (int)$shortcut['uid'], $databaseQueries[] = $queryBuilder->getSQL();
array( $queryBuilder->execute();
'url' => $encodedUrl,
)
);
$databaseQueries[] = $db->debug_lastBuiltQuery;
}
} }
$this->markWizardAsDone(); $this->markWizardAsDone();
return true; return true;
} }
......
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