[BUGFIX] Backup of LocalConfiguration.php missing on update 80/28980/5
authorNicole Cordes <typo3@cordes.co>
Mon, 31 Mar 2014 14:01:11 +0000 (16:01 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 1 Apr 2014 18:58:25 +0000 (20:58 +0200)
If you update from a 6.x installation there should be a backup of the
old, unmodified LocalConfiguration.php as it's getting changed during
PackageStates.php extraction. This is prevented with commit e755bcd
as a check for the PackageStates.php file was introduced, which might
not be available at this point during upgrade.

Resolves: #57458
Releases: 6.2
Change-Id: Ic3634ab58e3e4112df5d8544cca9c42e8f1db91f
Reviewed-on: https://review.typo3.org/28980
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/install/Classes/Controller/StepController.php

index 6496a29..2057e1c 100644 (file)
@@ -288,8 +288,14 @@ class StepController extends AbstractController {
                $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
                $localConfigurationFileLocation = $configurationManager->getLocalConfigurationFileLocation();
                $localConfigurationFileExists = is_file($localConfigurationFileLocation);
+               $packageStatesFilePath = PATH_typo3conf . 'PackageStates.php';
+               $localConfigurationBackupFilePath = preg_replace(
+                       '/\\.php$/',
+                       '.beforePackageStatesMigration.php',
+                       $configurationManager->getLocalConfigurationFileLocation()
+               );
 
-               if (file_exists(PATH_typo3conf . 'PackageStates.php')
+               if (file_exists($packageStatesFilePath)
                        || (is_dir(PATH_typo3conf) && !$localConfigurationFileExists)
                        || !is_dir(PATH_typo3conf)
                ) {
@@ -326,20 +332,21 @@ class StepController extends AbstractController {
                        }
 
                        // Backup LocalConfiguration.php
-                       if (file_exists(PATH_typo3conf . 'PackageStates.php')) {
-                               copy(
-                                       $configurationManager->getLocalConfigurationFileLocation(),
-                                       preg_replace('/\.php$/', '.beforePackageStatesMigration.php', $configurationManager->getLocalConfigurationFileLocation())
-                               );
-                       }
+                       copy(
+                               $configurationManager->getLocalConfigurationFileLocation(),
+                               $localConfigurationBackupFilePath
+                       );
 
                        $packageManager->forceSortAndSavePackageStates();
 
                        // Perform a reload to self, so bootstrap now uses new PackageStates.php
                        $this->redirect();
                } catch (\Exception $exception) {
-                       if (file_exists(PATH_typo3conf . 'PackageStates.php')) {
-                               unlink(PATH_typo3conf . 'PackageStates.php');
+                       if (file_exists($packageStatesFilePath)) {
+                               unlink($packageStatesFilePath);
+                       }
+                       if (file_exists($localConfigurationBackupFilePath)) {
+                               unlink($localConfigurationBackupFilePath);
                        }
                        throw $exception;
                }