@@ -184,10 +184,17 @@ public function cancelGroupJoinRequest(UnityUser $user, bool $send_mail = true):
184184 // // now we delete the ldap entry
185185 // $this->entry->ensureExists();
186186 // $this->entry->delete();
187- // $this->REDIS->removeCacheArray("sorted_groups", "", $this->gid);
187+ // $default_value_getter = [$this->LDAP, "getSortedGroupsForRedis"];
188+ // $this->REDIS->removeCacheArray("sorted_groups", "", $this->gid, $default_value_getter);
188189 // foreach ($users as $user) {
189- // $this->REDIS->removeCacheArray($user->uid, "groups", $this->gid);
190+ // $this->REDIS->removeCacheArray(
191+ // $user->uid,
192+ // "groups",
193+ // $this->gid,
194+ // fn() => $this->getGroupMemberUIDs(true),
195+ // );
190196 // }
197+ // // FIXME group not removed from user's groups array
191198
192199 // // send email to every user of the now deleted PI group
193200 // if ($send_mail) {
@@ -376,7 +383,8 @@ private function init(): void
376383 $ this ->entry ->setAttribute ("gidnumber " , strval ($ nextGID ));
377384 $ this ->entry ->setAttribute ("memberuid " , [$ owner ->uid ]);
378385 $ this ->entry ->write ();
379- $ this ->REDIS ->appendCacheArray ("sorted_groups " , "" , $ this ->gid );
386+ $ default_value_getter = [$ this ->LDAP , "getSortedGroupsForRedis " ];
387+ $ this ->REDIS ->appendCacheArray ("sorted_groups " , "" , $ this ->gid , $ default_value_getter );
380388 // TODO if we ever make this project based,
381389 // we need to update the cache here with the memberuid
382390 }
@@ -385,16 +393,36 @@ private function addUserToGroup(UnityUser $new_user): void
385393 {
386394 $ this ->entry ->appendAttribute ("memberuid " , $ new_user ->uid );
387395 $ this ->entry ->write ();
388- $ this ->REDIS ->appendCacheArray ($ this ->gid , "members " , $ new_user ->uid );
389- $ this ->REDIS ->appendCacheArray ($ new_user ->uid , "groups " , $ this ->gid );
396+ $ this ->REDIS ->appendCacheArray (
397+ $ this ->gid ,
398+ "members " ,
399+ $ new_user ->uid ,
400+ fn () => $ this ->getGroupMemberUIDs (true ),
401+ );
402+ $ this ->REDIS ->appendCacheArray (
403+ $ new_user ->uid ,
404+ "groups " ,
405+ $ this ->gid ,
406+ fn () => $ this ->LDAP ->getPIGroupGIDsWithMemberUID ($ new_user ->uid ),
407+ );
390408 }
391409
392410 private function removeUserFromGroup (UnityUser $ old_user ): void
393411 {
394412 $ this ->entry ->removeAttributeEntryByValue ("memberuid " , $ old_user ->uid );
395413 $ this ->entry ->write ();
396- $ this ->REDIS ->removeCacheArray ($ this ->gid , "members " , $ old_user ->uid );
397- $ this ->REDIS ->removeCacheArray ($ old_user ->uid , "groups " , $ this ->gid );
414+ $ this ->REDIS ->removeCacheArray (
415+ $ this ->gid ,
416+ "members " ,
417+ $ old_user ->uid ,
418+ fn () => $ this ->getGroupMemberUIDs (true ),
419+ );
420+ $ this ->REDIS ->removeCacheArray (
421+ $ old_user ->uid ,
422+ "groups " ,
423+ $ this ->gid ,
424+ fn () => $ this ->LDAP ->getPIGroupGIDsWithMemberUID ($ old_user ->uid ),
425+ );
398426 }
399427
400428 public function memberExists (UnityUser $ user ): bool
0 commit comments