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
This commit is contained in:
Yuriy Bakhtin 2024-08-07 15:20:45 +03:00 committed by GitHub
parent f497f14825
commit de2027b913
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -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)
---------------------

View File

@ -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();
}
}
}
/**