[MAGNOLIA-4582] DHTMLUtil.findVariable() flawed Created: 13/Oct/12 Updated: 17/Mar/21 Resolved: 17/Mar/21 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | admininterface |
| Affects Version/s: | 4.5.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Jonas Petersen [X] (Inactive) | Assignee: | Unassigned |
| Resolution: | Inactive | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
| Description |
|
I had the case where the "AdminCentral"-button in the main edit bar would sometimes refuse to work. It would do what I expect for a while (open the current node in the website tree of the admin central) but then "suddenly" after some navigating through the website it would stop working, even after further navigating. Only reopening the website in a new window would fix it (for a while). Some debugging showed an UmbrellaException with a "stack overflow" when it happened. Doing some gwt debugging I found a "too much recursion" exception. A while later I found that DHTMLUtil.findVariable() is in a recursive loop when it happens. But why? Because it's recursive and is calling itself with this.findVariable(name, current.opener) and current.opener is in this case equal to current (and current is equal to window). findVariable: function(name, current){
current = current?current:window;
if(current[name]!=null)
return current[name];
if(current.top != current)
return this.findVariable(name, current.top);
if(current.opener != null)
return this.findVariable(name, current.opener);
return null;
}
This means window == window.opener. But why? Try this: <a href="#" onclick="window.open(window.location.href, '_self')">CLICK</a> We have some jQuery that is injecting links of this kind into the page at several places. I guess that's valid, but it produces window == window.opener. (Btw. it also happens when you create links to other locations than window.location.href, it is just a quick example to reproduce.) My workaround for now is putting this in the header: if (window.opener == window) { window.opener = null; } But I guess the solution woud be replacing if(current.opener != null) return this.findVariable(name, current.opener); with if(current.opener != null && current.opener != current) return this.findVariable(name, current.opener); in findVariable() of DHTMLUtil.js. (I'm not sure about findVariable(name, current.top) it might be good to add it there to.) |