Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-4582

DHTMLUtil.findVariable() flawed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Inactive
    • Neutral
    • None
    • 4.5.5
    • admininterface
    • None

    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.)

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              jpetersen Jonas Petersen [X] (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD