Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
entity system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
25 Sep 2015 at 16:21 UTC
Updated:
29 Sep 2015 at 12:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
anavarreComment #3
catchDrupal 7 used to have https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/fun...
I have no idea what the 8.x equivalent is, but even if we have it, we're clearly not implementing it.
Bumping to critical since this is a clear data-loss issue. We can prevent the rename for now as a quick fix, then handle renames properly and remove the validation later IMO.
Comment #4
catchAlso need to check if this is an issue for taxonomy vocabularies or other entity types in core that have a bundle config entity.
Comment #5
fgmWorking on this.
Comment #6
fgmThis hook was removed in #1374116: Move bundle CRUD API out of Field API where it was renamed hook_entity_bundle_rename(), not hook_entity_rename_bundle() as said on the issue.
Comment #7
fgmThe problem is that this hook is triggered by an entity::postSave(), so it happens too late to prevent the change, and a complete fix will have to be extensive, possibly involving an API change, so let's just do it in the entity type forms.
We have 4 entity types in core where this happens, not counting tests: node, taxonomy_term, shortcut, and block_content, with bundle edit forms. The latter two already have a form-based protection, so I replicated the same policy on the two former ones. Let's see how the tests fare.
Comment #8
fgmAdjusting component.
Comment #10
dawehnerPersonally renaming bundles is a vulcano. It would require adaption all over the place.
Personally this is a feature that can be provided by contrib modules.
Comment #11
catchWe ought to be able to detect the change in save somewhere, and throw an exception there?
Comment #13
jhedstromI haven't looked too far into how this might work in EntityForm (which all 3 of these extend), but it would be really great if we could generically dis-allow changing the machine name for any entity type with existing content (simply disallowing it at all after creation would be fine too, but would perhaps be frustrating for devs prone to typos :)
Edit: EntityForm is probably too generic, but perhaps a trait the given entity type forms could use?
The Book module tests for the ability to change machine name (as if that were a feature?), so a change notice will be needed I suppose:
Comment #14
wim leersMy thoughts exactly.
Comment #15
dawehnerSo I think we want to have two things:
#disabledflag by default)The current patch should at least document for the
#disabledflags, why they are setup in this particular way.Comment #16
fgmI've been updating the path to catch the change in the storage layer, to avoid depending only on UI, as suggested by @catch. It doesn't prevent doing it in the UI to avoid exposing an otherwise unavailable rename operation, of course.
Question is: what to do about BookTest, for instance, which explicitly tests renaming a node bundle : do we just drop the test ?
Comment #17
catchI think we can just drop the test for now yes, that hunk could move to the follow-up issue to add back the feature.
Comment #18
catchDuplicate of #2172843: Remove ability to update entity bundle machine names which has unfortunately been around for a long time with a patch.