We have noticed that we have a lot of softlinks that is not active anymore in one of our solutions. If we look at a document it says that it is linked to eight contents but seven of these does not have a link to that document anymore.
We think it is from a migration earlier so we have had the error for some time now and need help on what is the best way to solve it.
What we want to do is to have a solution that goes through all registred softlinks in the database and for each link verify that it still exists.
Are there any built in functions for this?
Not that I am aware of, the code for a single content would be:
var contentSoftLinkIndexer = ServiceLocator.Current.GetInstance<ContentSoftLinkIndexer>();
var contentSoftLinkRepo = ServiceLocator.Current.GetInstance<ContentSoftLinkRepository>();
var links = contentSoftLinkIndexer.GetLinks(content);
contentSoftLinkRepo.Save(content.ContentLink.ToReferenceWithoutVersion(), content is ILocalizable ? ((ILocalizable)content).Language : null, links);}
Just a little info, the problem was that we had a lot of content/files that was imported from another system that had not gotten the proper language in it so they did not show in any list and was not removed when updating the pages.
We solved it by updating those rows in the contentsoftlink table with the proper language and then run a update on all the pages.