Sitecore SXA/JSS – Invariant language versions and access denied exceptions

Within a new implementation running on Sitecore 10.1 with SXA, we ran into a problem where we saw Invariant Language versions being created on certain items or recieving access denied exceptions, when saving an item. After a long time i’ve managed to reproduce the issue and pinpoint it to a new handler that was introduced in SXA 1.9.0 and is also included within JSS.

The FlagPublishingGroupingItems handler

Within that version, SXA/JSS introduced the FlagPublishingGroupingItems handler, which listens on item save. When an item is saved it does the following:

  1. Check if the site of the item that is saved, is an SXA site, if not it stops further execution
  2. Check if the parent inherits from PublishingGroupingTemplate, if so then it updates the revision of the parent and stops further execution.
  3. Get all the referrers to the current item, by retrieving them from the link database, and loops trough it doing the following:
    • It gets the referrer item using the referrer id, language and version.
    • If the item could not be found, the item inherits from the default Page template, or the referring item is the same as the saved item (the item references itself), then it skips further execution.
    • Updates the revision of the referrer item.

The functionality that is described above has two main culprits:

  1. The code doesn’t check if the content-editor has write access to the referrer item, but still updates the revision.
  2. The code doesn’t check if the language field of the referrer is filled, but still updates the revision. This forces an invariant language to be created.

Reproduction scenario:

I’ve been able to reproduce this, using the following setup:

  • Create a brand new SXA site
  • Create a partial design
  • Edit the shared layout of the partial design, add the navigation rendering, and point the NavigationRoot of the rendering to your home item.
  • Create a page design using the partial design
  • Add the page design to your homepage item
  • Change something on your homepage and save
  • Note that your newly created partial design now has an invariant language.

When you have a content editor that only has the SXA Site Author role, then he will get an access denied exception when saving the homepage, as he has no rights to update the partial design.

The “fix”

To fix this problem, the easy way is to disable the FlagPublishingGroupingItems handler, by adding the following config. If you require a fix from Sitecore, you can use public reference number #477263.

<sitecore>
    <settings>
        <setting name="XA.Foundation.Publishing.FlagPublishingGroupingItems.Enabled" value="false"/>
    </settings>
</sitecore>

Update

Mark let me know on Slack that this is not just a problem in SXA, but it also occurs in JSS installations. Thanks for the heads up Mark!

I’ve consulted with Sitecore support to figure out what the handler does, and why it was introduced. The handler is introduced to fix “The Publishing Service does not publish in SXA” (public reference #286762).
When you’re not using the Sitecore Publishing Service, it’s safe to disable this handler.

Leave a Reply

Your email address will not be published. Required fields are marked *