[BUGFIX] register['count_menuItems'] wrong, if filtered by userfunc
authorBjoern Pedersen <bjoern.pedersen@frm2.tum.de>
Wed, 6 Apr 2011 07:47:40 +0000 (09:47 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 19 Apr 2011 21:23:28 +0000 (23:23 +0200)
the register['count_menuItems'] is set, before a possible userfunc filters the menu items -> wrong register value.

Solution: change call sequence

Change-Id: I0425d04602110a5f6707022cb88077cc75e81f02
Resolves: #25405
Releases: 4.6, 4.5
Reviewed-on: http://review.typo3.org/1471
Reviewed-by: Tolleiv Nietsch
Reviewed-by: Frederic Gaus
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/cms/tslib/class.tslib_menu.php

index 56b22f0..a09c736 100644 (file)
@@ -598,12 +598,12 @@ class tslib_menu {
                                                        $kw = isset($this->conf['special.']['setKeywords.'])
                                                                ? $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.'])
                                                                : $this->conf['special.']['setKeywords'];
-                                               } else {
-                                                       $value_rec=$this->sys_page->getPage($value);    // The page record of the 'value'.
+                                               } else {
+                                                       $value_rec=$this->sys_page->getPage($value);    // The page record of the 'value'.
 
                                                        $kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
                                                        $kw = trim(tslib_cObj::keywords($value_rec[$kfieldSrc]));               // keywords.
-                                               }
+                                               }
 
                                                $mode = $this->conf['special.']['mode'];        // *'auto', 'manual', 'tstamp'
                                                switch($mode)   {
@@ -899,13 +899,14 @@ class tslib_menu {
                                        $c++;
                                }
                        }
-                               // Setting number of menu items
-                       $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
                                //      Passing the menuArr through a user defined function:
                        if ($this->mconf['itemArrayProcFunc'])  {
                                if (!is_array($this->parentMenuArr)) {$this->parentMenuArr=array();}
                                $this->menuArr = $this->userProcess('itemArrayProcFunc',$this->menuArr);
                        }
+                               // Setting number of menu items
+                       $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
+
                        $this->hash = md5(serialize($this->menuArr).serialize($this->mconf).serialize($this->tmpl->rootLine).serialize($this->MP_array));
 
                                // Get the cache timeout:
@@ -1932,7 +1933,7 @@ class tslib_tmenu extends tslib_menu {
                if (isset($this->I['val'][$pref . 'Wrap'])) {
                        return $this->tmpl->wrap($res . $processedPref, $this->I['val'][$pref . 'Wrap']);
                } else {
-                        return $res . $processedPref;
+                       return $res . $processedPref;
                }
        }