Upgrade localized SharePoint 2007 Publishing site to SharePoint 2010

publishing_error

Update: March 11 2011

Microsoft KB2484317 for issue with solution

http://support.microsoft.com/kb/2484317

After a succesfull (according to upgrade log file) upgrade of a SharePoint 2007 localized publishing site, the site is not working, the following error occurs when accessing the portal:

Ongeldig SPListItem. Het opgegeven SPListItem is niet compatibel met een publicatiepagina.

[ArgumentException: Ongeldig SPListItem. Het opgegeven SPListItem is niet compatibel met een publicatiepagina.] Microsoft.SharePoint.Publishing.PublishingPage.GetPublishingPage(SPListItem sourceListItem) +303 Microsoft.SharePoint.Publishing.Internal.WebControls.PublishingPageStateControl.RaisePostBackEventForPageRouting(String eventArgument, SPRibbonCommandHandler control, RaisePostBackEventDelegate raisePostBackEventDelegate) +110 Microsoft.SharePoint.Publishing.Internal.WebControls.PublishingPageSaveAndStopEditHandler.RaisePostBackEvent(String eventArgument) +134 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981

The same message in English:

“Invalid SPListItem. The SPListItem provided is not compatible with a Publishing Page."

 

Problem

Publishing sites in SharePoint 2007 has a default location for the publishing pages at ‘/Pages/’ in SharePoint 2010 the location has a new name in the Dutch Language pack of ‘/Paginas/’

The change has been made in the following resource file: osrvcore.nl-NL.resx

Quick Solution

This is not a real solution but this proves that the real solution solves the problem.

Step 1: change in the osrvcore.nl-NL.resx the following lines:

by:

Warning: it is not supported to change the default resource files.

After saving the file and performing an IISreset the site is working with no problems, now we know this we can solve the issue in a more robust way by moving the ‘Pages’ to ‘Paginas’ location.

Real Solution

After upgrading localized publishing sites the following steps needs to be performed:

Step 1: Move your publishing pages inside the pages library to ‘Paginas’

Create a console application an perform following code on the server, the same can be accomplished by writing a PowerShell script. In this example I know that I only need to change Dutch sites (1043).

using (SPSite sitecollection = new SPSite(sitecollectionUrl)) { foreach (SPWeb web in sitecollection.AllWebs) { //Dutch language if (web.Language == 1043) { foreach (SPList item in web.Lists) { if (item.RootFolder.Url == “Pages”) { item.RootFolder.MoveTo(item.RootFolder.Url.Replace(“Pages”, “Paginas”)); item.Update(); } } } } }

Step 2: Set the welcomepage location to the new default.aspx

Execute the following code on the server through a console app.

using (SPSite sitecollection = new SPSite(sitecollectionUrl)) { foreach (SPWeb web in sitecollection.AllWebs) { if (web.Language == 1043) { if (PublishingWeb.IsPublishingWeb(web)) { PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web); SPFile welcomePage = null; welcomePage = web.GetFile(“Paginas/default.aspx”);

            <span style="color: blue;">if </span>(welcomePage != <span style="color: blue;">null</span>)
            {

//Set default welcomepage

                publishingWeb.DefaultPage = welcomePage;
                publishingWeb.Update();
            }
        }        
    }
}

}

Step 3: reactivate publishing feature for each site.

In this situation we only had a couple of subsites so we manually disabled and activated the feature for each sub site.

publishing_feature