-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Simply put, the code should not corrupt the tree or leave orphaned plugins laying around. Orphaned plugins are a frequent headache. The current situation requires developers to log in and run a command to repair the database once the site starts giving 500 errors to users. This is not a good way to run a production website.
Part of the issue is that it's possible for django-cms and plugins to overwrite treebeard data by saving stale data after treebeard makes updates. I found an example of this type of corruption in django-cms/djangocms-text-ckeditor#212 where tree data was overwritten due to incorrect order of operations.
We need tighter controls on when treebeard operations take place. Haven't fully investigated the feasibility but would be good if we could prevent CMS Plugins from ever setting these mptt values directly, perhaps using update_fields. Only treebeard should ever touch these values.
Haven't dug through all the code paths that might contribute to the orphaned plugins situation but we may need to rethink the 'save CMSPlugin when all the user really needed was a form to be rendered'. CMSPlugin's should only be saved to the db when a CMSPlugin subclass is saved to the db, wrapped in a transaction.
This is somewhat related to #3157 & #3158 but I think we should focus on squashing the bugs that lead to these issues in the first place. Those tickets are just asking for errors to be silenced in production, but there may be too many code paths that expect valid, intact data for that approach to work.