OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.44k stars 2.4k forks source link

Deleteing a content-type that is inuse causes an exception #6751

Closed MikeAlhayek closed 2 years ago

MikeAlhayek commented 4 years ago

When creating a content-type "i,e. Widget", then adding it to a Widget. Then deleting the content-type, the system throws an exception, and is hard to use the GUI to recover from it.

Solution: prior to performing the "delete" operation content-type or content-part, check that it isn't being used. If it is used, you might want to throw an alert to the user and prevent the delete.

hishamco commented 4 years ago

Showing a warning alert may good for this case, @CrestApps would you like to push a PR for this?

MikeAlhayek commented 4 years ago

I could mess with it. But it won't be any time soon.

hishamco commented 4 years ago

Which version you are using? I just deleted an Article content type successfully

KaloyanIT commented 4 years ago

I'm interested in contributing. Could you provide a little more detail on exactly what should be accomplished to resolve this issue?

hishamco commented 4 years ago

Glad to hear that @KaloyanIT!! the idea basically to avoid deleting the content type who has already some content items, unless we show a warning alert or confirm message telling that the current content type has associated content types. @CrestApps still waiting for you

sebastienros commented 4 years ago

Will be hard for types that are contained (widgets, bag part content items, menu items...)

I assume we should just log the issue, and ignore the content items without throwing exceptions.

deanmarcussen commented 3 years ago

Related https://github.com/OrchardCMS/OrchardCore/issues/1014