In my blog I already wrote about various problems on sites after export/import (see e.g. Using SPExport/SPImport for copying content with managed metadata or Problem with SPContextPageInfo.IsWebWelcomePage on imported Sharepoint sites). There was also article about problems with connecting to catalogs on imported sites: Problem with connecting to catalog on site collections imported with SPExport/SPImport API in Sharepoint. In this post I will describe one more problem with publishing catalog connections on imported sites.
Suppose that we have site collection which uses cross-site publishing, i.e. has one or more connected catalogs. After that we export site collection via SPExport and import it to another location via SPImport. Now if we will check available catalog connections on the imported site in Site settings > Manage catalog connections there won’t be any connections. However if we will click Connect to catalog on the same page we will see all connections from the source site. The problem is that they still will point to the source site and it won’t be possible to disconnect them from UI (in the last column where normally there is Connect link, there will be server-relative URL of the source site collection which won’t be clickable).
In order to solve this problem we discussed the following approach with colleagues: if it is not possible to disconnect copied connections from UI, we will try to do it programmatically, and after that will check will it be possible to reconnect them from the target site. My colleague Mikko Niemi created console utility which enumerates all available connections and allows to disconnect them one by one. With his approval I post the code of this utility here:
With this utility you may disconnect copied “broken” connections and reconnect them again e.g. from UI (after disconnecting near appropriate connection you will see Connect link). Hope that it will help you if you will face with similar problem.