From de2027b913369764d5f571a9f27cd828bf14df5a Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Wed, 7 Aug 2024 15:20:45 +0300 Subject: [PATCH] Fix duplicated following spaces in the chooser widget (#7156) * Fix duplicated following spaces in the chooser widget * Integrity check to delete space following if user is a member --- CHANGELOG.md | 1 + protected/humhub/modules/space/Events.php | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d070f9a77..2bd0ba248f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ HumHub Changelog - Fix #7146: Fix search request by container guid - Fix #7141: Fix meta searching twice for the same keyword - Fix #7150: Remove js statement `with` to avoid error on build assets by grunt uglify +- Fix #7156: Fix duplicated following spaces in the chooser widget 1.16.1 (July 1, 2024) --------------------- diff --git a/protected/humhub/modules/space/Events.php b/protected/humhub/modules/space/Events.php index 24a52d6472..86068dae76 100644 --- a/protected/humhub/modules/space/Events.php +++ b/protected/humhub/modules/space/Events.php @@ -14,6 +14,7 @@ use humhub\modules\user\events\UserEvent; use humhub\modules\space\models\Space; use humhub\modules\space\models\Membership; use humhub\modules\space\helpers\MembershipHelper; +use humhub\modules\user\models\Follow; use Yii; use yii\base\BaseObject; use humhub\components\Event; @@ -85,6 +86,18 @@ class Events extends BaseObject } } } + + $integrityController->showTestHeadline('Space Module - Follow (' . Follow::find()->where(['object_model' => Space::class])->count() . ' entries)'); + $follows = Follow::find() + ->innerJoin('space_membership', 'space_membership.user_id = user_follow.user_id AND space_membership.space_id = user_follow.object_id') + ->where(['user_follow.object_model' => Space::class]) + ->andWhere(['space_membership.status' => Membership::STATUS_MEMBER]); + foreach ($follows->each() as $follow) { + /* @var Follow $follow */ + if ($integrityController->showFix('Deleting a following of user #' . $follow->user_id . ' to space #' . $follow->object_id . ' because of membership!')) { + $follow->delete(); + } + } } /**