[TASK] Improve performance of array_merge_recursive_overrule 86/25986/11
authorMarkus Klein <klein.t3@mfc-linz.at>
Fri, 6 Dec 2013 12:50:07 +0000 (13:50 +0100)
committerErnesto Baschny <ernst@cron-it.de>
Wed, 8 Jan 2014 12:13:30 +0000 (13:13 +0100)
The method GeneralUtility::array_merge_recursive_overrule()
always works on a copy of the given array(s). This is highly
inefficient when it comes to really big arrays and recursion.

This patches moves the functionality into the class ArrayUtility
and changes the behaviour to use a reference to the
original array.
All calls in the core are adjusted accordingly.

Furthermore we deprecate the method in GeneralUtility and
preserve backward compatibility.

Resolves: #54251
Releases: 6.2
Change-Id: I5499905593c2124897de5998be985e546a3d05ee
Reviewed-on: https://review.typo3.org/25986
Reviewed-by: Michiel Roos
Tested-by: Michiel Roos
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
49 files changed:
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/backend/Classes/Form/Element/SuggestDefaultReceiver.php
typo3/sysext/backend/Classes/Form/Element/SuggestElement.php
typo3/sysext/backend/Classes/Form/FlexFormsHelper.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/Module/AbstractFunctionModule.php
typo3/sysext/backend/Classes/Template/DocumentTemplate.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/cms/layout/db_new_content_el.php
typo3/sysext/core/Classes/Category/CategoryRegistry.php
typo3/sysext/core/Classes/Configuration/ConfigurationManager.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Localization/Locales.php
typo3/sysext/core/Classes/Localization/LocalizationFactory.php
typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php
typo3/sysext/core/Classes/Page/PageRenderer.php
typo3/sysext/core/Classes/Resource/FileReference.php
typo3/sysext/core/Classes/TypoScript/ConfigurationForm.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Classes/Utility/ArrayUtility.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Resource/BaseTestCase.php
typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php
typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php
typo3/sysext/extbase/Classes/Configuration/AbstractConfigurationManager.php
typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php
typo3/sysext/extbase/Classes/Configuration/FrontendConfigurationManager.php
typo3/sysext/extbase/Classes/Mvc/Web/Routing/UriBuilder.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php
typo3/sysext/extbase/Classes/Utility/ExtensionUtility.php
typo3/sysext/extensionmanager/Classes/Controller/ConfigurationController.php
typo3/sysext/extensionmanager/Classes/Domain/Repository/ConfigurationItemRepository.php
typo3/sysext/extensionmanager/Classes/Utility/ConfigurationUtility.php
typo3/sysext/filemetadata/Configuration/TCA/sys_file_metadata.php
typo3/sysext/fluid/Classes/ViewHelpers/Be/Widget/Controller/PaginateController.php
typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php
typo3/sysext/form/Classes/Controller/FormController.php
typo3/sysext/form/Classes/View/Wizard/WizardView.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php
typo3/sysext/lang/Classes/LanguageService.php
typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php
typo3/sysext/rtehtmlarea/Classes/RteHtmlAreaApi.php
typo3/sysext/rtehtmlarea/Classes/RteHtmlAreaBase.php
typo3/sysext/rtehtmlarea/Classes/User.php
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/version/Classes/DataHandler/CommandMap.php

index 22866ea..32efb1c 100644 (file)
@@ -2260,7 +2260,7 @@ class InlineElement {
                        $PA = array();
                        $PA['fieldConf'] = $GLOBALS['TCA'][$foreign_table]['columns'][$field];
                        if ($PA['fieldConf'] && $conf['foreign_selector_fieldTcaOverride']) {
-                               $PA['fieldConf'] = GeneralUtility::array_merge_recursive_overrule($PA['fieldConf'], $conf['foreign_selector_fieldTcaOverride']);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($PA['fieldConf'], $conf['foreign_selector_fieldTcaOverride']);
                        }
                        $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
                        // Using "form_type" locally in this script
index d7351ab..4daf8a3 100644 (file)
@@ -121,7 +121,7 @@ class SuggestDefaultReceiver {
                        $depth = intval($config['pidDepth']);
                        foreach ($pageIds as $pageId) {
                                if ($pageId > 0) {
-                                       $allowedPages = GeneralUtility::array_merge_recursive_overrule($allowedPages, $this->getAllSubpagesOfPage($pageId, $depth));
+                                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($allowedPages, $this->getAllSubpagesOfPage($pageId, $depth));
                                }
                        }
                        $this->allowedPages = array_unique($allowedPages);
index 8f83259..1ed6c0c 100644 (file)
@@ -218,23 +218,23 @@ class SuggestElement {
                        }
                        $config = (array) $wizardConfig['default'];
                        if (is_array($wizardConfig[$queryTable])) {
-                               $config = GeneralUtility::array_merge_recursive_overrule($config, $wizardConfig[$queryTable]);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($config, $wizardConfig[$queryTable]);
                        }
                        // merge the configurations of different "levels" to get the working configuration for this table and
                        // field (i.e., go from the most general to the most special configuration)
                        if (is_array($TSconfig['TCEFORM.']['suggest.']['default.'])) {
-                               $config = GeneralUtility::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.']['suggest.']['default.']);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($config, $TSconfig['TCEFORM.']['suggest.']['default.']);
                        }
                        if (is_array($TSconfig['TCEFORM.']['suggest.'][$queryTable . '.'])) {
-                               $config = GeneralUtility::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.']['suggest.'][$queryTable . '.']);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($config, $TSconfig['TCEFORM.']['suggest.'][$queryTable . '.']);
                        }
                        // use $table instead of $queryTable here because we overlay a config
                        // for the input-field here, not for the queried table
                        if (is_array($TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.']['default.'])) {
-                               $config = GeneralUtility::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.']['default.']);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($config, $TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.']['default.']);
                        }
                        if (is_array($TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.'][$queryTable . '.'])) {
-                               $config = GeneralUtility::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.'][$queryTable . '.']);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($config, $TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.'][$queryTable . '.']);
                        }
                        //process addWhere
                        if (!isset($config['addWhere']) && $foreign_table_where) {
index ed93f72..8914cd2 100644 (file)
@@ -189,7 +189,8 @@ class FlexFormsHelper extends \TYPO3\CMS\Backend\Form\FormEngine {
                        unset($fieldConf['addItems']);
                        // Manipulate field
                        if (!empty($field['TCEforms']) && is_array($field['TCEforms'])) {
-                               $sheet[$fieldName]['TCEforms'] = GeneralUtility::array_merge_recursive_overrule($field['TCEforms'], $fieldConf);
+                               $sheet[$fieldName]['TCEforms'] = $field['TCEforms'];
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($sheet[$fieldName]['TCEforms'], $fieldConf);
                        }
                        // Manipulate only select fields, other field types will stop here
                        if (empty($field['TCEforms']['config']['type']) || $field['TCEforms']['config']['type'] != 'select') {
index defbe81..51720ac 100644 (file)
@@ -3545,7 +3545,7 @@ TBE_EDITOR.customEvalFunctions[\'' . $evalData . '\'] = function(value) {
                                }
                                // Override $GLOBALS['TCA'] field config by remaining TSconfig['config']:
                                if (count($TSconfig['config'])) {
-                                       $fieldConfig = GeneralUtility::array_merge_recursive_overrule($fieldConfig, $TSconfig['config']);
+                                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($fieldConfig, $TSconfig['config']);
                                }
                        }
                }
index 6be9b44..66ae262 100644 (file)
@@ -234,7 +234,8 @@ abstract class AbstractFunctionModule {
                if ($this->localLangFile && (@is_file(($this->thisPath . '/' . $this->localLangFile)) || @is_file(($this->thisPath . '/' . substr($this->localLangFile, 0, -4) . '.xml')) || @is_file(($this->thisPath . '/' . substr($this->localLangFile, 0, -4) . '.xlf')))) {
                        $LOCAL_LANG = $GLOBALS['LANG']->includeLLFile($this->thisPath . '/' . $this->localLangFile, FALSE);
                        if (is_array($LOCAL_LANG)) {
-                               $GLOBALS['LOCAL_LANG'] = GeneralUtility::array_merge_recursive_overrule((array) $GLOBALS['LOCAL_LANG'], $LOCAL_LANG);
+                               $GLOBALS['LOCAL_LANG'] = (array)$GLOBALS['LOCAL_LANG'];
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['LOCAL_LANG'], $LOCAL_LANG);
                        }
                }
        }
index 42a0261..38f90c7 100644 (file)
@@ -361,7 +361,7 @@ class DocumentTemplate {
                        // Make copy
                        $ovr = $GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID];
                        // merge styles.
-                       $GLOBALS['TBE_STYLES'] = GeneralUtility::array_merge_recursive_overrule($GLOBALS['TBE_STYLES'], $ovr);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TBE_STYLES'], $ovr);
                        // Have to unset - otherwise the second instantiation will do it again!
                        unset($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID]);
                }
index 1ce3280..cb3d4d3 100644 (file)
@@ -1169,7 +1169,7 @@ class BackendUtility {
                        // Get User TSconfig overlay
                        $userTSconfig = $GLOBALS['BE_USER']->userTS['page.'];
                        if (is_array($userTSconfig)) {
-                               $TSconfig = GeneralUtility::array_merge_recursive_overrule($TSconfig, $userTSconfig);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($TSconfig, $userTSconfig);
                        }
 
                        if ($useCacheForCurrentPageId) {
@@ -2704,8 +2704,8 @@ class BackendUtility {
                if (is_null($BE_USER_modOptions['value'])) {
                        unset($BE_USER_modOptions['value']);
                }
-               $modTSconfig = GeneralUtility::array_merge_recursive_overrule($pageTS_modOptions, $BE_USER_modOptions);
-               return $modTSconfig;
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($pageTS_modOptions, $BE_USER_modOptions);
+               return $pageTS_modOptions;
        }
 
        /**
@@ -3242,7 +3242,7 @@ class BackendUtility {
                                                $res[$fieldN] = $val;
                                                unset($res[$fieldN]['types.']);
                                                if (strcmp($typeVal, '') && is_array($val['types.'][$typeVal . '.'])) {
-                                                       $res[$fieldN] = GeneralUtility::array_merge_recursive_overrule($res[$fieldN], $val['types.'][$typeVal . '.']);
+                                                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($res[$fieldN], $val['types.'][$typeVal . '.']);
                                                }
                                        }
                                }
@@ -3400,10 +3400,10 @@ class BackendUtility {
                $thisFieldConf = $RTEprop['config.'][$table . '.'][$field . '.'];
                if (is_array($thisFieldConf)) {
                        unset($thisFieldConf['types.']);
-                       $thisConfig = GeneralUtility::array_merge_recursive_overrule($thisConfig, $thisFieldConf);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($thisConfig, $thisFieldConf);
                }
                if ($type && is_array($RTEprop['config.'][$table . '.'][$field . '.']['types.'][$type . '.'])) {
-                       $thisConfig = GeneralUtility::array_merge_recursive_overrule($thisConfig, $RTEprop['config.'][$table . '.'][$field . '.']['types.'][$type . '.']);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($thisConfig, $RTEprop['config.'][$table . '.'][$field . '.']['types.'][$type . '.']);
                }
                return $thisConfig;
        }
index 7da0767..8dc1635 100644 (file)
@@ -40,7 +40,8 @@ unset($MLANG);
 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
 $LOCAL_LANG_orig = $LOCAL_LANG;
 $LANG->includeLLFile('EXT:cms/layout/locallang_db_new_content_el.xlf');
-$LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($LOCAL_LANG_orig, $LOCAL_LANG);
+\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($LOCAL_LANG_orig, $LOCAL_LANG);
+$LOCAL_LANG = $LOCAL_LANG_orig;
 // Exits if 'cms' extension is not loaded:
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms', 1);
 /**
index 1cd1407..930a7bd 100644 (file)
@@ -349,7 +349,7 @@ class CategoryRegistry implements \TYPO3\CMS\Core\SingletonInterface {
                        );
 
                        if (!empty($options['fieldConfiguration'])) {
-                               $fieldConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
                                        $fieldConfiguration,
                                        $options['fieldConfiguration']
                                );
index 7a66b75..5e2d116 100644 (file)
@@ -160,10 +160,8 @@ class ConfigurationManager {
         * @return void
         */
        public function updateLocalConfiguration(array $configurationToMerge) {
-               $newLocalConfiguration = Utility\GeneralUtility::array_merge_recursive_overrule(
-                       $this->getLocalConfiguration(),
-                       $configurationToMerge
-               );
+               $newLocalConfiguration = $this->getLocalConfiguration();
+               Utility\ArrayUtility::mergeRecursiveWithOverrule($newLocalConfiguration, $configurationToMerge);
                $this->writeLocalConfiguration($newLocalConfiguration);
        }
 
@@ -195,12 +193,9 @@ class ConfigurationManager {
         * @return mixed
         */
        public function getConfigurationValueByPath($path) {
-               return Utility\ArrayUtility::getValueByPath(
-                       Utility\GeneralUtility::array_merge_recursive_overrule(
-                               $this->getDefaultConfiguration(), $this->getLocalConfiguration()
-                       ),
-                       $path
-               );
+               $defaultConfiguration = $this->getDefaultConfiguration();
+               Utility\ArrayUtility::mergeRecursiveWithOverrule($defaultConfiguration, $this->getLocalConfiguration());
+               return Utility\ArrayUtility::getValueByPath($defaultConfiguration, $path);
        }
 
        /**
@@ -280,7 +275,9 @@ class ConfigurationManager {
                if (@is_file($this->getLocalConfigurationFileLocation())) {
                        $localConfiguration = $this->getLocalConfiguration();
                        if (is_array($localConfiguration)) {
-                               $GLOBALS['TYPO3_CONF_VARS'] = Utility\GeneralUtility::array_merge_recursive_overrule($this->getDefaultConfiguration(), $localConfiguration);
+                               $defaultConfiguration = $this->getDefaultConfiguration();
+                               Utility\ArrayUtility::mergeRecursiveWithOverrule($defaultConfiguration, $localConfiguration);
+                               $GLOBALS['TYPO3_CONF_VARS'] = $defaultConfiguration;
                        } else {
                                throw new \UnexpectedValueException('LocalConfiguration invalid.', 1349272276);
                        }
@@ -359,7 +356,7 @@ class ConfigurationManager {
                $additionalFactoryConfigurationFileLocation = $this->getAdditionalFactoryConfigurationFileLocation();
                if (file_exists($additionalFactoryConfigurationFileLocation)) {
                        $additionalFactoryConfigurationArray = require $additionalFactoryConfigurationFileLocation;
-                       $localConfigurationArray = Utility\GeneralUtility::array_merge_recursive_overrule(
+                       Utility\ArrayUtility::mergeRecursiveWithOverrule(
                                $localConfigurationArray,
                                $additionalFactoryConfigurationArray
                        );
index 3fdf322..78a6de0 100644 (file)
@@ -1107,7 +1107,7 @@ class DataHandler {
                                                                                                                $this->autoVersionIdMap[$origTable][$origId] = $newId;
                                                                                                        }
                                                                                                }
-                                                                                               $this->RTEmagic_copyIndex = GeneralUtility::array_merge_recursive_overrule($this->RTEmagic_copyIndex, $tce->RTEmagic_copyIndex);
+                                                                                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->RTEmagic_copyIndex, $tce->RTEmagic_copyIndex);
                                                                                                // See where RTEmagic_copyIndex is used inside fillInFieldArray() for more information...
                                                                                                // Update registerDBList, that holds the copied relations to child records:
                                                                                                $registerDBList = array_merge($registerDBList, $tce->registerDBList);
@@ -1306,7 +1306,7 @@ class DataHandler {
                        // IF $incomingFieldArray is an array, overlay it.
                        // The point is that when new records are created as copies with flex type fields there might be a field containing information about which DataStructure to use and without that information the flexforms cannot be correctly processed.... This should be OK since the $checkValueRecord is used by the flexform evaluation only anyways...
                        if (is_array($incomingFieldArray) && is_array($checkValueRecord)) {
-                               $checkValueRecord = GeneralUtility::array_merge_recursive_overrule($checkValueRecord, $incomingFieldArray);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($checkValueRecord, $incomingFieldArray);
                        }
                } else {
                        // We must use the current values as basis for this!
@@ -2184,8 +2184,8 @@ class DataHandler {
                                        }
                                }
 
-                               $arrValue = GeneralUtility::array_merge_recursive_overrule($currentValueArray, $arrValue);
-                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue, TRUE);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($currentValueArray, $arrValue);
+                               $xmlValue = $this->checkValue_flexArray2Xml($currentValueArray, TRUE);
                        }
                        // Action commands (sorting order and removals of elements)
                        $actionCMDs = GeneralUtility::_GP('_ACTION_FLEX_FORMdata');
@@ -2915,7 +2915,7 @@ class DataHandler {
                                                        }
                                                }
                                                // Merging the copy-array info together for remapping purposes.
-                                               $this->copyMappingArray_merged = GeneralUtility::array_merge_recursive_overrule($this->copyMappingArray_merged, $this->copyMappingArray);
+                                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->copyMappingArray_merged, $this->copyMappingArray);
                                        }
                                }
                        }
@@ -6437,7 +6437,8 @@ class DataHandler {
        public function getTableEntries($table, $TSconfig) {
                $tA = is_array($TSconfig['table.'][$table . '.']) ? $TSconfig['table.'][$table . '.'] : array();
                $dA = is_array($TSconfig['default.']) ? $TSconfig['default.'] : array();
-               return GeneralUtility::array_merge_recursive_overrule($dA, $tA);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($dA, $tA);
+               return $dA;
        }
 
        /**
index aa4c32a..736ae7e 100644 (file)
@@ -185,7 +185,7 @@ class Locales implements \TYPO3\CMS\Core\SingletonInterface {
                }
                // Merge user-provided locale dependencies
                if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies'])) {
-                       $instance->localeDependencies = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($instance->localeDependencies, $GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies']);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($instance->localeDependencies, $GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies']);
                }
        }
 
index f657351..e7bbd7a 100644 (file)
@@ -150,7 +150,7 @@ class LocalizationFactory implements \TYPO3\CMS\Core\SingletonInterface {
                if (count($overrides) > 0) {
                        foreach ($overrides as $overrideFile) {
                                $languageOverrideFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($overrideFile);
-                               $LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($LOCAL_LANG, $this->getParsedData($languageOverrideFileName, $languageKey, $charset, $errorMode, TRUE));
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($LOCAL_LANG, $this->getParsedData($languageOverrideFileName, $languageKey, $charset, $errorMode, TRUE));
                        }
                }
        }
index 8b7ef9c..20653a9 100644 (file)
@@ -63,7 +63,8 @@ class LocallangXmlParser extends \TYPO3\CMS\Core\Localization\Parser\AbstractXml
                        $parsedTarget = $this->getParsedTargetData($this->sourcePath);
                }
                $LOCAL_LANG = array();
-               $LOCAL_LANG[$languageKey] = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($parsedSource, $parsedTarget);
+               $LOCAL_LANG[$languageKey] = $parsedSource;
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($LOCAL_LANG[$languageKey], $parsedTarget);
                return $LOCAL_LANG;
        }
 
index 615cd02..0adf18e 100644 (file)
@@ -2507,7 +2507,7 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface {
                        if ($this->lang !== 'default' && isset($tempLL[$language])) {
                                // Merge current language labels onto labels from previous language
                                // This way we have a labels with fall back applied
-                               $localLanguage[$this->lang] = GeneralUtility::array_merge_recursive_overrule($localLanguage[$this->lang], $tempLL[$language], FALSE, FALSE);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($localLanguage[$this->lang], $tempLL[$language], TRUE, FALSE);
                        }
                }
 
index 1529239..fe90273 100644 (file)
@@ -166,10 +166,11 @@ class FileReference implements FileInterface {
         */
        public function getProperties() {
                if (empty($this->mergedProperties)) {
-                       $this->mergedProperties = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(
-                               $this->propertiesOfFileReference,
+                       $this->mergedProperties = $this->propertiesOfFileReference;
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
+                               $this->mergedProperties,
                                $this->originalFile->getProperties(),
-                               FALSE,
+                               TRUE,
                                TRUE,
                                FALSE
                        );
index e5db8c8..5eee7ee 100644 (file)
@@ -182,7 +182,8 @@ class ConfigurationForm extends \TYPO3\CMS\Core\TypoScript\ExtendedTemplateServi
                $parseObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
                $parseObj->parse(implode(LF, $this->ext_incomingValues));
                $arr2 = $parseObj->setup;
-               return \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($arr, $arr2);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($arr, $arr2);
+               return $arr;
        }
 
        // Extends:
index f8d4524..95f71c9 100644 (file)
@@ -1073,7 +1073,7 @@ class TemplateService {
                $parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
                $parseObj->parse($userTS);
                if (is_array($parseObj->setup['TSFE.']['constants.'])) {
-                       $constArray = GeneralUtility::array_merge_recursive_overrule($constArray, $parseObj->setup['TSFE.']['constants.']);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($constArray, $parseObj->setup['TSFE.']['constants.']);
                }
                return $constArray;
        }
index 76cdb8e..6b25605 100644 (file)
@@ -513,4 +513,45 @@ class ArrayUtility {
                return $renumberedArray;
        }
 
+
+       /**
+        * Merges two arrays recursively and "binary safe" (integer keys are
+        * overridden as well), overruling similar values in the original array
+        * with the values of the overrule array.
+        * In case of identical keys, ie. keeping the values of the overrule array.
+        *
+        * This method takes the original array by reference for speed optimization with large arrays
+        *
+        * The differences to the existing PHP function array_merge_recursive() are:
+        *  * Keys of the original array can be unset via the overrule array. ($enableUnsetFeature)
+        *  * Much more control over what is actually merged. ($addKeys, $includeEmptyValues)
+        *  * Elements or the original array get overwritten if the same key is present in the overrule array.
+        *
+        * @param array $original Original array. It will be *modified* by this method and contains the result afterwards!
+        * @param array $overrule Overrule array, overruling the original array
+        * @param boolean $addKeys If set to FALSE, keys that are NOT found in $original will not be set. Thus only existing value can/will be overruled from overrule array.
+        * @param boolean $includeEmptyValues If set, values from $overrule will overrule if they are empty or zero.
+        * @param boolean $enableUnsetFeature If set, special values "__UNSET" can be used in the overrule array in order to unset array keys in the original array.
+        * @return void
+        */
+       static public function mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys = TRUE, $includeEmptyValues = TRUE, $enableUnsetFeature = TRUE) {
+               foreach (array_keys($overrule) as $key) {
+                       if ($enableUnsetFeature && $overrule[$key] === '__UNSET') {
+                               unset($original[$key]);
+                               continue;
+                       }
+                       if (isset($original[$key]) && is_array($original[$key])) {
+                               if (is_array($overrule[$key])) {
+                                       self::mergeRecursiveWithOverrule($original[$key], $overrule[$key], $addKeys, $includeEmptyValues, $enableUnsetFeature);
+                               }
+                       } elseif (
+                               ($addKeys || isset($original[$key])) &&
+                               ($includeEmptyValues || $overrule[$key])
+                       ) {
+                               $original[$key] = $overrule[$key];
+                       }
+               }
+               // This line is kept for backward compatibility reasons.
+               reset($original);
+       }
 }
index 54b9c72..fcec966 100644 (file)
@@ -499,7 +499,8 @@ class ExtensionManagementUtility {
                                'localizeChildrenAtParentLocalization' => TRUE,
                        ),
                );
-               return GeneralUtility::array_merge_recursive_overrule($fileFieldTCAConfig, $customSettingOverride);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($fileFieldTCAConfig, $customSettingOverride);
+               return $fileFieldTCAConfig;
        }
 
        /**
@@ -739,7 +740,8 @@ class ExtensionManagementUtility {
                if ($mainModuleName === 'web') {
                        $defaultModuleConfiguration['navigationComponentId'] = 'typo3-pagetree';
                }
-               $moduleConfiguration = GeneralUtility::array_merge_recursive_overrule($defaultModuleConfiguration, $moduleConfiguration);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($defaultModuleConfiguration, $moduleConfiguration);
+               $moduleConfiguration = $defaultModuleConfiguration;
                if (strlen($subModuleName) > 0) {
                        $moduleSignature = $mainModuleName . '_' . $subModuleName;
                } else {
index 28d42a1..4d2307b 100644 (file)
@@ -129,7 +129,8 @@ class GeneralUtility {
        static public function _GPmerged($parameter) {
                $postParameter = isset($_POST[$parameter]) && is_array($_POST[$parameter]) ? $_POST[$parameter] : array();
                $getParameter = isset($_GET[$parameter]) && is_array($_GET[$parameter]) ? $_GET[$parameter] : array();
-               $mergedParameters = self::array_merge_recursive_overrule($getParameter, $postParameter);
+               $mergedParameters = $getParameter;
+               ArrayUtility::mergeRecursiveWithOverrule($mergedParameters, $postParameter);
                self::stripSlashesOnArray($mergedParameters);
                return $mergedParameters;
        }
@@ -200,7 +201,8 @@ class GeneralUtility {
                                        $pointer = &$pointer[$piece];
                                }
                                $pointer = $inputGet;
-                               $mergedGet = self::array_merge_recursive_overrule($_GET, $newGet);
+                               $mergedGet = $_GET;
+                               ArrayUtility::mergeRecursiveWithOverrule($mergedGet, $newGet);
                                $_GET = $mergedGet;
                                $GLOBALS['HTTP_GET_VARS'] = $mergedGet;
                        } else {
@@ -1719,25 +1721,12 @@ class GeneralUtility {
         * @param boolean $includeEmptyValues If set, values from $arr1 will overrule if they are empty or zero. Default: TRUE
         * @param boolean $enableUnsetFeature If set, special values "__UNSET" can be used in the second array in order to unset array keys in the resulting array.
         * @return array Resulting array where $arr1 values has overruled $arr0 values
+        * @deprecated since 6.2 - will be removed two versions later: use ArrayUtility::mergeRecursiveWithOverrule instead. Consider that the first array is directly modified there. (better performance)
         */
        static public function array_merge_recursive_overrule(array $arr0, array $arr1, $notAddKeys = FALSE, $includeEmptyValues = TRUE, $enableUnsetFeature = TRUE) {
-               foreach ($arr1 as $key => $val) {
-                       if ($enableUnsetFeature && $val === '__UNSET') {
-                               unset($arr0[$key]);
-                               continue;
-                       }
-                       if (is_array($arr0[$key])) {
-                               if (is_array($arr1[$key])) {
-                                       $arr0[$key] = self::array_merge_recursive_overrule($arr0[$key], $arr1[$key], $notAddKeys, $includeEmptyValues, $enableUnsetFeature);
-                               }
-                       } elseif (
-                               (!$notAddKeys || isset($arr0[$key])) &&
-                               ($includeEmptyValues || $val)
-                       ) {
-                               $arr0[$key] = $val;
-                       }
-               }
-               reset($arr0);
+               self::logDeprecatedFunction();
+               ArrayUtility::mergeRecursiveWithOverrule($arr0, $arr1, !$notAddKeys, $includeEmptyValues, $enableUnsetFeature);
+               // Our local $arr0 has been modified now, so return it as result
                return $arr0;
        }
 
@@ -3183,7 +3172,7 @@ Connection: close
                if ($parts['query']) {
                        parse_str($parts['query'], $getP);
                }
-               $getP = self::array_merge_recursive_overrule($getP, $getParams);
+               ArrayUtility::mergeRecursiveWithOverrule($getP, $getParams);
                $uP = explode('?', $url);
                $params = self::implodeArrayForUrl('', $getP);
                $outurl = $uP[0] . ($params ? '?' . substr($params, 1) : '');
index 2391d25..aa01a75 100644 (file)
@@ -58,7 +58,7 @@ abstract class BaseTestCase extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        protected function mergeToVfsContents($contents) {
-               $this->vfsContents = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->vfsContents, $contents);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->vfsContents, $contents);
        }
 
        protected function initializeVfs() {
index 273b40f..3c6dbb9 100644 (file)
@@ -70,9 +70,8 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
                $permissionMethods = array('assureFileAddPermissions', 'checkFolderActionPermission', 'checkFileActionPermission', 'checkUserActionPermission', 'checkFileExtensionPermission', 'isWithinFileMountBoundaries');
                $mockedMethods = NULL;
                $configuration = $this->convertConfigurationArrayToFlexformXml($configuration);
-               $storageRecord = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($storageRecord, array(
-                       'configuration' => $configuration
-               ));
+               $overruleArray = array('configuration' => $configuration);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($storageRecord, $overruleArray);
                if ($driverObject == NULL) {
                        /** @var $mockedDriver \TYPO3\CMS\Core\Resource\Driver\AbstractDriver */
                        $driverObject = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Driver\\AbstractDriver', array(), '', FALSE);
index 587b0e8..be1fbc0 100644 (file)
@@ -1492,4 +1492,33 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertEquals($expected, ArrayUtility::renumberKeysToAvoidLeapsIfKeysAreAllNumeric($inputArray));
        }
 
+
+       /**
+        * @test
+        */
+       public function arrayMergeRecursiveOverruleDoesConsiderUnsetValues() {
+               $array1 = array(
+                       'first' => array(
+                               'second' => 'second',
+                               'third' => 'third'
+                       ),
+                       'fifth' => array()
+               );
+               $array2 = array(
+                       'first' => array(
+                               'second' => 'overrule',
+                               'third' => '__UNSET',
+                               'fourth' => 'overrile'
+                       ),
+                       'fifth' => '__UNSET'
+               );
+               $expected = array(
+                       'first' => array(
+                               'second' => 'overrule',
+                               'fourth' => 'overrile'
+                       )
+               );
+               ArrayUtility::mergeRecursiveWithOverrule($array1, $array2);
+               $this->assertEquals($expected, $array1);
+       }
 }
index 7b9a645..edff561 100755 (executable)
@@ -144,7 +144,7 @@ abstract class AbstractConfigurationManager implements \TYPO3\CMS\Core\Singleton
                // only merge $this->configuration and override switchableControllerActions when retrieving configuration of the current plugin
                if ($extensionName === NULL || $extensionName === $this->extensionName && $pluginName === $this->pluginName) {
                        $pluginConfiguration = $this->getPluginConfiguration($this->extensionName, $this->pluginName);
-                       $pluginConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($pluginConfiguration, $this->configuration);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($pluginConfiguration, $this->configuration);
                        $pluginConfiguration['controllerConfiguration'] = $this->getSwitchableControllerActions($this->extensionName, $this->pluginName);
                        if (isset($this->configuration['switchableControllerActions'])) {
                                $this->overrideSwitchableControllerActions($pluginConfiguration, $this->configuration['switchableControllerActions']);
@@ -153,7 +153,7 @@ abstract class AbstractConfigurationManager implements \TYPO3\CMS\Core\Singleton
                        $pluginConfiguration = $this->getPluginConfiguration($extensionName, $pluginName);
                        $pluginConfiguration['controllerConfiguration'] = $this->getSwitchableControllerActions($extensionName, $pluginName);
                }
-               $frameworkConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($frameworkConfiguration, $pluginConfiguration);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($frameworkConfiguration, $pluginConfiguration);
                // only load context specific configuration when retrieving configuration of the current plugin
                if ($extensionName === NULL || $extensionName === $this->extensionName && $pluginName === $this->pluginName) {
                        $frameworkConfiguration = $this->getContextSpecificFrameworkConfiguration($frameworkConfiguration);
index a1cc62f..85447cc 100644 (file)
@@ -94,7 +94,8 @@ class BackendConfigurationManager extends \TYPO3\CMS\Extbase\Configuration\Abstr
                if ($pluginName !== NULL) {
                        $pluginSignature = strtolower($extensionName . '_' . $pluginName);
                        if (is_array($setup['module.']['tx_' . $pluginSignature . '.'])) {
-                               $pluginConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($pluginConfiguration, $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . $pluginSignature . '.']));
+                               $overruleConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . $pluginSignature . '.']);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($pluginConfiguration, $overruleConfiguration);
                        }
                }
                return $pluginConfiguration;
index 8f964a8..c3856d2 100644 (file)
@@ -66,7 +66,10 @@ class FrontendConfigurationManager extends \TYPO3\CMS\Extbase\Configuration\Abst
                if ($pluginName !== NULL) {
                        $pluginSignature = strtolower($extensionName . '_' . $pluginName);
                        if (is_array($setup['plugin.']['tx_' . $pluginSignature . '.'])) {
-                               $pluginConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($pluginConfiguration, $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_' . $pluginSignature . '.']));
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
+                                       $pluginConfiguration,
+                                       $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_' . $pluginSignature . '.'])
+                               );
                        }
                }
                return $pluginConfiguration;
@@ -126,7 +129,7 @@ class FrontendConfigurationManager extends \TYPO3\CMS\Extbase\Configuration\Abst
                        if (count($list) > 0) {
                                $pages = $pages . ',' . implode(',', $list);
                        }
-                       $frameworkConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($frameworkConfiguration, array(
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($frameworkConfiguration, array(
                                'persistence' => array(
                                        'storagePid' => $pages
                                )
@@ -189,7 +192,7 @@ class FrontendConfigurationManager extends \TYPO3\CMS\Extbase\Configuration\Abst
         */
        protected function mergeConfigurationIntoFrameworkConfiguration(array $frameworkConfiguration, array $configuration, $configurationPartName) {
                if (is_array($frameworkConfiguration[$configurationPartName]) && is_array($configuration[$configurationPartName])) {
-                       $frameworkConfiguration[$configurationPartName] = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($frameworkConfiguration[$configurationPartName], $configuration[$configurationPartName]);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($frameworkConfiguration[$configurationPartName], $configuration[$configurationPartName]);
                }
                return $frameworkConfiguration;
        }
index 89cb372..e4aabb1 100644 (file)
@@ -520,7 +520,7 @@ class UriBuilder {
                        $pluginNamespace = $this->extensionService->getPluginNamespace($extensionName, $pluginName);
                        $prefixedControllerArguments = array($pluginNamespace => $controllerArguments);
                }
-               $this->arguments = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->arguments, $prefixedControllerArguments);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->arguments, $prefixedControllerArguments);
                return $this->build();
        }
 
@@ -606,7 +606,7 @@ class UriBuilder {
                                'id' => \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id')
                        );
                }
-               $arguments = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($arguments, $this->arguments);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($arguments, $this->arguments);
                $arguments = $this->convertDomainObjectsToIdentityArrays($arguments);
                $this->lastArguments = $arguments;
                $uri = 'mod.php?' . http_build_query($arguments, NULL, '&');
index 0225282..0ae2ad7 100644 (file)
@@ -126,7 +126,7 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface {
                                $currentClassSettings = $frameworkConfiguration['persistence']['classes'][$currentClassName];
                                if ($currentClassSettings !== NULL) {
                                        if (isset($currentClassSettings['mapping']['columns']) && is_array($currentClassSettings['mapping']['columns'])) {
-                                               $columnMapping = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($columnMapping, $currentClassSettings['mapping']['columns'], 0, FALSE);
+                                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($columnMapping, $currentClassSettings['mapping']['columns'], TRUE, FALSE);
                                        }
                                }
                        }
@@ -136,7 +136,7 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface {
                $dataMap = $this->addMetaDataColumnNames($dataMap, $tableName);
                // $classPropertyNames = $this->reflectionService->getClassPropertyNames($className);
                $tcaColumnsDefinition = $this->getColumnsDefinition($tableName);
-               $tcaColumnsDefinition = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($tcaColumnsDefinition, $columnMapping);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($tcaColumnsDefinition, $columnMapping);
                // TODO Is this is too powerful?
 
                foreach ($tcaColumnsDefinition as $columnName => $columnDefinition) {
index c371480..12932f2 100644 (file)
@@ -237,7 +237,8 @@ tt_content.' . $pluginSignature . ' {
                if ($mainModuleName === 'web') {
                        $defaultModuleConfiguration['navigationComponentId'] = 'typo3-pagetree';
                }
-               $moduleConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($defaultModuleConfiguration, $moduleConfiguration);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($defaultModuleConfiguration, $moduleConfiguration);
+               $moduleConfiguration = $defaultModuleConfiguration;
                $moduleSignature = $mainModuleName;
                if (strlen($subModuleName) > 0) {
                        $subModuleName = $extensionName . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($subModuleName);
index c4dd9c2..cc27ae9 100644 (file)
@@ -89,8 +89,8 @@ class ConfigurationController extends \TYPO3\CMS\Extensionmanager\Controller\Abs
        public function saveAction(array $config, $extensionKey) {
                /** @var $configurationUtility \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility */
                $configurationUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility');
-               $currentFullConfiguration = $configurationUtility->getCurrentConfiguration($extensionKey);
-               $newConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($currentFullConfiguration, $config);
+               $newConfiguration = $configurationUtility->getCurrentConfiguration($extensionKey);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($newConfiguration, $config);
                $configurationUtility->writeConfiguration(
                        $configurationUtility->convertValuedToNestedConfiguration($newConfiguration),
                        $extensionKey
index 759c87f..dec11e6 100644 (file)
@@ -64,10 +64,12 @@ class ConfigurationItemRepository {
                        $configuration = $this->mergeWithExistingConfiguration($defaultConfiguration, $extensionKey);
                        $hierarchicConfiguration = array();
                        foreach ($configuration as $configurationOption) {
-                               $hierarchicConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(
-                                       $this->buildConfigurationArray($configurationOption, $extensionKey),
+                               $originalConfiguration = $this->buildConfigurationArray($configurationOption, $extensionKey);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
+                                       $originalConfiguration,
                                        $hierarchicConfiguration
                                );
+                               $hierarchicConfiguration = $originalConfiguration;
                        }
 
                        // Flip category array as it was merged the other way around
@@ -84,7 +86,8 @@ class ConfigurationItemRepository {
                        }
                        unset($tempConfiguration);
 
-                       $resultArray = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($hierarchicConfiguration, $metaInformation);
+                        \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($hierarchicConfiguration, $metaInformation);
+                       $resultArray = $hierarchicConfiguration;
                }
 
                return $resultArray;
@@ -183,8 +186,8 @@ class ConfigurationItemRepository {
                foreach ($flatExtensionConfig as $key => $value) {
                        $valuedCurrentExtensionConfig[$key]['value'] = $value;
                }
-               $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($defaultConfiguration, $valuedCurrentExtensionConfig);
-               return $configuration;
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($defaultConfiguration, $valuedCurrentExtensionConfig);
+               return $defaultConfiguration;
        }
 
        /**
index a56cdb6..120c06d 100644 (file)
@@ -81,15 +81,15 @@ class ConfigurationUtility implements \TYPO3\CMS\Core\SingletonInterface {
         * @return array
         */
        public function getCurrentConfiguration($extensionKey) {
-               $defaultConfiguration = $this->getDefaultConfigurationFromExtConfTemplateAsValuedArray($extensionKey);
+               $mergedConfiguration = $this->getDefaultConfigurationFromExtConfTemplateAsValuedArray($extensionKey);
                $currentExtensionConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]);
                $currentExtensionConfig = is_array($currentExtensionConfig) ? $currentExtensionConfig : array();
                $currentExtensionConfig = $this->convertNestedToValuedConfiguration($currentExtensionConfig);
-               $currentFullConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(
-                       $defaultConfiguration,
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
+                       $mergedConfiguration,
                        $currentExtensionConfig
                );
-               return $currentFullConfiguration;
+               return $mergedConfiguration;
        }
 
        /**
index 530f498..888201d 100644 (file)
@@ -440,5 +440,4 @@ $tca = array(
        ),
 );
 
-
-return \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($GLOBALS['TCA']['sys_file_metadata'], $tca);
+return array_replace_recursive($GLOBALS['TCA']['sys_file_metadata'], $tca);
index 88abda3..f5894cc 100644 (file)
@@ -60,7 +60,7 @@ class PaginateController extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetCont
         */
        public function initializeAction() {
                $this->objects = $this->widgetConfiguration['objects'];
-               $this->configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->configuration, $this->widgetConfiguration['configuration'], TRUE);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->configuration, $this->widgetConfiguration['configuration'], FALSE);
                $this->numberOfObjects = count($this->objects);
                $this->numberOfPages = ceil($this->numberOfObjects / (integer) $this->configuration['itemsPerPage']);
        }
index 84048fe..1a3a789 100644 (file)
@@ -52,7 +52,7 @@ class PaginateController extends \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetCont
         */
        public function initializeAction() {
                $this->objects = $this->widgetConfiguration['objects'];
-               $this->configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->configuration, $this->widgetConfiguration['configuration'], TRUE);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->configuration, $this->widgetConfiguration['configuration'], FALSE);
                $this->numberOfPages = ceil(count($this->objects) / (integer) $this->configuration['itemsPerPage']);
                $this->maximumNumberOfLinks = (integer) $this->configuration['maximumNumberOfLinks'];
        }
index 9912e3f..b0cbda2 100644 (file)
@@ -98,7 +98,8 @@ class FormController {
                                /** @var $typoScriptParser \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */
                                $typoScriptParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
                                $typoScriptParser->parse($bodytext);
-                               $mergedTypoScript = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule((array) $typoScriptParser->setup, (array) $typoScript);
+                               $mergedTypoScript = (array)$typoScriptParser->setup;
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($mergedTypoScript, (array)$typoScript);
                                // Disables content elements since TypoScript is handled that could contain insecure settings:
                                $mergedTypoScript[\TYPO3\CMS\Form\Domain\Factory\TypoScriptFactory::PROPERTY_DisableContentElement] = TRUE;
                        }
index 371685a..af28b3a 100644 (file)
@@ -272,8 +272,8 @@ class WizardView extends \TYPO3\CMS\Form\View\Wizard\AbstractWizardView {
        protected function loadLocalization() {
                $wizardLabels = $GLOBALS['LANG']->includeLLFile('EXT:form/Resources/Private/Language/locallang_wizard.xlf', FALSE, TRUE);
                $controllerLabels = $GLOBALS['LANG']->includeLLFile('EXT:form/Resources/Private/Language/locallang_controller.xlf', FALSE, TRUE);
-               $labels = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($controllerLabels, $wizardLabels);
-               $this->pageRenderer->addInlineLanguageLabelArray($labels['default']);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($controllerLabels, $wizardLabels);
+               $this->pageRenderer->addInlineLanguageLabelArray($controllerLabels['default']);
        }
 
        /**
index bc97ab5..9302080 100644 (file)
@@ -5450,7 +5450,9 @@ class ContentObjectRenderer {
                                switch ($type) {
                                        case 'gp':
                                                // Merge GET and POST and get $key out of the merged array
-                                               $retVal = $this->getGlobal($key, GeneralUtility::array_merge_recursive_overrule(GeneralUtility::_GET(), GeneralUtility::_POST()));
+                                               $getPostArray = GeneralUtility::_GET();
+                                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($getPostArray, GeneralUtility::_POST());
+                                               $retVal = $this->getGlobal($key, $getPostArray);
                                                break;
                                        case 'tsfe':
                                                $retVal = $this->getGlobal('TSFE|' . $key);
@@ -6504,9 +6506,9 @@ class ContentObjectRenderer {
                        $newQueryArray = $currentQueryArray;
                }
                if ($forceOverruleArguments) {
-                       $newQueryArray = GeneralUtility::array_merge_recursive_overrule($newQueryArray, $overruleQueryArguments);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments);
                } else {
-                       $newQueryArray = GeneralUtility::array_merge_recursive_overrule($newQueryArray, $overruleQueryArguments, TRUE);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments, FALSE);
                }
                return GeneralUtility::implodeArrayForUrl('', $newQueryArray, '', FALSE, TRUE);
        }
index 17cdafb..7698dfc 100644 (file)
@@ -2046,7 +2046,7 @@ class TypoScriptFrontendController {
                                $realGet = array();
                        }
                        // Merge new values on top:
-                       $realGet = GeneralUtility::array_merge_recursive_overrule($realGet, $GET_VARS);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($realGet, $GET_VARS);
                        // Write values back to $_GET:
                        \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset($realGet);
                        // Setting these specifically (like in the init-function):
@@ -2370,7 +2370,7 @@ class TypoScriptFrontendController {
                                        }
                                        // override it with the page/type-specific "config."
                                        if (is_array($this->pSetup['config.'])) {
-                                               $this->config['config'] = GeneralUtility::array_merge_recursive_overrule($this->config['config'], $this->pSetup['config.']);
+                                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->config['config'], $this->pSetup['config.']);
                                        }
                                        if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
                                                $this->config['config']['typolinkCheckRootline'] = TRUE;
@@ -2419,8 +2419,9 @@ class TypoScriptFrontendController {
                }
                // Merge GET with defaultGetVars
                if (!empty($this->config['config']['defaultGetVars.'])) {
-                       $modifiedGetVars = GeneralUtility::array_merge_recursive_overrule(\TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']), GeneralUtility::_GET());
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset($modifiedGetVars);
+                       $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, GeneralUtility::_GET());
+                       GeneralUtility::_GETset($modifiedGetVars);
                }
                // Hook for postProcessing the configuration array
                if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
@@ -4642,7 +4643,7 @@ if (version == "n3") {
                        if ($this->lang !== 'default' && isset($tempLL[$language])) {
                                // Merge current language labels onto labels from previous language
                                // This way we have a label with fall back applied
-                               $localLanguage[$this->lang] = GeneralUtility::array_merge_recursive_overrule($localLanguage[$this->lang], $tempLL[$language], FALSE, FALSE);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($localLanguage[$this->lang], $tempLL[$language], TRUE, FALSE);
                        }
                }
 
index cd512f4..62464cc 100644 (file)
@@ -291,7 +291,9 @@ class AbstractPlugin {
        public function pi_setPiVarDefaults() {
                if (isset($this->conf['_DEFAULT_PI_VARS.']) && is_array($this->conf['_DEFAULT_PI_VARS.'])) {
                        $this->conf['_DEFAULT_PI_VARS.'] = $this->applyStdWrapRecursive($this->conf['_DEFAULT_PI_VARS.']);
-                       $this->piVars = GeneralUtility::array_merge_recursive_overrule($this->conf['_DEFAULT_PI_VARS.'], is_array($this->piVars) ? $this->piVars : array());
+                       $tmp = $this->conf['_DEFAULT_PI_VARS.'];
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($tmp, is_array($this->piVars) ? $this->piVars : array());
+                       $this->piVars = $tmp;
                }
        }
 
@@ -375,7 +377,8 @@ class AbstractPlugin {
                if (is_array($this->piVars) && is_array($overrulePIvars) && !$clearAnyway) {
                        $piVars = $this->piVars;
                        unset($piVars['DATA']);
-                       $overrulePIvars = GeneralUtility::array_merge_recursive_overrule($piVars, $overrulePIvars);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($piVars, $overrulePIvars);
+                       $overrulePIvars = $piVars;
                        if ($this->pi_autoCacheEn) {
                                $cache = $this->pi_autoCache($overrulePIvars);
                        }
index 61270d0..7a111c9 100644 (file)
@@ -409,7 +409,8 @@ class LanguageService {
                if (is_array($localLanguage) && count($localLanguage)) {
                                // it depends on, whether we should return the result or set it in the global $LOCAL_LANG array
                        if ($setGlobal) {
-                               $globalLanguage = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule((array) $GLOBALS['LOCAL_LANG'], $localLanguage);
+                               $globalLanguage = (array)$GLOBALS['LOCAL_LANG'];
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($globalLanguage, $localLanguage);
                        } else {
                                $globalLanguage = $localLanguage;
                        }
@@ -417,7 +418,7 @@ class LanguageService {
                        $lFileRef = $this->localizedFileRef($fileRef);
                        if ($lFileRef && (string) $globalLanguage[$this->lang] == 'EXT') {
                                $localLanguage = $this->readLLfile($lFileRef);
-                               $globalLanguage = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($globalLanguage, $localLanguage);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($globalLanguage, $localLanguage);
                        }
                                // Merge local onto default
                        if ($mergeLocalOntoDefault && $this->lang !== 'default' && is_array($globalLanguage[$this->lang]) && is_array($globalLanguage['default'])) {
@@ -457,7 +458,7 @@ class LanguageService {
                        if ($this->lang !== 'default' && isset($tempLL[$language])) {
                                        // Merge current language labels onto labels from previous language
                                        // This way we have a labels with fall back applied
-                               $localLanguage[$this->lang] = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($localLanguage[$this->lang], $tempLL[$language], FALSE, FALSE);
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($localLanguage[$this->lang], $tempLL[$language], TRUE, FALSE);
                        }
                }
                return $localLanguage;
index f482c07..afcdc98 100644 (file)
@@ -345,7 +345,7 @@ class ValidatorTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
                $modTs = $modTs['properties'];
                $overrideTs = $tsConfig['mod.']['tx_linkvalidator.'];
                if (is_array($overrideTs)) {
-                       $modTs = GeneralUtility::array_merge_recursive_overrule($modTs, $overrideTs);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($modTs, $overrideTs);
                }
                return $modTs;
        }
index c3f0271..aee8b7f 100644 (file)
@@ -103,7 +103,13 @@ abstract class RteHtmlAreaApi {
                // Localization array must be initialized here
                if ($this->relativePathToLocallangFile) {
                        if ($this->htmlAreaRTE->is_FE()) {
-                               $this->LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->LOCAL_LANG, \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile('EXT:' . $this->extensionKey . '/' . $this->relativePathToLocallangFile, $this->htmlAreaRTE->language));
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
+                                       $this->LOCAL_LANG,
+                                       \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile(
+                                               'EXT:' . $this->extensionKey . '/' . $this->relativePathToLocallangFile,
+                                               $this->htmlAreaRTE->language
+                                       )
+                               );
                        } else {
                                $LANG->includeLLFile('EXT:' . $this->extensionKey . '/' . $this->relativePathToLocallangFile);
                        }
index bdd1b93..b2b2d59 100644 (file)
@@ -1109,7 +1109,9 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
                foreach ($labelsArray as $labels => $subArray) {
                        $LOCAL_LANG = GeneralUtility::readLLfile('EXT:' . $this->ID . '/htmlarea/locallang_' . $labels . '.xlf', $this->language, 'utf-8');
                        if (!empty($LOCAL_LANG[$this->language])) {
-                               $LOCAL_LANG[$this->language] = GeneralUtility::array_merge_recursive_overrule($LOCAL_LANG['default'], $LOCAL_LANG[$this->language], FALSE, FALSE);
+                               $mergedLocalLang = $LOCAL_LANG['default'];
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($mergedLocalLang, $LOCAL_LANG[$this->language], TRUE, FALSE);
+                               $LOCAL_LANG[$this->language] = $mergedLocalLang;
                        } else {
                                $LOCAL_LANG[$this->language] = $LOCAL_LANG['default'];
                        }
@@ -1180,13 +1182,14 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
         * @todo Define visibility
         */
        public function buildJSLangArray($plugin) {
-               $LOCAL_LANG = FALSE;
                $extensionKey = is_object($this->registeredPlugins[$plugin]) ? $this->registeredPlugins[$plugin]->getExtensionKey() : $this->ID;
                $LOCAL_LANG = GeneralUtility::readLLfile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $plugin . '/locallang.xlf', $this->language, 'utf-8', 1);
                $JSLanguageArray = 'HTMLArea.I18N["' . $plugin . '"] = new Object();' . LF;
                if (is_array($LOCAL_LANG)) {
                        if (!empty($LOCAL_LANG[$this->language])) {
-                               $LOCAL_LANG[$this->language] = GeneralUtility::array_merge_recursive_overrule($LOCAL_LANG['default'], $LOCAL_LANG[$this->language], FALSE, FALSE);
+                               $defaultLocalLang = $LOCAL_LANG['default'];
+                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($defaultLocalLang, $LOCAL_LANG[$this->language], TRUE, FALSE);
+                               $LOCAL_LANG[$this->language] = $defaultLocalLang;
                        } else {
                                $LOCAL_LANG[$this->language] = $LOCAL_LANG['default'];
                        }
index d850eb0..1122d10 100644 (file)
@@ -215,7 +215,8 @@ class User {
                                                }
                                                if (is_array($mArray)) {
                                                        if ($v['merge']) {
-                                                               $v = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($mArray, $v);
+                                                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($mArray, $v);
+                                                               $v = $mArray;
                                                        } else {
                                                                $v = $mArray;
                                                        }
index 99b2f61..e211a80 100644 (file)
@@ -626,7 +626,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                if (count($this->submittedData) > 0) {
                        // If some data was already submitted, use it to override
                        // existing data
-                       $taskInfo = GeneralUtility::array_merge_recursive_overrule($taskInfo, $this->submittedData);
+                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($taskInfo, $this->submittedData);
                }
                // Get the extra fields to display for each task that needs some
                $allAdditionalFields = array();
index a693bc7..ac88428 100644 (file)
@@ -532,7 +532,8 @@ class CommandMap {
         * @return void
         */
        protected function mergeToTop(array $commandMap) {
-               $this->commandMap = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($commandMap, $this->commandMap);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($commandMap, $this->commandMap);
+               $this->commandMap = $commandMap;
        }
 
        /**
@@ -542,7 +543,7 @@ class CommandMap {
         * @return void
         */
        protected function mergeToBottom(array $commandMap) {
-               $this->commandMap = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->commandMap, $commandMap);
+               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->commandMap, $commandMap);
        }
 
        /**