diff --git a/CHANGELOG.md b/CHANGELOG.md index c2bb962b03..94e227db7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ HumHub Changelog - Fix #6108: Fix log time in the `date()` function - Fix #6122: Fix deleting a content with empty reason - Fix #6128: Reset backuped content after submit form +- Fix #6142: Fix saving empty values in admin settings 1.13.1 (January 25, 2023) ------------------------- diff --git a/protected/humhub/modules/admin/models/forms/DesignSettingsForm.php b/protected/humhub/modules/admin/models/forms/DesignSettingsForm.php index 2e9016f49d..4350ce64e0 100644 --- a/protected/humhub/modules/admin/models/forms/DesignSettingsForm.php +++ b/protected/humhub/modules/admin/models/forms/DesignSettingsForm.php @@ -67,6 +67,7 @@ class DesignSettingsForm extends Model public function rules() { return [ + ['paginationSize', 'required'], ['paginationSize', 'integer', 'max' => 200, 'min' => 1], ['theme', 'in', 'range' => $this->getThemes()], [['displayNameFormat', 'displayNameSubFormat', 'spaceOrder'], 'safe'], diff --git a/protected/humhub/modules/admin/models/forms/FileSettingsForm.php b/protected/humhub/modules/admin/models/forms/FileSettingsForm.php index ca9d63e2e2..6ba658cf7b 100644 --- a/protected/humhub/modules/admin/models/forms/FileSettingsForm.php +++ b/protected/humhub/modules/admin/models/forms/FileSettingsForm.php @@ -43,7 +43,9 @@ class FileSettingsForm extends \yii\base\Model { return [ [['allowedExtensions'], 'match', 'pattern' => '/^[A-Za-z0-9_,]+$/u'], - [['maxFileSize', 'useXSendfile', 'excludeMediaFilesPreview'], 'integer'], + [['useXSendfile', 'excludeMediaFilesPreview'], 'integer'], + [['maxFileSize'], 'required'], + [['maxFileSize'], 'integer', 'min' => 1], ]; } @@ -69,7 +71,7 @@ class FileSettingsForm extends \yii\base\Model public function save() { $settingsManager = Yii::$app->getModule('file')->settings; - $settingsManager->set('maxFileSize', $this->maxFileSize * 1024 * 1024); + $settingsManager->set('maxFileSize', (int) $this->maxFileSize * 1024 * 1024); $settingsManager->set('excludeMediaFilesPreview', $this->excludeMediaFilesPreview); $settingsManager->set('useXSendfile', $this->useXSendfile); $settingsManager->set('allowedExtensions', strtolower($this->allowedExtensions)); diff --git a/protected/humhub/modules/admin/views/setting/file.php b/protected/humhub/modules/admin/views/setting/file.php index 8cb60ba4fd..870ff3a583 100644 --- a/protected/humhub/modules/admin/views/setting/file.php +++ b/protected/humhub/modules/admin/views/setting/file.php @@ -18,8 +18,6 @@ $fileModule = Yii::$app->getModule('file'); true]); ?> -= $form->errorSummary($model); ?> - = $form->field($model, 'maxFileSize')->textInput(['class' => 'form-control', 'readonly' => $fileModule->settings->isFixed('maxFileSize')]); ?>
maxFileSize > $maxUploadSize) ? 'style="color:' . $this->theme->variable('danger') . ' !important"' : '' ?>> = Yii::t('AdminModule.settings', 'PHP reported a maximum of {maxUploadSize} MB', ['{maxUploadSize}' => $maxUploadSizeText]); ?> diff --git a/protected/humhub/modules/search/controllers/SearchController.php b/protected/humhub/modules/search/controllers/SearchController.php index 65a579966b..29de599fea 100644 --- a/protected/humhub/modules/search/controllers/SearchController.php +++ b/protected/humhub/modules/search/controllers/SearchController.php @@ -8,14 +8,13 @@ namespace humhub\modules\search\controllers; -use humhub\modules\user\widgets\Image; -use Yii; -use yii\data\Pagination; use humhub\components\Controller; use humhub\modules\space\models\Space; use humhub\modules\user\models\User; use humhub\modules\search\models\forms\SearchForm; use humhub\modules\search\engine\Search; +use Yii; +use yii\data\Pagination; /** * Search Controller provides search functions inside the application. @@ -43,7 +42,7 @@ class SearchController extends Controller { $this->appendPageTitle(\Yii::t('SearchModule.base', 'Search')); $this->view->setViewContext(static::VIEW_CONTEXT); - return parent::init(); + parent::init(); } /** @@ -74,7 +73,7 @@ class SearchController extends Controller $options = [ 'page' => $model->page, 'sort' => (empty($model->keyword)) ? 'title' : null, - 'pageSize' => Yii::$app->settings->get('paginationSize'), + 'pageSize' => $model->pageSize, 'limitSpaces' => $limitSpaces ]; diff --git a/protected/humhub/modules/search/engine/Search.php b/protected/humhub/modules/search/engine/Search.php index 6eb0fff995..510198ab42 100644 --- a/protected/humhub/modules/search/engine/Search.php +++ b/protected/humhub/modules/search/engine/Search.php @@ -8,16 +8,16 @@ namespace humhub\modules\search\engine; -use Yii; -use yii\base\Component; -use humhub\modules\search\interfaces\Searchable; use humhub\modules\content\models\Content; use humhub\modules\content\models\ContentTag; use humhub\modules\content\components\ContentActiveRecord; use humhub\modules\content\components\ContentContainerActiveRecord; use humhub\modules\user\models\User; -use humhub\modules\space\models\Space; use humhub\modules\search\events\SearchAttributesEvent; +use humhub\modules\search\interfaces\Searchable; +use humhub\modules\search\models\forms\SearchForm; +use humhub\modules\space\models\Space; +use yii\base\Component; /** * Description of HSearchComponent @@ -159,12 +159,12 @@ abstract class Search extends Component protected function setDefaultFindOptions($options) { - if (!isset($options['page']) || $options['page'] == '') { + if (empty($options['page'])) { $options['page'] = 1; } - if (!isset($options['pageSize']) || $options['pageSize'] == '') { - $options['pageSize'] = Yii::$app->settings->get('paginationSize'); + if (empty($options['pageSize'])) { + $options['pageSize'] = (new SearchForm())->pageSize; } if (!isset($options['checkPermissions'])) { diff --git a/protected/humhub/modules/search/models/forms/SearchForm.php b/protected/humhub/modules/search/models/forms/SearchForm.php index e2efc26ee5..69b3523069 100644 --- a/protected/humhub/modules/search/models/forms/SearchForm.php +++ b/protected/humhub/modules/search/models/forms/SearchForm.php @@ -24,13 +24,16 @@ class SearchForm extends Model public $keyword = ''; public $scope = ''; public $page = 1; + public $pageSize; public $limitSpaceGuids = []; public function init() { - if (Yii::$app->request->get('page')) { - $this->page = Yii::$app->request->get('page'); - } + $page = (int) Yii::$app->request->get('page'); + $this->page = $page < 1 ? 1 : $page; + + $pageSize = (int) Yii::$app->settings->get('paginationSize'); + $this->pageSize = $pageSize < 1 ? 1 : $pageSize; } /**