@@ -206,10 +206,17 @@ public function cancelGroupJoinRequest(UnityUser $user, bool $send_mail = true):
206206 // // now we delete the ldap entry
207207 // $this->entry->ensureExists();
208208 // $this->entry->delete();
209- // $this->REDIS->removeCacheArray("sorted_groups", "", $this->gid);
209+ // $default_value_getter = [$this->LDAP, "getSortedGroupsForRedis"];
210+ // $this->REDIS->removeCacheArray("sorted_groups", "", $this->gid, $default_value_getter);
210211 // foreach ($users as $user) {
211- // $this->REDIS->removeCacheArray($user->uid, "groups", $this->gid);
212+ // $this->REDIS->removeCacheArray(
213+ // $user->uid,
214+ // "groups",
215+ // $this->gid,
216+ // fn() => $this->getGroupMemberUIDs(true),
217+ // );
212218 // }
219+ // // FIXME group not removed from user's groups array
213220
214221 // // send email to every user of the now deleted PI group
215222 // if ($send_mail) {
@@ -417,7 +424,8 @@ private function init(): void
417424 $ this ->entry ->setAttribute ("gidnumber " , strval ($ nextGID ));
418425 $ this ->entry ->setAttribute ("memberuid " , [$ owner ->uid ]);
419426 $ this ->entry ->write ();
420- $ this ->REDIS ->appendCacheArray ("sorted_groups " , "" , $ this ->gid );
427+ $ default_value_getter = [$ this ->LDAP , "getSortedGroupsForRedis " ];
428+ $ this ->REDIS ->appendCacheArray ("sorted_groups " , "" , $ this ->gid , $ default_value_getter );
421429 // TODO if we ever make this project based,
422430 // we need to update the cache here with the memberuid
423431 }
@@ -426,16 +434,36 @@ private function addUserToGroup(UnityUser $new_user): void
426434 {
427435 $ this ->entry ->appendAttribute ("memberuid " , $ new_user ->uid );
428436 $ this ->entry ->write ();
429- $ this ->REDIS ->appendCacheArray ($ this ->gid , "members " , $ new_user ->uid );
430- $ this ->REDIS ->appendCacheArray ($ new_user ->uid , "groups " , $ this ->gid );
437+ $ this ->REDIS ->appendCacheArray (
438+ $ this ->gid ,
439+ "members " ,
440+ $ new_user ->uid ,
441+ fn () => $ this ->getGroupMemberUIDs (true ),
442+ );
443+ $ this ->REDIS ->appendCacheArray (
444+ $ new_user ->uid ,
445+ "groups " ,
446+ $ this ->gid ,
447+ fn () => $ this ->LDAP ->getPIGroupGIDsWithMemberUID ($ new_user ->uid ),
448+ );
431449 }
432450
433451 private function removeUserFromGroup (UnityUser $ old_user ): void
434452 {
435453 $ this ->entry ->removeAttributeEntryByValue ("memberuid " , $ old_user ->uid );
436454 $ this ->entry ->write ();
437- $ this ->REDIS ->removeCacheArray ($ this ->gid , "members " , $ old_user ->uid );
438- $ this ->REDIS ->removeCacheArray ($ old_user ->uid , "groups " , $ this ->gid );
455+ $ this ->REDIS ->removeCacheArray (
456+ $ this ->gid ,
457+ "members " ,
458+ $ old_user ->uid ,
459+ fn () => $ this ->getGroupMemberUIDs (true ),
460+ );
461+ $ this ->REDIS ->removeCacheArray (
462+ $ old_user ->uid ,
463+ "groups " ,
464+ $ this ->gid ,
465+ fn () => $ this ->LDAP ->getPIGroupGIDsWithMemberUID ($ old_user ->uid ),
466+ );
439467 }
440468
441469 public function memberExists (UnityUser $ user ): bool
0 commit comments