Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting an item causes inconistend database state, when referenced in other Item #1328

Open
4 tasks done
bezin opened this issue Jul 29, 2019 · 3 comments
Open
4 tasks done
Assignees
Labels
enhancement This issue is about an enhancement (aka new feature)
Milestone

Comments

@bezin
Copy link
Contributor

bezin commented Jul 29, 2019

Checklist before I submit this issue report

I confirm that:

My environment is:

(Please fill in the actual values from your environment - check Contao Manager or use composer show)

Key Value Comments
PHP version: 7.2.2
Contao version: 4.4.41
MetaModels version: 2.1.4
Installed MetaModels packages: All
DCG version: 2.1.3

Issue description

The database is inconsistend when you delete an item that is referenced in another item. There is no "delete cascade", so the relation is still stored in tl_metamodel_tag_relation.

Steps to reproduce

Have an MetaModel A and B, where A has a tags attribute that references B. Delete one item of MetaModel B that is referenced in an Item of MetaModel A.

Describe the behaviour of the application

The relation in tl_metamodel_tag_relation is not deleted.

Describe the expected behaviour

The relation in tl_metamodel_tag_relation is deleted

@bezin bezin changed the title Deleting an item causes inconistend database state, when referenced in other MetaModel Deleting an item causes inconistend database state, when referenced in other Item Jul 29, 2019
@discordier
Copy link
Member

This is currently a known limitation.

MetaModels has no, as Contao itself, foreign key definitions and hence no enforcement of these.

This will be addressed in MM 3.0 earliest as it requires rewrites in the core DB management.

@bezin
Copy link
Contributor Author

bezin commented Jul 29, 2019

Is it possible to add an event in the delete method of the MetaModels DCGeneral Driver https://github.com/MetaModels/core/blob/master/src/DcGeneral/Data/Driver.php#L131 before deleting the item itself?

@discordier
Copy link
Member

for DcGeneral there is such an event: PreDeleteModelEvent

However, bear in mind that this does NOT get triggered when deleting via API.

@zonky2 zonky2 added the enhancement This issue is about an enhancement (aka new feature) label Jul 31, 2019
@zonky2 zonky2 added this to the Future milestone Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is about an enhancement (aka new feature)
Projects
None yet
Development

No branches or pull requests

4 participants