Uploaded image for project: 'Magnolia Site Module'
  1. Magnolia Site Module
  2. MGNLSITE-39

SiteAwareRendererWrapper fails to render optional areas

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 1.0.5
    • 1.0.2
    • api
    • None
    • Kromeriz 30
    • 2

      It fails with an NPE in SiteAwareRendererWrapper on line 84 where it tries to use the content.

      It appears that optional areas are rendered without a content node. In AreaElement.java we have this code:

          private boolean canRenderAreaScript() {
              if (!this.isAreaDefinitionEnabled) { // area script can be rendered only when area is enabled
                  return false;
              }
              if (this.areaNode != null) {
                  return true;
              }
              if (this.optional && this.getServer().isAdmin() && !MgnlContext.getAggregationState().isPreviewMode()) { // render script for optional areas when being in edit mode on author instance
                  return true;
              }
              return false;
          }
      

      So if areaNode is null and optional is true and we're in preview mode on an author instance then we go ahead and call the renderer without a content node. The template script is then rendered.

      This works fine in JspRenderer and FreemarkerRenderer but in SiteAwareRendererWrapper throws an NPE.

      Without a content node SiteAwareRendererWrapper can't get the current site, and can't decide if it's rendering a page (well it could look at the renderable definition id to see if it has pages/ in it but there's no point since it doesn't have a site to use anyway).

      SiteAwareRendererWrapper should just skip template prototype merging altogether and proceed with rendering when content is null. Basically assuming that when content is null its an area so there's nothing to do anyway. With this change the fix would be a simple null check.

        Acceptance criteria

              tmattsson Tobias Mattsson
              tmattsson Tobias Mattsson
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 35m
                    35m