Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Avoid exception in case a membership is already found. #296

Merged
merged 6 commits into from
Oct 16, 2017

Conversation

idimopoulos
Copy link
Contributor

From issue #295

Copy link
Member

@amitaibu amitaibu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'd love to get a test as-well to confirm the functionality.

og.module Outdated
$membership = Og::createMembership($entity, $entity->getOwner());
$membership->save();
// Other modules might interfere and create a membership.
if (!Og::getMembership($entity, $entity->getOwner())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here you will get only the active memberships.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed!! I have also been trapped by this in the past, which is why I created #292 to lobby for changing this to return all memberships by default. I think it is not intuitive that this method returns filtered results by default, and an additional parameter should be passed to get the actual membership.

og.module Outdated
@@ -47,8 +47,11 @@ function og_entity_insert(EntityInterface $entity) {
return;
}

$membership = Og::createMembership($entity, $entity->getOwner());
$membership->save();
// Other modules might interfere and create a membership.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe // Implementing modules might have created a membership ahead of us.

@pfrenssen
Copy link
Contributor

I think it's OK for me to merge this since I did not write the original patch but just the test coverage that proves the bug is real.

@pfrenssen pfrenssen merged commit 0704fc2 into Gizra:8.x-1.x Oct 16, 2017
@pfrenssen pfrenssen deleted the duplicated_membership_exception branch October 16, 2017 12:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants