Updated: Comment #0
Problem/Motivation
DateFormatAccessController
and NodeTypeAccessController
relies on isLocked()
method of the entity to prevent delete entities that are used by enabled modules. Menu entity relies on menu_list_system_menus()
to prevent delete system menus but this going to change #2084197: Uninstalling menu module removes all custom menus in favour of locked
property on entity.
So currently there's no common approach to prevent some config to be deleted.
Locking usage
DateFormat::
isLocked()NodeType::
isLocked()Language->
locked propertyMenu::isLocked()
#2084197: Uninstalling menu module removes all custom menus
Proposed resolution
Implement a service to allow modules to lock entity definitions (probably config files) that are required them to operate properly.
For example: forum relies on vocabulary and node type that are required to work.
Remaining tasks
tbd
User interface changes
no
API changes
tbd
Related Issues
#2084197: Uninstalling menu module removes all custom menus
#2003892: Convert date formats to config entities
#111715: Convert node/content types into configuration
Comment | File | Size | Author |
---|---|---|---|
#9 | 2084567-9.patch | 23.9 KB | tstoeckler |
#9 | 2084567-8-9-interdiff.txt | 13.61 KB | tstoeckler |
Comments
Comment #1
Gábor HojtsyThe language entities also have a concept of locked and will not even list locked entities in the list controller. Would be a good one to add on this list :)
Comment #1.0
andypostadded links to types
Comment #1.1
andypostUpdated issue summary.
Comment #1.2
andypostUpdated issue summary.
Comment #2
andypost@Gabor, yes, the same interface needed for language types in #1862202-157: Objectify the language system
probably better title according #2044583: Add EntityChangedInterface to allow entities with "changed" field to be properly cached
Comment #2.0
andypostmarkup
Comment #3
andypostComment #4
tstoecklerTaking a stab at this.
Comment #5
fagoThis makes sense, however I think the name EntityStateInterface is too generic. Maybe, EntityLockInterface would describe it better?
Also, at discussed over at #2031717-15: Make entity module not required it might be worthwhile to have CMI enforce the locking.
The way this works with entity exportables in d7 is that deletion is actually a revertion - so I guess this is what people would expect to happen? However, issues through the delete+insert approach occurred as the deletion reactions are often unwanted in the revertion case, so a dedicated revert hook would be a a good improvement.
Comment #6
tstoecklerI also did not like EntityStateInterface. To be consistent with EntityChangedInterface I went with EntityLockedInterface for now. (Will upload patch soon.) Re-titling for that.
I think a dedicated 'revert' operation + hook, etc. makes sense, but if I'm not mistaken that could be a follow-up right?
Comment #7
tstoecklerComment #8
tstoecklerSo we have two different usages of locked currently:
This patch implements the latter behavior for EntityLockedInterface and keeps the custom implementations of Language and DateFormat on top of that. We should probably find a cleaner way to do that and/or better terminology.
To be more specific on top of providing the EntityLockedInterface the patch does two things:
This patch in-passing also fixes a minor bug where currently DateFormatAccessController does not check create access. By supplying an 'admin_permission' in the annotation this is done automatically.
Comment #9
tstoecklerThe patch was missing the isLocked() method in the Language entity class.
From looking around core I am now prettty convinced that we need to clarify the terminology here. The word 'lock' is already very ambiguous. On top the usage that is discussed here, we already have the whole locking system á la LockInterface / lock.inc and also views can be locked from editing but only if another person is currently editing it.
Therefore in this patch I introduce:
1. EntityDeletionLockedInterface
2. EntityUpdateLockedInterface
(Please *do* provide suggestions for better names.)
With this the access control of date formats, languages, menus and node types are all covered. Only the list controller magic of date formats in languages mentioned in #8 is still done manually.
Comment #12
andypostI think #9 is overcomplicated but this points why I used 'state' in issue.
State is not boolean, I suppose a set of disabled operations better describes this interface.
So probably better to move the implementation to operations level after #1839516: Introduce entity operation providers and related #1965910: Remove enable/disable entity operations
looks fragile
Comment #13
tstoecklerI'm fine with going back to the approach in #8.
As I've tried to explain in #9 what we currently have in core is confusing when you look closely. Regardless of the other usages of the word 'lock' in core currently, DateFormatInterface::isLocked() has a different meaning that NodeType::isLocked(). That's the problem that I was trying to solve.
Regarding the hunk quoted in #12: I'm fine with removing that for now. I just thought it would be handy not to have to redeclare 'locked' in getExportProperties the whole time.
Comment #14
tstoecklerSo this issue really needs some more discussion input before progressing with this. Unassigning for now. Maybe someone can summon the Entity API gurus :-)
Comment #15
andypostComment #24
andypostComment #25
fgmFWIW, I have this issue in the G2 module, to prevent deletion of a specific vocabulary and misc fields, similar to Forum.
Comment #26
geek-merlinMused a bit about this. The problem eith the "locked" property altogether is, that is has no info why something is locked.
Think 2 components set a locked property. One does not need the lock anymore, not knowing that the other still needs the lock.
Also we can never know why something is locked, nor who set the property. Bad.
So what about kill the locked property in favor of (something like) hook_entity_change_veto()?
We can invoke that hook and display to the user something like: "Deleting this entity is disallowed by module Foo because 'foo reason'", "Editing or deleting this entity is disallowed by module Bar because 'bar reason'".
Comment #27
andypostMeantime here's core enforced dependencies for confirmation, also transform and override different kinds.
Thinking about this interface for content I think itl may affect default content (making it read only)
Comment #28
geek-merlin@andipost #27: I read that several times and do not get what you want to say...