Bug #23866

layered menus generate "too much recursion javascript-error"

Added by Andreas Philippi over 6 years ago. Updated about 4 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2010-10-28
Due date:
% Done:

0%

TYPO3 Version:
4.4
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Under certain conditions, when using TMENU_LAYERS the layers containing the navigation items get non-unique IDs.

That happens because of a unique-ID-generating-function making uses microtime... which on these specific server seems not to provide unique IDs.

We noticed this error after migrating several sites in a virtualized environment on a much faster machine.

To correct this error we used the php-function uniqid to give us unique ids.

To correct this error we proceeded this way:

Locate the file /typo3/sysext/cms/tslib/media/scripts/tmenu_layers.php

Search for the string: substr(md5(microtime()),0,6);

Replace the string using: str_replace('.','',uniqid('',true));
(issue imported from #M16165)


Related issues

Related to Core - Bug #21388: typo3temp got filled with thousands of javascript_* files Rejected 2009-10-28
Related to Core - Bug #24367: changes in tmenu_layers.php broke TMENU Rejected 2010-12-19
Related to Core - Task #46358: Separate ext:statictemplates code from core Resolved 2013-03-16

History

#1 Updated by Chris topher over 6 years ago

Hi Andreas,

the code you mention was already changed in #21388.
TYPO3 4.4.5 will ship with the new version. You can see the changeset here:
http://forge.typo3.org/projects/typo3v4-core/repository/revisions/9037/diff/branches/TYPO3_4-4/typo3/sysext/cms/tslib/media/scripts/tmenu_layers.php

Does this solve the problem?

#2 Updated by Jorgo S. over 6 years ago

#3 Updated by Chris topher over 6 years ago

@ Jorgo: The files in typo3/sysext/statictemplates/media/scripts/ were not changed until now.
Please send a reminder for the follow up which Jigal posted to #21388 in Core List.

#4 Updated by Jorgo S. over 6 years ago

I'm not suscribed to that list and the one time I tried to contribute something I was instantly reprimanded about some rules I don't know anything about.

#5 Updated by Andreas Philippi over 6 years ago

Hi,

I applied the code changes from here
http://forge.typo3.org/projects/typo3v4-core/repository/revisions/9037/diff/branches/TYPO3_4-4/typo3/sysext/cms/tslib/media/scripts/tmenu_layers.php

It seems to work.
Since this error did not occur every time I cannot be 100% sure. If it happens again I will let you know.

#6 Updated by Mittwald CM over 6 years ago

Hi @all,

as mentioned in 0012376 TYPO3 must offer a management of cached files and/or temporary files.

All javascript files in typo3temp are not temporary files but actually cached files: If they still lay around there they will be used many times.

To make a clean bugfix it must be choosen whether these files are temporary or cached files.
Next point is to write functions for managing temporary files, which can only be once used and will be deleted on some trigger event, and functions for cached files which may be used many times and must have also an actual unique id.

The bugfix of 0012376 is just a hot and dirty and slow bugfix. TYPO3 must offer routines for managing files.

best regards

#7 Updated by Torben Hansen over 6 years ago

Since 0012376 got into the CORE (TYPO3 4.4.5), the TMENU_LAYERS of one of my TYPO3 sites donĀ“t work anymore. I get exactly the same error (Too much recursion) as described in this bugreport. The menu-DIVs do not have unique IDs, which leads to this error.

The Bugfix in 0012376 works fine with menus having one sublevel. If you have 4 sublevels, it does not work correctly, since "substr(md5('gl' . serialize($this->mconf)), 0, 6)" does not produce unique results.

The approach from this bugreport using PHP uniqid works great and every menu has its unique ID.

#8 Updated by Andreas Philippi over 6 years ago

I can confirm what Torben Hansen noticed:

I created 4 sublevels and the JS-errors came back :( .... I had to switch back to str_replace('.','',uniqid('',true));

#9 Updated by Helmut Hummel over 6 years ago

Can anyone post a simple TypoScript snippet to reproduce the problem?

Thanks.

#10 Updated by Torben Hansen over 6 years ago

I have no "simple" 4-level TMENU_LAYER, but you can try this one:

---[ start menu ]---

page.includeLibs.tmenu_layers = EXT:cms/tslib/media/scripts/tmenu_layers.php
lib.menu= HMENU
lib.menu {

1 = TMENU_LAYERS
1 {
layerStyle = position:absolute;VISIBILITY:hidden;vertical-align:middle;align:center;width: 150px;
lockPosition = x
relativeToParentLayer=1
relativeToTriggerItem=1
topOffset=20
leftOffset=0
hideMenuWhenNotOver = 50
hideMenuTimer = 70
expAll=1
wrap = <table border="0" cellspacing="0" cellpadding="0"><tr>|</tr></table>
NO {
allWrap = <td class="menu_level1"> |</td>
ATagParams = class="menu_link_level1"
}
ACT = 1
ACT {
allWrap = <td class="menu_level1"> |</td>
ATagParams = class="menu_link_level1"
}
IFSUB = 1
IFSUB {
allWrap = <td class="menu_level1"> |</td>
ATagParams = class="menu_link_level1"
}
}
2 = TMENU_LAYERS
2 {
layerStyle = position:absolute;VISIBILITY:hidden;
lockPosition = x
relativeToParentLayer=2
relativeToTriggerItem=2
topOffset=0
leftOffset=150
hideMenuWhenNotOver = 50
hideMenuTimer = 70
expAll=1
wrap = <table border="0" cellspacing="0" cellpadding="0">|</table>
NO {
allWrap = <tr><td class="menu_level2"> |</td></tr>
ATagParams = class="menu_link_level2"
}
ACT = 1
ACT {
allWrap = <tr><td class="menu_level2"> |</td></tr>
ATagParams = class="menu_link_level2_act"
}
IFSUB = 1
IFSUB {
allWrap = <tr><td class="menu_level2"> |</td></tr>
ATagParams = class="menu_link_level2"
}
IFSUB.allStdWrap.insertData = 1
}
3 = TMENU_LAYERS
3 {
layerStyle = position:absolute;VISIBILITY:hidden;
lockPosition = x
relativeToParentLayer=2
relativeToTriggerItem=2
topOffset=0
leftOffset=150
hideMenuWhenNotOver = 50
hideMenuTimer = 70
expAll=1
wrap = <table border="0" cellspacing="0" cellpadding="0">|</table>
NO {
allWrap = <tr><td class="menu_level2"> |</td></tr>
ATagParams = class="menu_link_level2"
}
NO.allStdWrap.insertData = 1
ACT = 1
ACT {
allWrap = <tr><td class="menu_level2"> |</td></tr>
ATagParams = class="menu_link_level2_act"
}
ACT.allStdWrap.insertData = 1
IFSUB = 1
IFSUB {
allWrap = <tr><td class="menu_level2"> |</td></tr>
ATagParams = class="menu_link_level2"
}
IFSUB.allStdWrap.insertData = 1
}
4 = TMENU_LAYERS
4 {
layerStyle = position:absolute;VISIBILITY:hidden;
lockPosition = x
relativeToParentLayer=3
relativeToTriggerItem=3
topOffset=0
leftOffset=150
expAll=1
wrap = <table border="0" cellspacing="0" cellpadding="0">|</table>
NO {
allWrap = <tr><td class="menu_level3"> |</td></tr>
ATagParams = class="menu_link_level2"
}
NO.allStdWrap.insertData = 1
ACT = 1
ACT {
allWrap = <tr><td class="menu_level3"> |</td></tr>
ATagParams = class="menu_link_level2_act"
}
ACT.allStdWrap.insertData = 1
}

}

---[ end menu ]---

Create a menu that has 4 levels of submenus. Create several submenu and sub-submenu-items and validate the HTML output using W3C validation service. It should report you, that some IDs are already defined. If not, try creating more submenu-items

I could not reproduce the javascript-error in my testinstallation. I have a customer-installation, where the customer has 450+ pages in his menu. There the javascript-error occours.

#11 Updated by Sebastien L almost 6 years ago

This string is causing us troubles in some of our sites with many levels of submenu either with tmenu_layers than gmenu_layers. The problem is always the same when it happens, an id produced by the string "substr(md5(microtime()),0,6);" is not unique and two menu elements has the same id which ends with javascript errors and strange menu behaviors. Everytime, we edit the core to switch this string using "str_replace('.','',uniqid('',true));" and it corrects the problem.

Is it possible to fix this problem in future versions?

Thanks!

#12 Updated by Christian Kuhn about 4 years ago

  • Category deleted (Communication)
  • Status changed from Needs Feedback to Rejected
  • Target version deleted (0)

With 6.1 issue #46358, the _layers menus where moved to statictemplates, and statictemplates was removed from core afterwards. This issue won't be solved in the core anymore.

Also available in: Atom PDF