[BUGFIX] Use correct values in settings InstallTool 49/54049/4
authorSimon Praetorius <simon@praetorius.me>
Sat, 9 Sep 2017 08:54:32 +0000 (10:54 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 9 Sep 2017 16:54:23 +0000 (18:54 +0200)
Currently, the InstallTool will use the global TYPO3_CONF_VARS for the
settings form. In backend context, this contains merged TypoScript,
which shouldn't be added to LocalConfiguration.php.

Resolves: #82399
Releases: master
Change-Id: I0aabbde5c8fb8574fe30422fa687849271a3d618
Reviewed-on: https://review.typo3.org/54049
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Configuration/ConfigurationManager.php
typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml
typo3/sysext/install/Classes/Service/LocalConfigurationValueService.php
typo3/sysext/install/Resources/Private/Partials/Action/Tool/Settings/LocalConfiguration/SubSection.html

index d35541b..e25c010 100644 (file)
@@ -135,6 +135,18 @@ class ConfigurationManager
         return PATH_site . $this->localConfigurationFile;
     }
 
+    /**
+     * Returns local configuration array merged with default configuration
+     *
+     * @return array
+     */
+    public function getMergedLocalConfiguration(): array
+    {
+        $localConfiguration = $this->getDefaultConfiguration();
+        ArrayUtility::mergeRecursiveWithOverrule($localConfiguration, $this->getLocalConfiguration());
+        return $localConfiguration;
+    }
+
     /**
      * Get the file location of the additional configuration file,
      * currently the path and filename.
index b4660ba..d16006d 100644 (file)
@@ -399,9 +399,11 @@ FE:
         defaultTypoScript_constants:
             type: multiline
             description: 'Enter lines of default TypoScript, constants-field.'
+            compareValuesWithCurrentConfiguration: false
         defaultTypoScript_setup:
             type: multiline
             description: 'Enter lines of default TypoScript, setup-field.'
+            compareValuesWithCurrentConfiguration: false
         additionalAbsRefPrefixDirectories:
             type: text
             description: 'Enter additional directories to be prepended with absRefPrefix. Directories must be comma-separated. TYPO3 already prepends the following directories: typo3/, typo3temp/, typo3conf/ext/ and all local storages'
index 6a8602c..83904f5 100644 (file)
@@ -37,12 +37,19 @@ class LocalConfigurationValueService
      */
     public function getCurrentConfigurationData(): array
     {
+        $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
+        $localConfiguration = $configurationManager->getMergedLocalConfiguration();
+
         $data = [];
         $commentArray = $this->getDefaultConfigArrayComments();
 
-        foreach ($GLOBALS['TYPO3_CONF_VARS'] as $sectionName => $section) {
+        foreach ($localConfiguration as $sectionName => $section) {
             if (isset($commentArray[$sectionName])) {
-                $data[$sectionName] = $this->recursiveConfigurationFetching($section, $commentArray[$sectionName]);
+                $data[$sectionName] = $this->recursiveConfigurationFetching(
+                    $section,
+                    isset($GLOBALS['TYPO3_CONF_VARS'][$sectionName]) ? $GLOBALS['TYPO3_CONF_VARS'][$sectionName] : null,
+                    $commentArray[$sectionName]
+                );
             }
         }
 
@@ -56,11 +63,12 @@ class LocalConfigurationValueService
      * to check entries recursively.
      *
      * @param array $sections
+     * @param array|null $sectionsFromCurrentConfiguration
      * @param array $descriptions
      * @param array $path
      * @return array
      */
-    protected function recursiveConfigurationFetching(array $sections, array $descriptions, array $path = []): array
+    protected function recursiveConfigurationFetching(array $sections, array $sectionsFromCurrentConfiguration, array $descriptions, array $path = []): array
     {
         $data = [];
 
@@ -85,6 +93,10 @@ class LocalConfigurationValueService
                 $itemData['fieldType'] = $descriptionInfo['type'];
                 $itemData['description'] = $descriptionInfo['description'];
                 $itemData['allowedValues'] = $descriptionInfo['allowedValues'];
+                $itemData['differentValueInCurrentConfiguration'] = (!isset($descriptionInfo['compareValuesWithCurrentConfiguration']) ||
+                    $descriptionInfo['compareValuesWithCurrentConfiguration']) &&
+                    isset($sectionsFromCurrentConfiguration[$key]) &&
+                    $value !== $sectionsFromCurrentConfiguration[$key];
                 switch ($descriptionType) {
                     case 'multiline':
                         $itemData['type'] = 'textarea';
index 79f2685..b71942b 100644 (file)
                                        </f:if>
                                </div>
                                <div class="item-body">
+                                       <f:if condition="{item.differentValueInCurrentConfiguration}">
+                                               <div class="t3js-infobox callout callout-sm callout-warning">
+                                                       <div class="callout-body">
+                                                               Note that <code>$GLOBALS['TYPO3_CONF_VARS']</code> currently contains a different value.
+                                                               This could mean that the value is overwritten in AdditionalConfiguration.php.
+                                                       </div>
+                                               </div>
+                                       </f:if>
                                        <f:if condition="{f:count(subject: item.allowedValues)} || {item.dataType} == 'dropdown'">
                                                <f:then>
                                                        <div class="form-group">