[BUGFIX] RTEmagic upgrade wizard fails and uses wrong directory 60/20560/4
authorStefan Galinski <stefan.galinski@gmail.com>
Mon, 6 May 2013 20:29:36 +0000 (22:29 +0200)
committerStefan Galinski <stefan.galinski@gmail.com>
Fri, 5 Jul 2013 09:58:45 +0000 (11:58 +0200)
The RTE upgrade wizard fails, because it uses a
non-existing field name as the table and writes wrong
image paths back into the RTE content. Also the migration
directory should equal the already available migration
directory of the FAL upgrade wizards.

You can test the issue by adding an image to a
RTE field in a 4.7 instance and try to migrate to 6.1
afterwards.

Fixes: #47998
Releases: 6.2, 6.1
Change-Id: Ie6d3947f475e80ac36eb5ba43f258b5215e19928
Reviewed-on: https://review.typo3.org/20560
Reviewed-by: Francois Suter
Tested-by: Francois Suter
Reviewed-by: Alexander Opitz
Reviewed-by: Ingo Pfennigstorf
Reviewed-by: Marcus Schwemer
Tested-by: Marcus Schwemer
Reviewed-by: Stefan Galinski
Tested-by: Stefan Galinski
typo3/sysext/install/Classes/Updates/RteMagicImagesUpdateWizard.php

index 555bd9b..5dae7dc 100644 (file)
@@ -25,7 +25,7 @@ namespace TYPO3\CMS\Install\Updates;
  ***************************************************************/
 /**
  * Upgrade wizard that moves all RTE magic images (usually in uploads/)
- * that have the prefix RTEmagicC_* to the default storage (usually fileadmin/_migrated_/RTE/)
+ * that have the prefix RTEmagicC_* to the default storage (usually fileadmin/_migrated/RTE/)
  * and also updates the according fields (e.g. tt_content:123:bodytext) with the new string, and updates
  * the softreference index
  *
@@ -38,7 +38,7 @@ class RteMagicImagesUpdateWizard extends \TYPO3\CMS\Install\Updates\AbstractUpda
         * title of the update wizard
         * @var string
         */
-       protected $title = 'Migrate all RTE magic images from uploads/RTEmagicC_* to fileadmin/_migrated_/RTE/';
+       protected $title = 'Migrate all RTE magic images from uploads/RTEmagicC_* to fileadmin/_migrated/RTE/';
 
        /**
         * the default storage
@@ -87,7 +87,7 @@ class RteMagicImagesUpdateWizard extends \TYPO3\CMS\Install\Updates\AbstractUpda
         * @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/.<br />It also moves the files from uploads/ to the fileadmin/_migrated/ path.';
+               $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/.<br />It also moves the files from uploads/ to the fileadmin/_migrated/ path.';
 
                // wizard is only available if oldPrefix set
                if ($this->oldPrefix) {
@@ -117,7 +117,7 @@ class RteMagicImagesUpdateWizard extends \TYPO3\CMS\Install\Updates\AbstractUpda
                }
 
                $fileadminDirectory = rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/');
-               $targetDirectory = '/_migrated_/RTE/';
+               $targetDirectory = '/_migrated/RTE/';
                $fullTargetDirectory = PATH_site . $fileadminDirectory . $targetDirectory;
 
                // create the directory, if necessary
@@ -144,7 +144,7 @@ class RteMagicImagesUpdateWizard extends \TYPO3\CMS\Install\Updates\AbstractUpda
 
                                $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'], $row['recuid'], $row['field']),
+                                       sprintf($format, $sourceFileName, $refRecord['tablename'], $refRecord['recuid'], $refRecord['field']),
                                        '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
                                );
                                /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $message */
@@ -160,12 +160,12 @@ class RteMagicImagesUpdateWizard extends \TYPO3\CMS\Install\Updates\AbstractUpda
                        if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
                                // and now update the referencing field
                                $targetFieldName = $refRecord['field'];
-                               $targetRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid, ' . $targetFieldName, $refRecord['table'], 'uid=' . intval($refRecord['recuid']));
+                               $targetRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid, ' . $targetFieldName, $refRecord['tablename'], 'uid=' . intval($refRecord['recuid']));
                                if ($targetRecord) {
                                        // replace the old filename with the new one, and update the according record
-                                       $targetRecord[$targetFieldName] = str_replace($sourceFileName, $targetFileName, $targetRecord[$targetFieldName]);
+                                       $targetRecord[$targetFieldName] = str_replace($sourceFileName, $fileadminDirectory . $targetFileName, $targetRecord[$targetFieldName]);
                                        $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
-                                               $refRecord['table'],
+                                               $refRecord['tablename'],
                                                'uid=' . intval($refRecord['recuid']),
                                                array($targetFieldName => $targetRecord[$targetFieldName])
                                        );