addRelationship method skips validation of relationship entity

Created on 16 November 2024, about 1 month ago

Problem/Motivation

In our case we are using addMember to add users to the group, when group membership request is approved, but it was discovered that we can add like users to multiple groups, even the cardinality set to "1".
This happens, because addRelationship doesn't validate the entity before saving it and thus we skip all validations for entity.

    $storage = $this->relationshipStorage();
    $relationship = $storage->createForEntityInGroup($entity, $this, $plugin_id, $values);
    $storage->save($relationship);
    return $relationship;

Solution

Validate an entity before saving it, I am unsure what the best approach would be for the Group module.

🐛 Bug report
Status

Active

Version

3.3

Component

Code

Created by

🇧🇪Belgium lobsterr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @lobsterr
  • 🇩🇪Germany vetiver root

    After looking into this issue I noticed that this is also true for the native joining process.
    So if users are allowed to join a group they can join multipe groups of the same type even though the group cardinality for the group membership plugin is set to 1.

Production build 0.71.5 2024