From ca3833e6e18833549a4c2d826364a902bdd6032b Mon Sep 17 00:00:00 2001 From: Lucas Bartholemy Date: Thu, 27 Feb 2020 11:27:14 +0100 Subject: [PATCH] Fix #3883: Former & soft deleted LDAP user produces multiple warnings --- protected/humhub/docs/CHANGELOG.md | 3 +- .../modules/ldap/authclient/LdapAuth.php | 4 +- ...200218_122109_profile_translation_fix2.php | 42 +++++++++++++++++++ protected/humhub/modules/user/models/User.php | 3 +- 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 protected/humhub/modules/user/migrations/m200218_122109_profile_translation_fix2.php diff --git a/protected/humhub/docs/CHANGELOG.md b/protected/humhub/docs/CHANGELOG.md index 7c761f6679..61cd9948ae 100644 --- a/protected/humhub/docs/CHANGELOG.md +++ b/protected/humhub/docs/CHANGELOG.md @@ -1,7 +1,7 @@ HumHub Change Log ================= -1.4.2 +1.4.2 (Februrary 27, 2020) -------------------------- - Fix #3865: "Use default swipe" setting not working @@ -12,6 +12,7 @@ HumHub Change Log - Fix #3866: Emoji chooser broken after pjax link - Enh: Added emoji richtext menu item - Enh: Updated humhub richtext version to 1.0.20 +- Fix #3883: Former & soft deleted LDAP user produces multiple warnings 1.4.1 (Februrary 17, 2020) diff --git a/protected/humhub/modules/ldap/authclient/LdapAuth.php b/protected/humhub/modules/ldap/authclient/LdapAuth.php index c807baa3d2..e6ccfc2130 100644 --- a/protected/humhub/modules/ldap/authclient/LdapAuth.php +++ b/protected/humhub/modules/ldap/authclient/LdapAuth.php @@ -213,8 +213,8 @@ class LdapAuth extends BaseFormAuth implements AutoSyncUsers, SyncAttributes, Ap * Find user based on ldap attributes * * @inheritdoc - * @see PrimaryClient * @return User the user + * @see PrimaryClient */ public function getUser() { @@ -510,7 +510,7 @@ class LdapAuth extends BaseFormAuth implements AutoSyncUsers, SyncAttributes, Ap $user->status = User::STATUS_ENABLED; $user->save(); Yii::info('Enabled user' . $user->username . ' (' . $user->id . ') - found in LDAP!', 'ldap'); - } elseif (!$foundInLdap && $user->status !== User::STATUS_DISABLED) { + } elseif (!$foundInLdap && $user->status == User::STATUS_ENABLED) { // Disable users that were not found in ldap $user->status = User::STATUS_DISABLED; $user->save(); diff --git a/protected/humhub/modules/user/migrations/m200218_122109_profile_translation_fix2.php b/protected/humhub/modules/user/migrations/m200218_122109_profile_translation_fix2.php new file mode 100644 index 0000000000..b5f642c016 --- /dev/null +++ b/protected/humhub/modules/user/migrations/m200218_122109_profile_translation_fix2.php @@ -0,0 +1,42 @@ +update('profile_field', ['translation_category' => 'UserModule.profile'], ['translation_category' => 'UserModule.models_Profile']); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + echo "m200217_122108_profile_translation_fix cannot be reverted.\n"; + + return false; + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m200217_122108_profile_translation_fix cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/protected/humhub/modules/user/models/User.php b/protected/humhub/modules/user/models/User.php index b105d4ec45..8c7f16f0dc 100644 --- a/protected/humhub/modules/user/models/User.php +++ b/protected/humhub/modules/user/models/User.php @@ -439,7 +439,8 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se $this->updateAttributes([ 'email' => new Expression('NULL'), 'username' => 'deleted-' . $this->id, - 'status' => User::STATUS_SOFT_DELETED + 'status' => User::STATUS_SOFT_DELETED, + 'authclient_id' => new Expression('NULL') ]); return true;