TYPO3 CMS  TYPO3_7-6
MigrateShortcutUrlsAgainUpdate.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $title = 'Migrate backend shortcut urls';
26 
33  public function checkForUpdate(&$description)
34  {
35  $shortcutsCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', 'sys_be_shortcuts');
36  if ($this->isWizardDone() || $shortcutsCount === 0) {
37  return false;
38  }
39 
40  $description = 'Migrate old shortcut urls to the new module urls.';
41 
42  return true;
43  }
44 
52  public function performUpdate(array &$databaseQueries, &$customMessages)
53  {
54  $db = $this->getDatabaseConnection();
55  $shortcuts = $db->exec_SELECTgetRows('uid,url', 'sys_be_shortcuts', '1=1');
56  if (!empty($shortcuts)) {
57  foreach ($shortcuts as $shortcut) {
58  $decodedUrl = urldecode($shortcut['url']);
59  $encodedUrl = str_replace(
60  [
61  '/typo3/sysext/cms/layout/db_layout.php?&',
62  '/typo3/sysext/cms/layout/db_layout.php?',
63  '/typo3/file_edit.php?&',
64  // From 7.2 to 7.4
65  'mod.php',
66  ],
67  [
68  '/typo3/index.php?&M=web_layout&',
69  urlencode('/typo3/index.php?&M=web_layout&'),
70  '/typo3/index.php?&M=file_edit&',
71  // From 7.2 to 7.4
72  'index.php',
73  ],
74  $decodedUrl
75  );
76 
77  $db->exec_UPDATEquery(
78  'sys_be_shortcuts',
79  'uid=' . (int)$shortcut['uid'],
80  [
81  'url' => $encodedUrl,
82  ]
83  );
84  $databaseQueries[] = $db->debug_lastBuiltQuery;
85  }
86  }
87 
88  $this->markWizardAsDone();
89  return true;
90  }
91 }