Rename cahce config keys (#7346)

* Change cache settings key to meet dot env naming

* Change cache settings keys to meet dot env naming

* Change cache settings keys to meet dot env naming

* Change cache settings keys to meet dot env naming
This commit is contained in:
Gevorg Mansuryan 2024-12-16 01:07:59 +04:00 committed by GitHub
parent c231e5c309
commit 0f28b87266
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 28 additions and 27 deletions

View File

@ -35,6 +35,7 @@ HumHub Changelog
- Fix #7301: Profile header: on small screens, the space at the left and the right of the image must be equal
- Fix #7298: Don't check email for existing on password recovery (CVE-2024-52043)
- Enh #7038: Optimize notification overview
- Enh #7346: Change cache settings keys to meet dot env naming
1.17.0-beta.1 (October 28, 2024)
--------------------------------

View File

@ -91,7 +91,7 @@ class DynamicConfig extends BaseObject
$config['name'] = Yii::$app->settings->get('name');
// Add Caching
$cacheClass = Yii::$app->settings->get('cache.class');
$cacheClass = Yii::$app->settings->get('cacheClass');
if (in_array($cacheClass, ['yii\caching\DummyCache', 'yii\caching\FileCache'])) {
$config['components']['cache'] = [
'class' => $cacheClass,
@ -189,7 +189,7 @@ class DynamicConfig extends BaseObject
public static function needRewrite($moduleId, $name)
{
return (in_array($name, [
'name', 'defaultLanguage', 'timeZone', 'cache.class', 'mailer.transportType',
'name', 'defaultLanguage', 'timeZone', 'cacheClass', 'mailer.transportType',
'mailer.hostname', 'mailer.username', 'mailer.password', 'mailer.encryption',
'mailer.port', 'horImageScrollOnMobile']));
}

View File

@ -1,7 +1,7 @@
<?php
use yii\db\Migration;
use yii\db\Expression;
use yii\db\Migration;
class m160508_005740_settings_cleanup extends Migration
{

View File

@ -29,9 +29,9 @@ class CacheSettingsForm extends Model
parent::init();
$settingsManager = Yii::$app->settings;
$this->type = $settingsManager->get('cache.class');
$this->expireTime = $settingsManager->get('cache.expireTime');
$this->reloadableScripts = $settingsManager->get('cache.reloadableScripts');
$this->type = $settingsManager->get('cacheClass');
$this->expireTime = $settingsManager->get('cacheExpireTime');
$this->reloadableScripts = $settingsManager->get('cacheReloadableScript');
}
/**
@ -45,10 +45,10 @@ class CacheSettingsForm extends Model
['type', 'checkCacheType'],
['expireTime', 'integer'],
['type', 'required', 'when' => function () {
return !Yii::$app->settings->isFixed('cache.class');
return !Yii::$app->settings->isFixed('cacheClass');
}],
['type', 'in', 'range' => array_keys($this->getTypes()), 'when' => function () {
return !Yii::$app->settings->isFixed('cache.class');
return !Yii::$app->settings->isFixed('cacheClass');
}],
];
}
@ -102,9 +102,9 @@ class CacheSettingsForm extends Model
{
$settingsManager = Yii::$app->settings;
$settingsManager->set('cache.class', $this->type);
$settingsManager->set('cache.expireTime', $this->expireTime);
$settingsManager->set('cache.reloadableScripts', $this->reloadableScripts);
$settingsManager->set('cacheClass', $this->type);
$settingsManager->set('cacheExpireTime', $this->expireTime);
$settingsManager->set('cacheReloadableScript', $this->reloadableScripts);
DynamicConfig::rewrite();
self::flushCache();

View File

@ -1,8 +1,8 @@
<?php
use humhub\modules\admin\models\forms\CacheSettingsForm;
use humhub\widgets\Button;
use humhub\modules\ui\form\widgets\ActiveForm;
use humhub\widgets\Button;
/* @var $cacheTypes [] */
/* @var $model CacheSettingsForm */
@ -13,11 +13,11 @@ use humhub\modules\ui\form\widgets\ActiveForm;
<?php $form = ActiveForm::begin(['acknowledge' => true]); ?>
<?php if (!Yii::$app->settings->isFixed('cache.class')): ?>
<?= $form->field($model, 'type')->dropDownList($cacheTypes, ['readonly' => Yii::$app->settings->isFixed('cache.class')]) ?>
<?php if (!Yii::$app->settings->isFixed('cacheClass')): ?>
<?= $form->field($model, 'type')->dropDownList($cacheTypes, ['readonly' => Yii::$app->settings->isFixed('cacheClass')]) ?>
<?php endif; ?>
<?= $form->field($model, 'expireTime')->textInput(['readonly' => Yii::$app->settings->isFixed('cache.expireTime')]) ?>
<?= $form->field($model, 'expireTime')->textInput(['readonly' => Yii::$app->settings->isFixed('cacheExpireTime')]) ?>
<hr>
<?= Button::primary(Yii::t('AdminModule.settings', 'Save & Flush Caches'))->submit() ?>

View File

@ -252,7 +252,7 @@ class Comment extends ContentAddonActiveRecord
$comments[$limit] = array_reverse($query->all());
if ($useCaching) {
Yii::$app->cache->set($cacheID, $comments, Yii::$app->settings->get('cache.expireTime'));
Yii::$app->cache->set($cacheID, $comments, Yii::$app->settings->get('cacheExpireTime'));
}
}
@ -274,7 +274,7 @@ class Comment extends ContentAddonActiveRecord
if ($commentCount === false) {
$commentCount = Comment::find()->where(['object_model' => $model, 'object_id' => $id])->count();
Yii::$app->cache->set($cacheID, $commentCount, Yii::$app->settings->get('cache.expireTime'));
Yii::$app->cache->set($cacheID, $commentCount, Yii::$app->settings->get('cacheExpireTime'));
}
return $commentCount;

View File

@ -63,8 +63,8 @@ class InitialData
Yii::$app->getModule('file')->settings->set('excludeMediaFilesPreview', '1');
// Caching
Yii::$app->settings->set('cache.class', 'yii\caching\FileCache');
Yii::$app->settings->set('cache.expireTime', '3600');
Yii::$app->settings->set('cacheClass', 'yii\caching\FileCache');
Yii::$app->settings->set('cacheExpireTime', '3600');
Yii::$app->getModule('admin')->settings->set('installationId', md5(uniqid("", true)));
// Design

View File

@ -9,11 +9,11 @@
namespace humhub\modules\like\models;
use humhub\components\behaviors\PolymorphicRelation;
use humhub\modules\like\activities\Liked;
use Yii;
use humhub\modules\content\components\ContentAddonActiveRecord;
use humhub\modules\content\interfaces\ContentOwner;
use humhub\modules\like\activities\Liked;
use humhub\modules\like\notifications\NewLike;
use Yii;
use yii\db\ActiveRecord;
/**
@ -88,7 +88,7 @@ class Like extends ContentAddonActiveRecord
->with('user')
->all();
},
Yii::$app->settings->get('cache.expireTime'),
Yii::$app->settings->get('cacheExpireTime'),
);
}

View File

@ -18,10 +18,10 @@ use RecursiveIteratorIterator;
use Yii;
use yii\base\Component;
use yii\base\ErrorException;
use yii\base\InvalidConfigException;
use yii\web\HttpException;
use yii\base\Exception;
use yii\base\InvalidConfigException;
use yii\helpers\FileHelper;
use yii\web\HttpException;
use yii\web\ServerErrorHttpException;
use ZipArchive;
@ -259,7 +259,7 @@ class OnlineModuleManager extends Component
unset($this->_modules[$blacklistedModuleId]);
}
Yii::$app->cache->set('onlineModuleManager_modules', $this->_modules, Yii::$app->settings->get('cache.expireTime'));
Yii::$app->cache->set('onlineModuleManager_modules', $this->_modules, Yii::$app->settings->get('cacheExpireTime'));
}
return $this->_modules;

View File

@ -23,8 +23,8 @@ return [
['name' => 'receive_email_notifications', 'value' => '2', 'module_id' => 'notification'],
['name' => 'maxFileSize', 'value' => '1048576', 'module_id' => 'file'],
['name' => 'forbiddenExtensions', 'value' => 'exe', 'module_id' => 'file'],
['name' => 'cache.class', 'value' => 'CFileCache', 'module_id' => 'base'],
['name' => 'cache.expireTime', 'value' => '3600', 'module_id' => 'base'],
['name' => 'cacheClass', 'value' => 'CFileCache', 'module_id' => 'base'],
['name' => 'cacheExpireTime', 'value' => '3600', 'module_id' => 'base'],
['name' => 'installationId', 'value' => '99846c45e9b9b0962238986a6fed519a', 'module_id' => 'admin'],
['name' => 'theme', 'value' => 'HumHub', 'module_id' => 'base'],
['name' => 'tour', 'value' => '1', 'module_id' => 'base'],