materio-d9/patches/flaglist-flaglistspermissio...

25 lines
1.3 KiB
Diff
Raw Permalink Normal View History

2021-12-08 11:10:56 +01:00
diff --git a/src/Permissions/FlagListsPermissionHandler.php b/src/Permissions/FlagListsPermissionHandler.php
index 3d08b98..baab066 100644
--- a/src/Permissions/FlagListsPermissionHandler.php
+++ b/src/Permissions/FlagListsPermissionHandler.php
@@ -49,10 +49,15 @@ class FlagListsPermissionHandler extends PermissionHandler {
// due to the flag lists module.
$flagLists = $this->flagListsService->getAllFlaggingCollections();
foreach ($flagLists as $flagList) {
- $flag = 'flag ' . $flagList->getRelatedFlag()->id();
- $unflag = 'unflag ' . $flagList->getRelatedFlag()->id();
- unset($all_permissions[$flag]);
- unset($all_permissions[$unflag]);
+ if ($flagList->getRelatedFlag()) {
+ $flag = 'flag ' . $flagList->getRelatedFlag()->id();
+ $unflag = 'unflag ' . $flagList->getRelatedFlag()->id();
+ unset($all_permissions[$flag]);
+ unset($all_permissions[$unflag]);
+ } else {
+ $logger = \Drupal::logger('flag_lists');
+ $logger->error('flagging_collection ' . $flagList->getName() . ' (' . $flagList->id() . ')' . ' owned by user id ' . $flagList->getOwner()->id() . ' doesn\'t have related flag');
+ }
}
// Check for access for the used template as well.
$flagTemplates = $this->flagListsService->getAllFlagForList();