More in this section

Forums / Bugs & Issues / An item with the same key has already been added

An item with the same key has already been added

12 posts, 1 answered
  1. JingYuan
    JingYuan avatar
    12 posts
    Registered:
    18 Jul 2011
    20 Jul 2011
    Link to this post
    I was trying to re-publish some images, which i have unpublished earlier but end up getting the error mention in the title. Now, whenever I try to access Content>>Images, I will get have a popup with this error. The rest of the cms seems to be working ok.
  2. Nicolas
    Nicolas avatar
    156 posts
    Registered:
    19 Jan 2011
    20 Jul 2011
    Link to this post
    Hi,

    You have the same problem as that : News Problems .
    It's a regression on Q1 SP2. If you unpublished and re-published a content without modification you break referential integrity in database because there are no foreign keys....

    You have to go in database and try to suppress the faulty line.

    Regards,
    Nicolas
  3. JingYuan
    JingYuan avatar
    12 posts
    Registered:
    18 Jul 2011
    20 Jul 2011
    Link to this post
    Hi Nicolas,

    Do you happen to know which table do I look into for Images?
    Thank you in advance?
  4. Nicolas
    Nicolas avatar
    156 posts
    Registered:
    19 Jan 2011
    20 Jul 2011
    Link to this post
    Hi,

    it's the datatable [sf_media_content].

    Regards,
    Nicolas
    Answered
  5. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    20 Jul 2011
    Link to this post
    Hi JingYuan Lin,

    We know of an issue as the one you described and have logged a bug. The problem was introduced in 1501 ( it is fixed in our latest internal build ) when you unpublish an image, and publish it again.

    Can you still access the following page:

    http://yourwebsite/sitefinity/Content/Images/Albums

    If you access to that page, you can try to delete all libraries and add the files again. This should fix the issue.


    Best wishes,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. JingYuan
    JingYuan avatar
    12 posts
    Registered:
    18 Jul 2011
    21 Jul 2011
    Link to this post
    Thank you Both Nicolas and Telerik Admin.

    If I dont wish to delete all the libraries, which is the 'Key' I should look for?
  7. Nicolas
    Nicolas avatar
    156 posts
    Registered:
    19 Jan 2011
    21 Jul 2011
    Link to this post
    Hi,

    you have to find your image who cause the bug. If you have the name is more easy. Otherwise you have to check duplicate keys for the same image into datatable.

    Regards,
    Nicolas
  8. Nick
    Nick avatar
    10 posts
    Registered:
    09 Jun 2008
    22 Jul 2011
    Link to this post
    Could a unique index be applied to the table to prevent this from happening in the future?
  9. Justin
    Justin avatar
    4 posts
    Registered:
    26 May 2011
    22 Jul 2011
    Link to this post
    HI,

    Is this issue fixed in 4.1 sp3 ?

    This is in the sp3 notes, is it the same issue?

    "Content/Pages: fixed error appearing when published item is unpublished and then published again"

    IF so, will the code cope with the duplicate data now in the database?
    Or will we need to run a cleanup script on the table?  Do you have a script...?

    We've just struck this in our production system so keen to know asap.

    Thanks,
    Justin
  10. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    22 Jul 2011
    Link to this post
    Hello Justin,

    The issue is fixed in the SP we released ( 4.1 SP3 ). You may upgrade your project to it because it also contains performance and security fixes and updates.

    Regards,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Web
    Web avatar
    6 posts
    Registered:
    13 Oct 2008
    27 Jul 2011
    Link to this post
    We have the same problem but we must repair project now.
    The upgrade take many times and problems.
    There is a procedure to fix error in database immediatly?
    We have identified the news item in database, we must delete it to repair backend news page?

    Thanks
  12. Nicolas
    Nicolas avatar
    156 posts
    Registered:
    19 Jan 2011
    27 Jul 2011
    Link to this post
    Hi,

    You have to delete only one line in database.

    On your identified news, check [original_content_id]  who are duplicate (different of 00000000-0000-0000-0000-000000000000).

    You have two lines one with [visible] equals 0 and other equals 1, get the [content_id] on the line with [visible]=0 .

    Delete it from [sf_news_items_sf_permissions] :
    DELETE
    FROM [MyDB].[dbo].[sf_news_items_sf_permissions]
    WHERE [content_id]='xxxxxx-xxxxxxxx-xxx-xxxx-xxxxxxx'

    And delete it from [sf_news_items] :
    DELETE
    FROM [MyDB].[dbo].[sf_news_items]
    WHERE [content_id]='xxxxx-xxxxxxxx-xxxxxxx-xxxxxx-xxxxx'

    And it resolve your problem.

    Regards,
    Nicolas
12 posts, 1 answered