From 366823d3b1541b142d4fa2b1efe6bc9fdc332d40 Mon Sep 17 00:00:00 2001 From: Gevorg Mansuryan Date: Wed, 2 Oct 2024 11:11:15 +0400 Subject: [PATCH] File settings max size fix (#7240) * File Settings size fix * File Settings size fix --- CHANGELOG.md | 1 + .../humhub/modules/admin/models/forms/FileSettingsForm.php | 6 ++++-- protected/humhub/modules/installer/libs/InitialData.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fafc71d79..377bffeb53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ HumHub Changelog - Enh #7233: Mobile view: enlarge images in gallery preview of entries for the wall stream - Enh #7237: Changed PoweredBy URL - Enh #7238: Fixed PHP warning related to `.env` +- Enh #7240: Fixed maximum file size setting in initialization 1.16.3 (Unreleased) -------------------------- diff --git a/protected/humhub/modules/admin/models/forms/FileSettingsForm.php b/protected/humhub/modules/admin/models/forms/FileSettingsForm.php index 37af109118..794726b5c6 100644 --- a/protected/humhub/modules/admin/models/forms/FileSettingsForm.php +++ b/protected/humhub/modules/admin/models/forms/FileSettingsForm.php @@ -88,10 +88,12 @@ class FileSettingsForm extends Model $fileSizeKey = 'post_max_size'; } + $maxUploadSizeInMb = $maxUploadSize / 1024 / 1024; + return [ $fileSizeKey, - floor($maxUploadSize / 1024 / 1024), - min($maxUploadSize, 64), + $maxUploadSizeInMb, + min($maxUploadSizeInMb, 64), ]; } diff --git a/protected/humhub/modules/installer/libs/InitialData.php b/protected/humhub/modules/installer/libs/InitialData.php index 620edf1490..5f71efa40b 100644 --- a/protected/humhub/modules/installer/libs/InitialData.php +++ b/protected/humhub/modules/installer/libs/InitialData.php @@ -60,7 +60,7 @@ class InitialData // File [,,$defaultMaxUploadSize] = FileSettingsForm::getPHPMaxUploadSize(); - Yii::$app->getModule('file')->settings->set('maxFileSize', $defaultMaxUploadSize); + Yii::$app->getModule('file')->settings->set('maxFileSize', $defaultMaxUploadSize * 1024 * 1024); Yii::$app->getModule('file')->settings->set('excludeMediaFilesPreview', '1'); // Caching