We're updating the issue view to help you get more done. 

Don't allow to delete content or search selections when referenced somewhere

Description

Currently content items or search selections can be deleted (of /admin/content and /admin/search-selection) when they are referenced somewhere else in the database. This should not be allowed, to keep the database consistent.

Because we don't know which bundles are loaded or which custom documents have been made the fields that contain a reference to the current class must be determined automatically. This can be done with this code: https://gist.github.com/zarathustra323/9551530. After that all found fields need to be queried to see if the document that will be deleted is in use somewhere.

When the document is still in use an error message needs to be shown: This item is still on use by <a href="">item name</a>
The "by <a href..." part will only be shown if they object is instanceof Article, otherwise you don't know the title and where to link to.

Note: please don't write this code in the controller, maybe a service or event listener.

Deployment actions

None

Technical tasks

None

Status

Assignee

Unassigned

Reporter

Marijn Otte

Labels

None

Product owner

None

OTM project ID

None

Client

None

Plan date

None

Developer

None

Code reviewer

Jeroen van Leeuwen

Max. hours

None

Error message

None

Follow up date

None

Switches

None

Refiner

None

Fix versions

Priority

Major