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

Request stored in WebContext is not updated after a forward/includes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 4.0
    • 3.6.1
    • core
    • None

      The request stored in WebContext by the ContextFilter is never updated, and may miss parameters added by a forward.

      For example, using a virtualUri filter in order to forward from /test/param.html to test..html?x=param I get different results when I do:
      request.getParam("x") --> "param"
      ((WebContext) MgnlContext.getInstance()).getRequest().getParam("x") --> null

      this also means that paragraphs never see parameters added by a forward, since the paragraph renderer gets the request from the context. Looks like a regression from 3.5, since I was using this kind of forwards and they stopped working after upgrading to 3.6 (not sure about which change in the filters has caused this).

      I would propose to fix it by updating the request stored in WebContext any time ContextFilter processes the request. A good fix, without modifying in any way the WebContext interface, is doing something like the following:

              if (!MgnlContext.hasInstance() || MgnlContext.isSystemInstance())
              {
                  MgnlContext.initAsWebContext(request, response, servletContext);
                  contextSet = true;
              }
      +        else
      +        {
      +            // update request
      +            WebContext webContext = (WebContext) MgnlContext.getInstance();
      +            webContext.init(request, response, servletContext);
      +        }
      +
      

      I would like to commit this to 3.6.2, this can be a very annoying bug for anyone using forwards with parameters. Any objection?

        Acceptance criteria

              had Jan Haderka
              fgiust Fabrizio Giustina
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD