Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Add two checkboxes to plugin config:
- Delete the entity along with the group-entity relation (GroupContent)
- Only delete when the entity is not part of any other group
Then implement those.
Comment | File | Size | Author |
---|---|---|---|
#15 | group-2754399-15.patch | 3.39 KB | msnassar |
#14 | group-2754399-14.patch | 3.46 KB | Boobaa |
#12 | group-2754399-12.patch | 3.63 KB | sergiuteaca |
#9 | plugin_config_delete-2754399-9.patch | 3.5 KB | tomasbarej |
#7 | plugin_config_delete-2754399-7.patch | 3.3 KB | sandeepguntaka |
|
Comments
Comment #2
imclean CreditAttribution: imclean commentedJust found this which I think relates to a problem I'm having: #2854068: Relation not deleted when node is deleted
From an entity/node object, is it possible to determine if the entity is part of a group?
Comment #3
kristiaanvandeneyndeNot related, this issue is about the option to also delete the entity the relation represents when you delete the relationship.
Comment #4
markconroy CreditAttribution: markconroy at Annertech for Trinity College Dublin commentedHi imclean,
Here's the code we use to check if a node is part of a group, and if so to redirect to the group alias version of the node:
Hopefully that can be some help to you.
Comment #5
sandeepguntaka CreditAttribution: sandeepguntaka at Azri Solutions commentedI ve done some code for this.
Comment #6
sandeepguntaka CreditAttribution: sandeepguntaka at Azri Solutions commentedComment #7
sandeepguntaka CreditAttribution: sandeepguntaka at Azri Solutions commentedComment #8
mvogel CreditAttribution: mvogel commentedPatch #7 works for me.
Maybe it would be nice too if the user could decide what should happen with the related content after the group deletion. (keep or delete) ?
Comment #9
tomasbarej CreditAttribution: tomasbarej commentedI had to update the patch with the current 8.x-1.x state.
Comment #11
moshe weitzman CreditAttribution: moshe weitzman as a volunteer and commentedI just ran into this issue. My use case is in an automated test using Drupal Test Traits https://gitlab.com/weitzman/drupal-test-traits. The test automatically cleans up created entities during tearDown(), in the order that they were created. In my test, a user was being deleted before its content and that led to GroupContent deletions which led to re-saving of the content (e.g. a node-page). The re-save failed with
Drupal\Core\Entity\EntityStorageException: Update existing 'node' entity while changing the ID is not supported.
I also saw this happenning when users are deleted, as they own nodes that get deleted which leads to GroupContent getting deleted and so it goes.
Comment #12
sergiuteaca CreditAttribution: sergiuteaca at FFW commentedA re-roll of patch #9 to meet the current state of the dev branch
@moshe weitzman I couldn't reproduce the error you are receiving.
Comment #13
matslats CreditAttribution: matslats as a volunteer commentedI just wanted to say that I'm having trouble with GroupContent::postDelete during migrate-rollback.
Here's my error message:
Drupal\Core\Entity\EntityStorageException: Update existing 'user' entity while changing the ID is not supported.
Comment #14
BoobaaMy use case is similar to #11 but not exactly the same: an automated Behat test automatically cleans up created users during tearDown(). In my test, a user was being deleted before its membership and that led to GroupContent deletions which led to re-saving of the user. The re-save failed with
Notice: Trying to get property 'pass' of non-object in web/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/PasswordItem.php line 50 (Drupal\Core\Entity\EntityStorageException)
. In my case, the user-to-be deleted was not the owner of any group, but only a member of one. I could not reproduce the problem using Drupal's web UI either.Re-rolled #12 anyway to meet the current state of the 8.x-1.x branch so it's also applicable to 8.x-1.4 (the latest stable release).
Comment #15
msnassar CreditAttribution: msnassar at European Commission and European Union Institutions, Agencies and Bodies commentedHere is a patch for group 2 and 3...
Comment #16
msnassar CreditAttribution: msnassar at European Commission and European Union Institutions, Agencies and Bodies commentedComment #17
msnassar CreditAttribution: msnassar at European Commission and European Union Institutions, Agencies and Bodies commentedThe patch in #15 is working for our website as we do not allow sharing content between groups.
Anyway, the proposed solution, is good when:
But, I wonder what should happen in case an entity is shared between 2 groups of different group type; where the relation plugins in each group type has different settings for entity deletion. For example:
Case #1:
It is deleting an entity that is being shared with other group (of different type) that assumes an entity should not be deleted when deleting its relation.
I think we should have a third option e.g. "Only delete when all same relation plugins in other group type allow to delete".
When this option is selected, Case #1 won't delete the target entity as it is being shared with a group of another type that prevents deleting the target entities!