The 'item:moving' event throws errors when publishing SXA website items


Description

Publishing might fail with an unhandled exception after some items have been moved in the Master database. The following message can be found in the log:

ERROR One or more exceptions occurred while processing the subscribers to the 'item:moving' event.
Exception[1]: System.NullReferenceException 
Message[1]: Object reference not set to an instance of an object. 
Source[1]: Sitecore.XA.Foundation.Multisite 
at Sitecore.XA.Foundation.Multisite.EventHandlers.VirtualMediaFolderValidator.OnItemMoving(Object obj, EventArgs args)
at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters, EventResult result)

This issue affects SXA 1.7.0 - 1.7.1 versions.

Solution

To resolve the issue, download and install the patch compatible with the affected product version found on this page: https://github.com/SitecoreSupport/Sitecore.Support.13144/releases