An item with the same key has already been added

Posted by Community Admin on 04-Aug-2018 08:11

An item with the same key has already been added

All Replies

Posted by Community Admin on 20-Jul-2011 00:00

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.

Posted by Community Admin on 20-Jul-2011 00:00

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

Posted by Community Admin on 20-Jul-2011 00:00

Hi Nicolas,

Do you happen to know which table do I look into for Images?
Thank you in advance?

Posted by Community Admin on 20-Jul-2011 00:00

Hi,

it's the datatable [sf_media_content].

Regards,
Nicolas

Posted by Community Admin on 20-Jul-2011 00:00

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

Posted by Community Admin on 21-Jul-2011 00:00

Thank you Both Nicolas and Telerik Admin.

If I dont wish to delete all the libraries, which is the 'Key' I should look for?

Posted by Community Admin on 21-Jul-2011 00:00

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

Posted by Community Admin on 22-Jul-2011 00:00

Could a unique index be applied to the table to prevent this from happening in the future?

Posted by Community Admin on 22-Jul-2011 00:00

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

Posted by Community Admin on 22-Jul-2011 00:00

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

Posted by Community Admin on 27-Jul-2011 00:00

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

Posted by Community Admin on 27-Jul-2011 00:00

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

This thread is closed