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


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: 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.

Technical tasks


Deployment actions



Marijn Otte
February 5, 2016, 7:52 AM

the PR has a merge conflict in an unimportant file, but I think you will have comments, so the merge conflict will be solved with the rework

Jeroen van Leeuwen
February 8, 2016, 7:45 AM

See comments in PR

Marijn Otte
February 8, 2016, 9:52 PM

Comments have been fixed

Jeroen van Leeuwen
February 9, 2016, 7:01 AM

Two comments still need an answer

Jeroen van Leeuwen
February 18, 2016, 1:19 PM

Sorry for not looking at the PR sooner.





Fix versions