Bug #36719

Javascript in header without script tags

Added by Markus Kappe about 1 year ago. Updated about 1 month ago.

Status:Resolved Start date:2012-04-30
Priority:Must have Due date:
Assignee:Ernesto Baschny % Done:

100%

Category:-
Target version:-
TYPO3 Version:4.6 Complexity:
PHP Version:
Votes: 4 (View)

Description

I am using TYPO3 4.6.8 and TMENU_LAYERS. On some pages (in my case the one with the indexed_search plugin) the JavaScript code (starting with GLV_) is displayed on the page. A quick look in the source showed, that the <script> tags were missing around the TMENU_LAYERS JS code. But only, when the cache is active. A &no_cache=1 in the url and the display looked OK.

In TYPO3 4.5.15 everything worked fine.

I did some research and found that: http://bugs.typo3.org/bug_view_advanced_page.php?bug_id=18513

And I think I found the error in the TYPO3 core:
In tslib_fe::INTincScript() disappeared the line

$this->JSCode = $this->additionalHeaderData['JSCode'];

(compared 4.5.15 with 4.6.8). I cannot see any meaning or intention behind that change, so I suppose this is the bug.

bug_36719.diff - Patch file (686 Bytes) Kurt Gusbeth, 2013-03-07 11:04

bug_36719.diff - Typo3 4.7.10 Patch (733 Bytes) Kurt Gusbeth, 2013-03-11 10:52

Associated revisions

Revision 772b102b
Added by Michael Stucki about 1 month ago

[BUGFIX] Javascript for TMENU_LAYERS and GMENU_LAYERS missing

If using TMENU_LAYERS/GMENU_LAYERS and (for example) indexed_search on
the same page, the JavaScript header tags are missing if the page is
loaded from the cache.

Resolves: #36719
Releases: 4.5, 4.6, 4.7, 6.0, 6.1
Change-Id: Icd52f68d2b9462360f0b9efd912d93d4b0c1048c
Reviewed-on: https://review.typo3.org/19263
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

Revision cf8336a3
Added by Michael Stucki about 1 month ago

[BUGFIX] Javascript for TMENU_LAYERS and GMENU_LAYERS missing

If using GMENU_LAYERS/TMENU_LAYERS and (for example) indexed_search on
the same page, the JavaScript header tags are missing if the page is
loaded from the cache.

Resolves: #36719
Releases: 4.5, 4.6, 4.7, 6.0, 6.1
Change-Id: Icd52f68d2b9462360f0b9efd912d93d4b0c1048c
Reviewed-on: https://review.typo3.org/19266
Reviewed-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

Revision 66dc994b
Added by Michael Stucki about 1 month ago

[BUGFIX] Javascript for TMENU_LAYERS and GMENU_LAYERS missing

If using GMENU_LAYERS/TMENU_LAYERS and (for example) indexed_search on
the same page, the JavaScript header tags are missing if the page is
loaded from the cache.

Resolves: #36719
Releases: 4.5, 4.6, 4.7, 6.0, 6.1
Change-Id: Icd52f68d2b9462360f0b9efd912d93d4b0c1048c
Reviewed-on: https://review.typo3.org/19262
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

Revision 7d6acfe2
Added by Michael Stucki about 1 month ago

[BUGFIX] Javascript for TMENU_LAYERS and GMENU_LAYERS missing

If using TMENU_LAYERS/GMENU_LAYERS and (for example) indexed_search on
the same page, the JavaScript header tags are missing if the page is
loaded from the cache.

Resolves: #36719
Releases: 4.5, 4.6, 4.7, 6.0, 6.1
Change-Id: Icd52f68d2b9462360f0b9efd912d93d4b0c1048c
Reviewed-on: https://review.typo3.org/19264
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

Revision 978d0bc8
Added by Michael Stucki about 1 month ago

[BUGFIX] Javascript for TMENU_LAYERS and GMENU_LAYERS missing

If using TMENU_LAYERS/GMENU_LAYERS and (for example) indexed_search on
the same page, the JavaScript header tags are missing if the page is
loaded from the cache.

Resolves: #36719
Releases: 4.5, 4.6, 4.7, 6.0, 6.1
Change-Id: Icd52f68d2b9462360f0b9efd912d93d4b0c1048c
Reviewed-on: https://review.typo3.org/19265
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

History

Updated by Sean Fulton about 1 year ago

REPOST:
We recently tried to upgrade a site from 4.5 to 4.6. We found that on pages with a tt_news container, a big chunk of navigation code gets ripped out of the page once it is cached, causing the pull-down navigational elements to appear on the upper-left corner of the screen.

This happens with tt_news 3.0.1 to 3.2.1 and only in Typo3 4.6. The menu elements appear when the cache is cleared, but on reload, the code is missing. What's interesting is that it appears the code is stored in the datase with the cached copy of the page, but is not sent to the browser on reload.

One of our developers reported that if you force the browser to clear its cache, the code will re-appear, but we have not been able to verify that in all browsers.

This is what appears after you clear the cache:

<script type="text/javascript">
/*<![CDATA[*/
<!--

function changeBGcolor(id,color) { //
if (document.getElementById && document.getElementById(id)) {
document.getElementById(id).style.background = color;
return true;
} else if (document.layers && document.layers[id]) {
document.layers[id].bgColor = color;
return true;
}
}

GLV_curLayerWidth["topnav1x"]=0;
GLV_curLayerHeight["topnav1x"]=0;
GLV_curLayerX["topnav1x"]=0;
GLV_curLayerY["topnav1x"]=0;
GLV_menuOn["topnav1x"] = null;
GLV_gap["topnav1x"]=1;
GLV_currentLayer["topnav1x"] = null;
GLV_currentROitem["topnav1x"] = null;
GLV_hasBeenOver["topnav1x"]=0;
GLV_doReset["topnav1x"]=false;
GLV_lastKey["topnav1x"] = "Menutopnav1x8";
GLV_onlyOnLoad["topnav1x"] = 0;
GLV_dontHideOnMouseUp["topnav1x"] = 0;
GLV_dontFollowMouse["topnav1x"] = 0;
GLV_date = new Date();
GLV_timeout["topnav1x"] = GLV_date.getTime();
GLV_timeoutRef["topnav1x"] = 3;
GLV_menuXY["topnav1x"] = new Array();
GLV_menuXY["topnav1x"]["Menutopnav1x0"] = new Array(0,0,"itemID085639d292","anchorID085639d292");
GLV_menuXY["topnav1x"]["Menutopnav1x1"] = new Array(72,24,"itemIDc4a051e098","anchorIDc4a051e098");
GLV_menuXY["topnav1x"]["Menutopnav1x2"] = new Array(143,48,"itemIDeeaab070dc","anchorIDeeaab070dc");
GLV_menuXY["topnav1x"]["Menutopnav1x3"] = new Array(287,72,"itemID72b188f9d0","anchorID72b188f9d0");
GLV_menuXY["topnav1x"]["Menutopnav1x4"] = new Array(362,96,"itemIDa4a8e66ce7","anchorIDa4a8e66ce7");
GLV_menuXY["topnav1x"]["Menutopnav1x5"] = new Array(502,120,"itemIDd3dc74c83c","anchorIDd3dc74c83c");
GLV_menuXY["topnav1x"]["Menutopnav1x6"] = new Array(633,144,"itemIDcf1ff8d4ba","anchorIDcf1ff8d4ba");
GLV_menuXY["topnav1x"]["Menutopnav1x7"] = new Array(741,168,"itemID5524f7cee1","anchorID5524f7cee1");
GLV_menuXY["topnav1x"]["Menutopnav1x8"] = new Array(846,192,"itemID8262b27a67","anchorID8262b27a67");

function GLtopnav1x_getMouse(e) {
if (GLV_menuOn["topnav1x"]!=null && !GLV_dontFollowMouse["topnav1x"]){

}
GL_mouseMoveEvaluate("topnav1x");
}
function GLtopnav1x_hideCode() {
GL_getObjCss("Menutopnav1x1").visibility = "hidden";
GL_getObjCss("Menutopnav1x2").visibility = "hidden";
GL_getObjCss("Menutopnav1x3").visibility = "hidden";
GL_getObjCss("Menutopnav1x6").visibility = "hidden";
GL_getObjCss("Menutopnav1x7").visibility = "hidden";
GL_getObjCss("Menutopnav1x8").visibility = "hidden";
}
function GLtopnav1x_doTop(WMid,id) {
var parentObject = GL_getObj(GLV_menuXY[WMid][id][2]);
var TI_width = parentObject.width;
var TI_height = parentObject.height;
var anchorObj = GL_getObj(GLV_menuXY[WMid][id][3]);
var TI_x = anchorObj.x;
var TI_y = anchorObj.y;

GLV_menuOn["topnav1x"].left = (TI_x+0)+"px";
GLV_menuOn["topnav1x"].top = (TI_y+24)+"px";
}
function GLtopnav1x_restoreMenu() {

}
function GLtopnav1x_resetSubMenus() {
var resetSubMenu=1;

return resetSubMenu;
}

GLV_timeout_pointers[GLV_timeout_count] = "topnav1x";
GLV_timeout_count++;
// -->
/*]]>*/
</script>

This is what appears after you reload the page (ie, once it has been cached).

<script type="text/javascript">
/*<![CDATA[*/
<!--

function changeBGcolor(id,color) { //
if (document.getElementById && document.getElementById(id)) {
document.getElementById(id).style.background = color;
return true;
} else if (document.layers && document.layers[id]) {
document.layers[id].bgColor = color;
return true;
}
}

// -->
/*]]>*/
</script>

Updated by Rafal Likus about 1 year ago

I have the same effect with JSmenu.
This is with properly generated page:

<script type="text/javascript" src="t3lib/jsfunc.menu.js"></script>

<script type="text/javascript">
    /*<![CDATA[*/
<!--

var JSmenub2df5 = new JSmenu(1,'JSmenub2df5Form');

And this after reload:
<script type="text/javascript" src="t3lib/jsfunc.menu.js"></script>

 var JSmenub2df5 = new JSmenu(1,'JSmenub2df5Form');

Adding mentioned line to typo3\sysext\cms\tslib\class.tslib_fe.php solved problem.

Updated by Jonas Götze 11 months ago

Hi,

same for me after update from 4.5.15 to 4.7.1, so this issue still exists in 4.7. Adding the line solved it for me too.

Regards

Updated by Stefan Galinski 11 months ago

Can you please open a review request with the one-liner? It's really easy... :-)

Tutorial:
http://wiki.typo3.org/Contribution_Walkthrough

Updated by Kurt Gusbeth 9 months ago

  • Target version set to 4.7.5

I have the same promblem with Typo3 4.7.4.
I can confirm it for "JSMENU" too.

Updated by Kurt Gusbeth 9 months ago

Note: the missing line is in the file typo3/sysext/cms/tslib/class.tslib_fe.php

Updated by Christian Geiselmann 9 months ago

I had the same issue with Typo3 4.7.1 after I started mounting frontend user login elements on several pages of my site (using the felogin extension).

Adding the mentioned line of code helped in my case, too.

Here some details for people facing the same problem:

In the class.tslib_fe.php in Typo3 4.5.15 the line in question is line 3217
In my Typo3 4.7.1 this became line 3200, after I had added it.

Or, in other words: replace

$this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS'];
$this->JSImgCode = $this->additionalHeaderData['JSImgCode'];

by

$this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS'];
$this->JSCode = $this->additionalHeaderData['JSCode'];
$this->JSImgCode = $this->additionalHeaderData['JSImgCode'];

And enjoy!

Christian Geiselmann

Updated by Christian Geiselmann 3 months ago

Hi Everybody,

I am coming back to this issue - and still unsolved Typo3 4.7 core bug - since after a core update (from 4.7.1 to 4.7.7) the same issue appeared on our site. - Funnily I did not remember that I had solved it, months ago, myself, and now asked our chief programmer to find out what the heck is this strange javascript code on top of pages with login forms. He googled the topic for a while and finally stumbled upon this bug report, including my own comment and advice. He solved the issue the same way I did months ago. But apparently, this will need to be done after every core update.

What could I possibly do to motivate the Typo3 community to fix the bug at its source?

Regards,
Christian Geiselmann

Updated by Wouter Wolters 3 months ago

Hi Christian,

There are several things you can do. You have already a working solution yourself.
So the best way is to push a patch to our reviewing system "Gerrit".
A guideline can be founr here: http://wiki.typo3.org/Contribution_Walkthrough_with_CommandLine

If this is not possible due to any reason, can you provide a patch file of the changes you made for the working solution?
Or send the complete changed file?

Greetz Wouter

Updated by Kurt Gusbeth 3 months ago

I have created a patch-file. Maybe this helps too.

Updated by Kurt Gusbeth 2 months ago

Maybe it is better to add an if-statement too...

Updated by Michael Stucki 2 months ago

Started investigation on it. The change was removed in 4e53925db0933d58fe40a2397dd246219c3d55f7.

Updated by Ernesto Baschny 2 months ago

  • Status changed from New to Accepted
  • Priority changed from Should have to Must have

Happens that TSFE->JSCode was "deprecated since 3.5" but was still being used by the core (exactly in GMENU_LAYERS and TMENU_LAYERS).

So it was removed in 4.6 without adapting the code of GMENU_LAYERS and TMENU_LAYERS.

Two solutions: Either put JSCode back in (also 4.7, 6.0, 6.1) and postpone the deprecation to a time when TMENU_LAYERS and GMENU_LAYERS are rewritten. Or do both at the same time.

Or an intermediate solution: Just put it back in the already released 4.6, 4.7, 6.0 and remove and rewrite the menu classes for 6.1.

Updated by Gerrit Code Review 2 months ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18948

Updated by Gerrit Code Review 2 months ago

Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at https://review.typo3.org/18949

Updated by Ernesto Baschny 2 months ago

I've added the reversing code as a review request for 4.6 and master. Please check out if this solves your problem.

Updated by Gerrit Code Review about 1 month ago

Patch set 1 for branch TYPO3_6-0 has been pushed to the review server.
It is available at https://review.typo3.org/19262

Updated by Michael Stucki about 1 month ago

I don't think we should add the deprecated code again. How about this approach? https://review.typo3.org/#/c/19262/

Btw. the fix is not needed in master anymore, since "statictemplates" have been removed entirely.

Updated by Michael Stucki about 1 month ago

  • Status changed from Under Review to Needs Feedback
  • Assignee set to Ernesto Baschny

Updated by Gerrit Code Review about 1 month ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at https://review.typo3.org/19263

Updated by Gerrit Code Review about 1 month ago

Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at https://review.typo3.org/19264

Updated by Gerrit Code Review about 1 month ago

Patch set 1 for branch TYPO3_4-5 has been pushed to the review server.
It is available at https://review.typo3.org/19265

Updated by Gerrit Code Review about 1 month ago

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19266

Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch TYPO3_6-0 has been pushed to the review server.
It is available at https://review.typo3.org/19262

Updated by Gerrit Code Review about 1 month ago

Patch set 3 for branch TYPO3_6-0 has been pushed to the review server.
It is available at https://review.typo3.org/19262

Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch TYPO3_4-7 has been pushed to the review server.
It is available at https://review.typo3.org/19263

Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch TYPO3_4-6 has been pushed to the review server.
It is available at https://review.typo3.org/19264

Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch TYPO3_4-5 has been pushed to the review server.
It is available at https://review.typo3.org/19265

Updated by Christian Kuhn about 1 month ago

how to reproduce
take a 4.7 instance
install statictemplates
install indexed_search
create a page "test"
create sub page 'main 1'
create sub page in 'main 1' called 'sub 1'
backend -> template -> info/modify -> chose "template green" in drop down -> "create template for a new site"
place content element "indexed search" on page "main 1"
view page in frontend in different (no be log in) browser
reload page once -> you should see some garbage top left (this is JS code of the gmenu_layer)
apply patch from https://review.typo3.org/#/c/19263/
clear cache
call page twice again -> no more garbage and the menu is working (showing sub page 1 on hover)

Updated by Michael Stucki about 1 month ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF