[TASK] joinTSarrays() is replaced by array_replace_recursive() 00/26500/3
authorMichiel Roos <michiel@maxserv.nl>
Thu, 19 Dec 2013 19:07:51 +0000 (20:07 +0100)
committerErnesto Baschny <ernst@cron-it.de>
Mon, 30 Dec 2013 17:21:46 +0000 (18:21 +0100)
\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::joinTSarrays is
replaced by the PHP native array_replace_recursive() (added in PHP 5.3.0)
which does exactly the same and is twice as fast.

Usage of $cObj->joinTSarrays() is deprecated.

Change-Id: I748270a192bccc89927e0d6b82a1f405959b2209
Resolves: #54520
Releases: 6.2
Reviewed-on: https://review.typo3.org/26500
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
typo3/sysext/css_styled_content/Classes/Controller/CssStyledContentController.php
typo3/sysext/form/Classes/Domain/Factory/TypoScriptFactory.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 90ec152..abe4dea 100644 (file)
@@ -472,7 +472,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                }
                // Specific configuration for the chosen rendering method
                if (is_array($conf['rendering.'][$renderMethod . '.'])) {
-                       $conf = $this->cObj->joinTSarrays($conf, $conf['rendering.'][$renderMethod . '.']);
+                       $conf = array_replace_recursive($conf, $conf['rendering.'][$renderMethod . '.']);
                }
                // Image or Text with Image?
                if (is_array($conf['text.'])) {
@@ -504,7 +504,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                        $fallbackRenderMethod = $this->cObj->cObjGetSingle($conf['fallbackRendering'], $conf['fallbackRendering.']);
                }
                if ($fallbackRenderMethod && is_array($conf['rendering.'][$fallbackRenderMethod . '.'])) {
-                       $conf = $this->cObj->joinTSarrays($conf, $conf['rendering.'][$fallbackRenderMethod . '.']);
+                       $conf = array_replace_recursive($conf, $conf['rendering.'][$fallbackRenderMethod . '.']);
                }
                // Set the accessibility mode which uses a different type of markup, used 4.7+
                $accessibilityMode = FALSE;
index 7cc7516..3fe2f56 100644 (file)
@@ -123,7 +123,7 @@ class TypoScriptFactory implements \TYPO3\CMS\Core\SingletonInterface {
                                $oldArguments = $arguments;
                                list($class, $arguments) = $typoscriptParser->getVal($key, $GLOBALS['TSFE']->tmpl->setup);
                                if (is_array($oldArguments) && count($oldArguments)) {
-                                       $arguments = $this->getLocalConentObject()->joinTSarrays($arguments, $oldArguments);
+                                       $arguments = array_replace_recursive($arguments, $oldArguments);
                                }
                                $GLOBALS['TT']->incStackPointer();
                                $contentObject = array(
index 90529aa..bc97ab5 100644 (file)
@@ -723,7 +723,7 @@ class ContentObjectRenderer {
                                $old_conf = $conf;
                                list($name, $conf) = $cF->getVal($key, $GLOBALS['TSFE']->tmpl->setup);
                                if (is_array($old_conf) && count($old_conf)) {
-                                       $conf = $this->joinTSarrays($conf, $old_conf);
+                                       $conf = array_replace_recursive($conf, $old_conf);
                                }
                                // Getting the cObject
                                $GLOBALS['TT']->incStackPointer();
@@ -6879,7 +6879,7 @@ class ContentObjectRenderer {
                        $old_conf = $confArr[$prop . '.'];
                        list($name, $conf) = $cF->getVal($key, $GLOBALS['TSFE']->tmpl->setup);
                        if (is_array($old_conf) && count($old_conf)) {
-                               $conf = $this->joinTSarrays($conf, $old_conf);
+                               $conf = array_replace_recursive($conf, $old_conf);
                        }
                        $confArr[$prop . '.'] = $conf;
                }
@@ -6893,19 +6893,12 @@ class ContentObjectRenderer {
         * @param array $old_conf TypoScript property array, the "overlay
         * @return array The resulting array
         * @see mergeTSRef(), tx_tstemplatestyler_modfunc1::joinTSarrays()
+        * @deprecated since 6.2, will be removed in two versions, use array_replace_recursive() instead
         * @todo Define visibility
         */
        public function joinTSarrays($conf, $old_conf) {
-               if (is_array($old_conf)) {
-                       foreach ($old_conf as $key => $val) {
-                               if (is_array($val)) {
-                                       $conf[$key] = $this->joinTSarrays($conf[$key], $val);
-                               } else {
-                                       $conf[$key] = $val;
-                               }
-                       }
-               }
-               return $conf;
+               GeneralUtility::logDeprecatedFunction();
+               return array_replace_recursive($conf, $old_conf);
        }
 
        /**