diff --git a/protected/humhub/docs/CHANGELOG.md b/protected/humhub/docs/CHANGELOG.md index 32f203b826..03ab344a47 100644 --- a/protected/humhub/docs/CHANGELOG.md +++ b/protected/humhub/docs/CHANGELOG.md @@ -9,6 +9,8 @@ HumHub Change Log - Fix #3914: Directory link in space chooser still visible when directory module not active - Fix #3915: Removed default border from canvas style - Fix #3885: Prevent comments on archived content +- Fix #3940: Empty visibility for some new spaces + 1.4.3 (March 4, 2020) --------------------- diff --git a/protected/humhub/modules/space/controllers/CreateController.php b/protected/humhub/modules/space/controllers/CreateController.php index 8147642513..db74c5e967 100644 --- a/protected/humhub/modules/space/controllers/CreateController.php +++ b/protected/humhub/modules/space/controllers/CreateController.php @@ -83,9 +83,11 @@ class CreateController extends Controller $visibilityOptions[Space::VISIBILITY_NONE] = Yii::t('SpaceModule.base', 'Private (Invisible)'); } - // allow setting pre-selected visibility if ($visibility !== null && isset($visibilityOptions[$visibility])) { + // allow setting pre-selected visibility $model->visibility = $visibility; + } elseif (!isset($visibilityOptions[$model->visibility])) { + $model->visibility = array_key_first($visibilityOptions); } $joinPolicyOptions = [ diff --git a/protected/humhub/modules/space/migrations/m200323_162006_fix_visibility.php b/protected/humhub/modules/space/migrations/m200323_162006_fix_visibility.php new file mode 100644 index 0000000000..87ef8be3de --- /dev/null +++ b/protected/humhub/modules/space/migrations/m200323_162006_fix_visibility.php @@ -0,0 +1,42 @@ +update('space', ['visibility' => 0], 'visibility IS NULL'); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + echo "m200323_162006_fix_visibility cannot be reverted.\n"; + + return false; + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m200323_162006_fix_visibility cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/protected/humhub/modules/space/models/Space.php b/protected/humhub/modules/space/models/Space.php index 6f2cba1f7b..94af95f87b 100644 --- a/protected/humhub/modules/space/models/Space.php +++ b/protected/humhub/modules/space/models/Space.php @@ -241,6 +241,11 @@ class Space extends ContentContainerActiveRecord implements Searchable $this->url = mb_strtolower($this->url); } + // Make sure visibility attribute is not empty + if (empty($this->visibility)) { + $this->visibility = self::VISIBILITY_NONE; + } + if ($this->visibility == self::VISIBILITY_NONE) { $this->join_policy = self::JOIN_POLICY_NONE; $this->default_content_visibility = Content::VISIBILITY_PRIVATE;