CharlZ's Blog

Ramblings about SharePoint, etc.

Bug in WSS 3.0 Picture Library after upgrade to SharePoint 2010

Symptoms

After upgrading content from WSS 3.0 to SharePoint Foundation 2010, we discovered the following behavior when clicking on an image inside of a picture library:
   
This behavior was only observed on picture libraries that existed prior to the upgrade. Any picture libraries that we created after the upgrade process did not suffer from this issue.  When I opened the AllItems.aspx pages in for each list in SharePoint Designer 2010, I could see that each page used different web parts to display the list of items. The upgraded content (originally in WSS 3.0) used a ListViewWebPart object to display the list of items and the newly created list used an XsltListViewWebPart.
Further investigation of the upgraded picture library revealed that the error message was being generated due to an invalid URL to list item page that was being constructed by SharePoint. SharePoint was generating a URL that looked like the following:
http://<Server>/<Site>/_Layouts/listform.aspx?PageType=4&ListId={GUID}?ID=XX&Source=<URL of original source page>&RootFolder=<Folder where image resides>
Because of the duplicated question marks in the query string portion of the URL, the page fails to load. When I manually modified the URL to contain an ampersand instead of a second question mark, the list item page was displayed.

Resolution

The resolution to this issue turns out to be fairly simple, all though potentially time consuming if your affected site has many picture libraries. The steps are detailed below: 
  1. Open the AllItems.aspx page of the affected list
  2. In the top left hand corner of the page, click Site Actions / Edit Page
  3. Edit the properties of the list view web part and press OK on the tool part. This step appears to fix whatever values are corrupted in the list view web part’s properties.
  4. Reload the page and it should work correctly.
  5. Repeat this for each view in the list.
These steps appear to work for the All Items view, but may not correct any of the standard list views.

Further Analysis

After comparing the ListViewXml data from the page prior to the fix and page after the fix, we can see that SharePoint has modified some of the underlying JavaScript to correct the URL it constructs to the list item details page.

Original Page

<![CDATA[
<script>
fImglibDefautlView = true;

urlCmdForDisplay = ctx.displayFormUrl + "?RootFolder=]]>

Corrected Page

<![CDATA[
<Script>
fImglibDefautlView = true;
strSeperator = "&";
if (ctx.displayFormUrl.indexOf("?") == -1)
            strSeperator = "?";
urlCmdForDisplay = ctx.displayFormUrl + strSeperator + "RootFolder=]]>

Programmatic Fix

I have put together a console application that will process all of the lists on your SharePoint farm and correct the invalid markup in the views.  Download the Visual Studio 2010 project below:

CorrectPictureViews.zip (59.12 kb)

Comments (4) -

  • Dennis

    7/28/2011 2:02:50 PM | Reply

    Hello,

    Thanx for your programmatic fix. Is there a possibility that you put this in a executable? i don't have Visual Studio and i'm not programmer.

    Thanx in advance!!

  • Charles

    7/29/2011 5:18:17 PM | Reply

    The executable is in the ZIP file.  Extract the files from the ZIP file onto a server in your SharePoint farm.  The file will be named CorrectPictureViews.exe in the CorrectPictureViews\bin\Debug folder inside of the extracted folder.  I would recommend preforming a full backup of your SharePoint farm before running it, just in case anything goes wrong.

  • Dennis

    8/15/2011 11:12:45 AM | Reply

    Charles,

    The executable worked. Good work.

    Strange thing is that a specific picturelibrary doesn't show the pictures. I red cross is shown. When I edit the page and save the page it worked well. Do you know witch code this is?

    Thanx in advance!

Add comment

Loading