Fix: User soft deletion membership cache overwrite

This commit is contained in:
Lucas Bartholemy 2019-01-23 14:42:55 +01:00
parent 38c3ae0903
commit e7d265433c
4 changed files with 6 additions and 4 deletions

View File

@ -11,6 +11,7 @@ HumHub Change Log
- Fix: Include user profile posts option in dashboard stream broken
- Fix: Check SoftDeleted user state in ControllerAccess
- Fix: Removed database charset configuration in dynamic config
- Fix: User soft deletion membership cache overwrite
1.3.8 (December 10, 2018)

View File

@ -102,7 +102,7 @@ class UserDeleteForm extends Model
}
// Handle owned spaces by the deleted user
$ownedSpaces = MembershipHelper::getOwnSpaces($this->user);
$ownedSpaces = MembershipHelper::getOwnSpaces($this->user, false);
if (count($ownedSpaces) !== 0 && empty($this->deleteSpaces)) {
foreach ($ownedSpaces as $space) {
$space->addMember(Yii::$app->user->id);

View File

@ -26,16 +26,17 @@ class MembershipHelper
* Returns an array of spaces where the given user is owner.
*
* @param User|null $user the user or null for current user
* @param boolean $useCache use cached result if available
* @return Space[] the list of spaces
*/
public static function getOwnSpaces(User $user = null)
public static function getOwnSpaces(User $user = null, $useCache = true)
{
if ($user === null) {
$user = Yii::$app->user->getIdentity();
}
$spaces = [];
foreach (Membership::GetUserSpaces($user->id) as $space) {
foreach (Membership::GetUserSpaces($user->id, $useCache) as $space) {
if ($space->isSpaceOwner($user->id)) {
$spaces[] = $space;
}

View File

@ -397,7 +397,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
public function softDelete()
{
// Delete spaces which are owned by this user.
foreach (MembershipHelper::getOwnSpaces($this) as $space) {
foreach (MembershipHelper::getOwnSpaces($this, false) as $space) {
$space->delete();
}