diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 000000000..df4658d6a
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,3 @@
+# Changelog
+
+All notable changes to the Organic Groups project are documented on [drupal.org](https://www.drupal.org/project/og/releases) and on [github](https://www.drupal.org/project/og/releases).
diff --git a/og.install b/og.install
index 80ad218cf..4fc373b6a 100644
--- a/og.install
+++ b/og.install
@@ -77,3 +77,16 @@ function og_update_8001(&$sandbox) {
return $message;
}
+
+/**
+ * Add uuid field to OgMembership.
+ */
+function og_update_8002() {
+ $manager = \Drupal::entityDefinitionUpdateManager();
+ $entity_type = $manager->getEntityType('og_membership');
+ $entity_keys = $entity_type->getKeys();
+ $entity_keys['uuid'] = 'uuid';
+ $entity_type->set('entity_keys', $entity_keys);
+ $manager->updateEntityType($entity_type);
+ $manager->updateFieldStorageDefinition($manager->getFieldStorageDefinition('uuid', 'og_membership'));
+}
diff --git a/phpcs-ruleset.xml.dist b/phpcs-ruleset.xml.dist
index 0114a856e..15c9ceb90 100644
--- a/phpcs-ruleset.xml.dist
+++ b/phpcs-ruleset.xml.dist
@@ -19,4 +19,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Entity/OgMembership.php b/src/Entity/OgMembership.php
index 14a221f05..470e38856 100644
--- a/src/Entity/OgMembership.php
+++ b/src/Entity/OgMembership.php
@@ -63,6 +63,7 @@
* fieldable = TRUE,
* bundle_entity_type = "og_membership_type",
* entity_keys = {
+ * "uuid" = "uuid",
* "id" = "id",
* "bundle" = "type",
* },
diff --git a/src/EventSubscriber/OgEventSubscriber.php b/src/EventSubscriber/OgEventSubscriber.php
index 3463cd3f2..e5b3cefe4 100644
--- a/src/EventSubscriber/OgEventSubscriber.php
+++ b/src/EventSubscriber/OgEventSubscriber.php
@@ -132,16 +132,9 @@ public function provideDefaultOgPermissions(PermissionEventInterface $event) {
'restrict access' => TRUE,
]),
new GroupPermission([
- 'name' => 'manage roles',
- 'title' => t('Add roles'),
- 'description' => t('Users may view group roles and add new roles if group default roles are overridden.'),
- 'default roles' => [OgRoleInterface::ADMINISTRATOR],
- 'restrict access' => TRUE,
- ]),
- new GroupPermission([
- 'name' => 'manage permissions',
- 'title' => t('Manage permissions'),
- 'description' => t('Users may view the group permissions page and change permissions if group default roles are overridden.'),
+ 'name' => 'administer permissions',
+ 'title' => t('Administer permissions'),
+ 'description' => t('Users may view, create, edit and delete permissions and roles within the group.'),
'default roles' => [OgRoleInterface::ADMINISTRATOR],
'restrict access' => TRUE,
]),
diff --git a/tests/src/Kernel/Entity/OgMembershipTest.php b/tests/src/Kernel/Entity/OgMembershipTest.php
index 2aa9ca6e5..3414285d3 100644
--- a/tests/src/Kernel/Entity/OgMembershipTest.php
+++ b/tests/src/Kernel/Entity/OgMembershipTest.php
@@ -777,6 +777,41 @@ public function testGetRolesFromMembershipWithoutGroup() {
$this->assertEquals([], $roles);
}
+ /**
+ * Tests that the role ids are being built properly by the membership.
+ *
+ * @covers ::getRolesIds
+ */
+ public function testGetRolesIdsFromMembership() {
+ $entity_type_id = $this->group->getEntityTypeId();
+ $bundle = $this->group->bundle();
+
+ $og_extra_role = OgRole::create()
+ ->setGroupType($entity_type_id)
+ ->setGroupBundle($bundle)
+ ->setName(mb_strtolower($this->randomMachineName()));
+ $og_extra_role->save();
+
+ $membership = OgMembership::create()
+ ->setGroup($this->group)
+ ->setOwner($this->user)
+ ->addRole($og_extra_role);
+ $membership->save();
+
+ $role_names = ['member', $og_extra_role->getName()];
+ $expected_ids = array_map(function ($role_name) use ($entity_type_id, $bundle) {
+ return "{$entity_type_id}-{$bundle}-{$role_name}";
+ }, $role_names);
+ $actual_ids = $membership->getRolesIds();
+
+ // Sort the two arrays before comparing so we can check the contents
+ // regardless of their order.
+ sort($expected_ids);
+ sort($actual_ids);
+
+ $this->assertEquals($expected_ids, $actual_ids, 'Role ids are built properly.');
+ }
+
/**
* Tests that the membership can return if it belongs to the group owner.
*
diff --git a/tests/src/Kernel/PermissionEventTest.php b/tests/src/Kernel/PermissionEventTest.php
index 59ecefacf..fa7a73bf4 100644
--- a/tests/src/Kernel/PermissionEventTest.php
+++ b/tests/src/Kernel/PermissionEventTest.php
@@ -131,8 +131,7 @@ public function permissionEventDataProvider() {
'administer group',
'approve and deny subscription',
'manage members',
- 'manage permissions',
- 'manage roles',
+ 'administer permissions',
'subscribe without approval',
'subscribe',
'update group',