Installing templates with a modified field sharing type may cause database corruption


Description

When changing the value of the Shared or Unversioned property of a particular field, every item based on the modified template is updated and the corresponding field values are moved to the appropriate data table in the Sitecore database: SharedFields, UnversionedFields, or VersionedFields.

However, in situations when the field sharing properties on a template are changed as part of a package installation, related items may not be updated properly, and corresponding field values may be located in different Sitecore database tables.

In this case, an author may experience various issues when working with items.

For example, field values may not be changed as expected upon save operation, or the data may not be published in an expected manner.

Fixing Data Corruption

If one the previously installed packages has already modified the field sharing properties, perform the following steps.

Notes:

  1. This solution applies only to SQL Server databases.
  2. Performing the procedure below may cause data loss in the items affected by changing field sharing properties. This applies only if changes have been made to those items after installing the package.
    At the end of the procedure, you will see the list of the affected items and fields that need to be checked.

Solution:

  1. IMPORTANT! Back up your solution.
  2. Copy the Sitecore.Support.310642.dll assembly to the /bin folder.
  3. Copy the Sitecore.Support.310642.config file to the /App_Config/Include folder.
  4. Copy the FixFieldSharing.aspx file to the /sitecore/admin folder of your solution.
  5. Request the <hostname>/sitecore/admin/FixFieldSharing.aspx URL and run the fix process for each of the affected databases.
  6. Remove all the files added in the previous steps.

After performing these steps, all the field values should be stored in correct places and unexpected results of the package installation should be fixed.

Preventing The Issue

To prevent this issue for future package installations, perform the following steps.

Note: The solution below applies only to SQL Server databases.

Solution:

  1. IMPORTANT! Back up your solution.
  2. Copy the Sitecore.Support.310642.dll assembly to the /bin folder.
  3. Copy the Sitecore.Support.310642.config file to the /App_Config/Include folder.
  4. In the /sitecore/shell/Applications/Install/Dialogs/Install package/Install Package.xml file, replace the following node:
    <WizardForm Application="Tools/Installer/InstallationWizard" CodeBeside="Sitecore.Shell.Applications.Install.Dialogs.InstallPackage.InstallPackageForm,Sitecore.Client">
    with the following one:
    <WizardForm Application="Tools/Installer/InstallationWizard" CodeBeside="Sitecore.Support.Shell.Applications.Install.Dialogs.InstallPackage.InstallPackageForm,Sitecore.Support.310642">
  5. Uncomment the following setting in the Sitecore.Support.310642.config:
    <setting name="FixFieldSharing.DatabasesToMaintain" value="master, web"/>
    In the value attribute, you can specify the names of the databases that should be checked after future package installations.