Try our conversational search powered by Generative AI!

Don't automatically remove thrashed content that is still referenced

Vote:
 

Today we've encountered an EPiServer Find error which created 404 errors on certain areas of our site.
This was caused because a user thrashed a few pages which were still referenced by a few products in EPiServer Commerse.

I don't think EPiServer should automatically remove content that is still referenced and should either log Errors or Warnings when the automatic thrash job is ran.
Because now if at any point a user makes an error and the job is ran, the site is compromised.

#184856
Nov 06, 2017 13:18
Vote:
 

In the version of Episerver CMS that I use, when an editor clicks Move to trash, they get notified "Any incoming links on the web to this page will not work after you move it to the trash." 
Are you saying that this warning is not adequate?
Or are you saying that editors should not be permitted to delete content?

#184943
Nov 06, 2017 22:25
Vote:
 

I understand that users get this notification, but humans make errors and I think having an automated job that knows no context shouldn't be responsible for permanently deleting this kind of content.

I'd like to see a warning so an admin or a developer can make an educated desiscion whether or not this content can be deleted permanently.

#184962
Nov 07, 2017 9:35
Vote:
 

Just prevent editors from moving referenced content to the trash like this

    [InitializableModule]
    [ModuleDependency(typeof(InitializationModule))]
    public class PreventDeletingContentInitialization : IInitializableModule
    {
        private IContentEvents events;

        private IContentRepository repository;

        public void Initialize(InitializationEngine context)
        {
            this.events = context.Locate.Advanced.GetInstance<IContentEvents>();
            this.repository = context.Locate.Advanced.GetInstance<IContentRepository>();

            this.events.MovingContent += this.MovingContentToTrash;
        }

        public void Uninitialize(InitializationEngine context)
        {
            this.events.MovingContent -= this.MovingContentToTrash;
        }

        private void MovingContentToTrash(object sender, ContentEventArgs e)
        {
            List<ReferenceInformation> references = this.repository.GetReferencesToContent(
                contentLink: e.Content.ContentLink,
                includeDecendents: true).ToList();

            if (!references.Any() || e.TargetLink.ID != 2)
            {
                return;
            }

            e.CancelAction = true;
            e.CancelReason = "Deleting this content is not allowed, because it is still referenced.";
        }
    }
#184963
Nov 07, 2017 10:44
Vote:
 

When a page is deleted, the change is not permanent. The page is moved to the trash container and can be restored by an authorized user.

Further, to prevent users from deleting content, remove their access rights to do that. Only give administrators permission to delete content.

#184976
Nov 07, 2017 18:27
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.