From 0f5ef6b2f38647eb280e93225b49284171997238 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Mon, 5 Jun 2023 13:25:50 +0400 Subject: [PATCH] Use integer format for Content columns "visibility" and "state" right after creating (#6373) --- CHANGELOG.md | 1 + .../humhub/modules/content/services/ContentStateService.php | 4 +++- .../humhub/modules/content/widgets/WallCreateContentForm.php | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ffbc957f9..16495e1e6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ HumHub Changelog - Fix #6345: Fix updating of post on wall stream - Fix #6351: Error when config `defaultReloadableScripts` is not array - Fix #6359: Avoid double call of `afterSave` on creating of a published content +- Fix #6373: Use integer format for Content columns "visibility" and "state" right after creating 1.14.2 (May 22, 2023) ---------------------- diff --git a/protected/humhub/modules/content/services/ContentStateService.php b/protected/humhub/modules/content/services/ContentStateService.php index 78b53f3ee5..76a45cf880 100644 --- a/protected/humhub/modules/content/services/ContentStateService.php +++ b/protected/humhub/modules/content/services/ContentStateService.php @@ -113,11 +113,13 @@ class ContentStateService extends Component */ public function set($state, array $options = []): bool { + $state = (int) $state; + if (!$this->canChange($state)) { return false; } - if ((int) $state === Content::STATE_SCHEDULED) { + if ($state === Content::STATE_SCHEDULED) { if (empty($options['scheduled_at'])) { return false; } diff --git a/protected/humhub/modules/content/widgets/WallCreateContentForm.php b/protected/humhub/modules/content/widgets/WallCreateContentForm.php index 56ba5df70f..f25f41892f 100644 --- a/protected/humhub/modules/content/widgets/WallCreateContentForm.php +++ b/protected/humhub/modules/content/widgets/WallCreateContentForm.php @@ -107,8 +107,8 @@ abstract class WallCreateContentForm extends Widget { Yii::$app->response->format = 'json'; - $visibility = Yii::$app->request->post('visibility', Content::VISIBILITY_PRIVATE); - if ($visibility == Content::VISIBILITY_PUBLIC && !$contentContainer->can(CreatePublicContent::class)) { + $visibility = (int) Yii::$app->request->post('visibility', Content::VISIBILITY_PRIVATE); + if ($visibility === Content::VISIBILITY_PUBLIC && !$contentContainer->can(CreatePublicContent::class)) { $visibility = Content::VISIBILITY_PRIVATE; }