[BUGFIX] Ensure filemount path has trailing slash after upgrade 78/40478/4
authorNicole Cordes <typo3@cordes.co>
Sat, 20 Jun 2015 09:50:56 +0000 (11:50 +0200)
committerFrans Saris <franssaris@gmail.com>
Wed, 15 Jul 2015 15:04:25 +0000 (17:04 +0200)
Currently the upgrade wizard for filemounts  doesn't ensure trailing
slashes for the paths. This results in "invalid value" messages if
an user edit filemounts and has to choose the correct path again. This
patch adds missing trailing slashes for paths.

Resolves: #67643
Releases: 6.2
Change-Id: I145a08ac5d6b6675723a73b7ec7d1bfb3ca22303
Reviewed-on: http://review.typo3.org/40478
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/install/Classes/Updates/FilemountUpdateWizard.php

index 01afe3b..b1dd41f 100644 (file)
@@ -119,7 +119,7 @@ class FilemountUpdateWizard extends AbstractUpdate {
                foreach ($absoluteFilemounts as $filemount) {
                        if (stristr($filemount['path'], $fileadminDir)) {
                                $storageId = $this->storage->getUid();
-                               $storagePath = str_replace($fileadminDir, '', $filemount['path']);
+                               $storagePath = rtrim(str_replace($fileadminDir, '', $filemount['path']), '/') . '/';
                        } else {
                                $storageId = $this->storageRepository->createLocalStorage(
                                        $filemount['title'] . ' (auto-created)',
@@ -152,10 +152,14 @@ class FilemountUpdateWizard extends AbstractUpdate {
                        'base = 1' . BackendUtility::deleteClause('sys_filemounts')
                );
                foreach ($relativeFilemounts as $filemount) {
+                       $storagePath = trim($filemount['path'], '/') . '/';
+                       if ($storagePath !== '/') {
+                               $storagePath = '/' . $storagePath;
+                       }
                        $this->db->exec_UPDATEquery(
                                'sys_filemounts',
                                'uid=' . (int)$filemount['uid'],
-                               array('base' => $this->storage->getUid(), 'path' => '/' . ltrim($filemount['path'], '/'))
+                               array('base' => $this->storage->getUid(), 'path' => $storagePath)
                        );
                        $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
                }