Thursday, September 13, 2012

How to fix corrupted "PublishingAssociatedContentType"

Recently I tried to get a site template from a publishing site, and then create a similar site collection from it in the same content database.

It all look good, until trying to open "Page Layout and Site Template Settings" from "site settings".

http://server/sites/site1/_Layouts/AreaTemplateSettings.aspx

Below is the error message

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. 
Parameter name: index 
at System.ThrowHelper.ThrowArgumentOutOfRangeException
at System.Collections.Generic.List`1.get_Item
at Microsoft.SharePoint.SPFieldMultiColumnValue.get_Item
at Microsoft.SharePoint.Publishing.PageLayout.get_AssociatedContentTypeId
at Microsoft.SharePoint.Publishing.PageLayout.get_AssociatedContentType 
at Microsoft.SharePoint.Publishing.PageLayout.get_UIDisplayName
at Microsoft.SharePoint.Publishing.PageLayoutComparerByUIDisplayName.Compare
at System.Collections.Generic.ArraySortHelper`1.SwapIfGreaterWithItems
at System.Collections.Generic.ArraySortHelper`1.QuickSort
at System.Collections.Generic.ArraySortHelper`1.Sort

The same error also comes out when trying to create a new publishing page.

After reading some nice posts like here and this one, the problem is quite clear. The ASPX pages in "http://server/sites/site1/_catalogs/masterpage" have a sealed property "PublishingAssociatedContentType".  Its value is changed during the site creation.

The correct one is:
";#Article Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#"

The corrupted one is:
"Article Page, 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D"

We can confirm the invalid values from here: http://server/sites/site1/_catalogs/masterpage/Forms/AllItems.aspx


Unfortunately, it seems there is no way to change the value of those properties.

Below is how I fixed it. It should work if there is no customized page layouts.
(As always, I didn't test this solution completely. Please take a full backup of the site collection before the changes)

[update 20140424]

Please click here to see how to properly reactivate publishing feature.

2 comments:

  1. Where is the fix?

    ReplyDelete
    Replies
    1. Please reactivate publishing feature in the new site collection.

      Delete