[BUGFIX] Don't write LocalConfiguration on every Install Tool entry 21/24221/3
authorErnesto Baschny <ernst@cron-it.de>
Tue, 1 Oct 2013 15:02:09 +0000 (17:02 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 1 Oct 2013 16:22:05 +0000 (18:22 +0200)
Make removeObsoleteLocalConfigurationSettings only rewrite the
file if something has changed.

Resolves: #52437
Releases: 6.2
Change-Id: I014fa04659d1ca8435d576c85ab039a9ee0bf92b
Reviewed-on: https://review.typo3.org/24221
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/core/Classes/Configuration/ConfigurationManager.php
typo3/sysext/core/Tests/Unit/Configuration/ConfigurationManagerTest.php

index 2a24b24..6682b81 100644 (file)
@@ -252,7 +252,9 @@ class ConfigurationManager {
                                $localConfiguration = Utility\ArrayUtility::removeByPath($localConfiguration, $path);
                        }
                }
-               $this->writeLocalConfiguration($localConfiguration);
+               if ($result) {
+                       $this->writeLocalConfiguration($localConfiguration);
+               }
                return $result;
        }
 
index d0bcc3b..a772bdf 100644 (file)
@@ -331,7 +331,27 @@ class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $currentLocalConfiguration = array(
                        'notChanged' => 23,
                );
-               $expectedConfiguration = array(
+               $this->createFixtureWithMockedMethods(
+                       array(
+                               'getLocalConfiguration',
+                               'writeLocalConfiguration',
+                       )
+               );
+               $this->fixture->expects($this->once())
+                       ->method('getLocalConfiguration')
+                       ->will($this->returnValue($currentLocalConfiguration));
+               $this->fixture->expects($this->never())
+                       ->method('writeLocalConfiguration');
+
+               $removeNothing = array();
+               $this->assertFalse($this->fixture->removeLocalConfigurationKeysByPath($removeNothing));
+       }
+
+       /**
+        * @test
+        */
+       public function removeLocalConfigurationKeysByPathReturnsFalseIfSomethingInexistentIsRemoved() {
+               $currentLocalConfiguration = array(
                        'notChanged' => 23,
                );
                $this->createFixtureWithMockedMethods(
@@ -343,12 +363,11 @@ class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->fixture->expects($this->once())
                        ->method('getLocalConfiguration')
                        ->will($this->returnValue($currentLocalConfiguration));
-               $this->fixture->expects($this->once())
-                       ->method('writeLocalConfiguration')
-                       ->with($expectedConfiguration);
+               $this->fixture->expects($this->never())
+                       ->method('writeLocalConfiguration');
 
-               $removePaths = array();
-               $this->assertFalse($this->fixture->removeLocalConfigurationKeysByPath($removePaths));
+               $removeNonExisting = array('notPresent');
+               $this->assertFalse($this->fixture->removeLocalConfigurationKeysByPath($removeNonExisting));
        }
 
        /**