[CLEANUP] Enhance RTE Magic Image FAL migration wizard 22/25622/2
authorBenjamin Mack <benni@typo3.org>
Thu, 21 Nov 2013 18:27:54 +0000 (19:27 +0100)
committerErnesto Baschny <ernst@cron-it.de>
Tue, 4 Mar 2014 16:42:18 +0000 (17:42 +0100)
If the RTE magic images FAL migration upgrade wizard in the
install tool ever fails (due to max_execution_time) or some
SQL error, then the migration stops and can be run again.

However, if the wizard is run again, it always checks
if the source file still exists. The wizard should rather
check if the target file exists, if not, move the source file
to the target file.

As a separate "step" in this wizard, if the target file (already)
exists, then the DB change can be done.

Additionally, a typo for the output is fixed as well.

Resolves: #53846
Releases: 6.2
Change-Id: Id7c3b6176997848210d83c54cd133819ab15f435
Reviewed-on: https://review.typo3.org/25622
Reviewed-by: Wouter Wolters
Reviewed-by: Tom Ruether
Tested-by: Tom Ruether
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
typo3/sysext/install/Classes/Updates/RteMagicImagesUpdateWizard.php

index 3c92c55..16eb38c 100644 (file)
@@ -90,7 +90,7 @@ class RteMagicImagesUpdateWizard extends AbstractUpdate {
         * @return boolean TRUE if an update is needed, FALSE otherwise
         */
        public function checkForUpdate(&$description) {
-               $description = 'This update wizard goes through all magic images, located in ' . \TYPO3\CMS\Core\Utility\PathUtility::dirname($this->oldPrefix) . '., and moves the files to fileadmin/_migrated/RTE/.';
+               $description = 'This update wizard goes through all magic images, located in "' . htmlspecialchars($this->oldPrefix) . '", and moves the files to fileadmin/_migrated/RTE/.';
                $description .= '<br />It also moves the files from uploads/ to the fileadmin/_migrated/ path.';
                // Issue warning about sys_refindex needing to be up to date
                /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $message */
@@ -150,24 +150,27 @@ class RteMagicImagesUpdateWizard extends AbstractUpdate {
                        // Full directory
                        $fullTargetFileName = $fullTargetDirectory . \TYPO3\CMS\Core\Utility\PathUtility::basename($refRecord['ref_string']);
 
-                       // If the source file does not exist, we should just continue, but leave a message in the docs;
-                       // ideally, the user would be informed after the update as well.
-                       if (!file_exists(PATH_site . $sourceFileName)) {
-                               $this->logger->notice('File ' . $sourceFileName . ' does not exist. Reference was not migrated.', array());
+                       // maybe the file has been moved previously
+                       if (!file_exists($fullTargetFileName)) {
+                               // If the source file does not exist, we should just continue, but leave a message in the docs;
+                               // ideally, the user would be informed after the update as well.
+                               if (!file_exists(PATH_site . $sourceFileName)) {
+                                       $this->logger->notice('File ' . $sourceFileName . ' does not exist. Reference was not migrated.', array());
+
+                                       $format = 'File \'%s\' does not exist. Referencing field: %s.%d.%s. The reference was not migrated.';
+                                       $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\TYPO3\CMS\Core\Messaging\FlashMessage',
+                                               sprintf($format, $sourceFileName, $refRecord['tablename'], $refRecord['recuid'], $refRecord['field']),
+                                               '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
+                                       );
+                                       /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $message */
+                                       $customMessages .= '<br />' . $message->render();
 
-                               $format = 'File \'%s\' does not exist. Referencing field: %s.%d.%s. The reference was not migrated.';
-                               $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\TYPO3\CMS\Core\Messaging\FlashMessage',
-                                       sprintf($format, $sourceFileName, $refRecord['tablename'], $refRecord['recuid'], $refRecord['field']),
-                                       '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
-                               );
-                               /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $message */
-                               $customMessages .= '<br />' . $message->render();
+                                       continue;
+                               }
 
-                               continue;
+                               rename($fullSourceFileName, $fullTargetFileName);
                        }
 
-                       rename($fullSourceFileName, $fullTargetFileName);
-
                        // Get the File object
                        $file = $this->storage->getFile($targetFileName);
                        if ($file instanceof \TYPO3\CMS\Core\Resource\File) {