Merge branch 'develop' into next

This commit is contained in:
Lucas Bartholemy 2025-03-06 15:47:39 +01:00
commit 337bc4d0b0
4 changed files with 28 additions and 43 deletions

View File

@ -16,9 +16,10 @@ HumHub Changelog
- Enh #7454: Upgrade compose packages
- Fix #7443: Exclude inactive users from `followers` and `following` lists
- Fix #7447: Update the comment counter when deleting a comment
- Fix #7456: Fix setting manager backwards compatibility
1.17.1 (Unreleased)
-------------------
1.17.1 (March 6, 2025)
----------------------
- Fix #7377: Configured Redis cache key prefix was overwritten by the default value
- Fix #7375: Use default language for email invitation and show language chooser on registration form
- Enh #7383: Improve SelfTest for Base URL

View File

@ -11,6 +11,7 @@ namespace humhub\libs;
use humhub\components\InstallationState;
use humhub\components\SettingActiveRecord;
use humhub\exceptions\InvalidArgumentTypeException;
use humhub\models\Setting;
use Stringable;
use Yii;
use yii\base\Component;
@ -155,6 +156,8 @@ abstract class BaseSettingsManager extends Component
*/
public function get(string $name, $default = null)
{
$name = Setting::fixDeprecatedSettingKeys($name);
$value = $this->_loaded[$name] ?? null;
// make sure it is an int, if it is possible

View File

@ -10,6 +10,7 @@ namespace humhub\models;
use humhub\components\InstallationState;
use humhub\components\SettingActiveRecord;
use humhub\helpers\ArrayHelper;
use Yii;
use yii\base\Exception;
@ -67,7 +68,7 @@ class Setting extends SettingActiveRecord
*/
public static function get($name, $moduleId = '')
{
list($name, $moduleId) = self::fixModuleIdAndName($name, $moduleId);
$name = self::fixDeprecatedSettingKeys($name);
return self::getModule($moduleId)->settings->get($name);
}
@ -82,7 +83,7 @@ class Setting extends SettingActiveRecord
*/
public static function set($name, $value, $moduleId = '')
{
list($name, $moduleId) = self::fixModuleIdAndName($name, $moduleId);
$name = self::fixDeprecatedSettingKeys($name);
return self::getModule($moduleId)->settings->set($name, $value);
}
@ -136,45 +137,25 @@ class Setting extends SettingActiveRecord
* @deprecated since version 1.1
*
* @param string $name
* @param string $moduleId
*/
public static function fixModuleIdAndName($name, $moduleId = '')
public static function fixDeprecatedSettingKeys($name)
{
static $translation = [
'authentication_internal' => [
'allowGuestAccess' => ['allowGuestAccess', 'user'],
'defaultUserGroup' => ['auth.allowGuestAccess', 'user'],
],
'mailing' => [
'systemEmailAddress' => ['mailerSystemEmailAddress', 'user'],
'mailing' => ['mailerSystemEmailName', 'user'],
'systemEmailReplyTo' => ['mailerSystemEmailReplyTo', 'user'],
],
'proxy' => [
'enabled' => ['proxy.enabled', 'base'],
'server' => ['proxy.server', 'base'],
'port' => ['proxy.port', 'base'],
'user' => ['proxy.user', 'base'],
'pass' => ['proxy.password', 'base'],
'noproxy' => ['proxy.noproxy', 'base'],
],
'' => [
'mailer.transportType' => ['mailerTransportType', 'base'],
'mailer.dsn' => ['mailerDsn', 'base'],
'mailer.hostname' => ['mailerHostname', 'base'],
'mailer.username' => ['mailerUsername', 'base'],
'mailer.password' => ['mailerPassword', 'base'],
'mailer.useSmtps' => ['mailerUseSmtps', 'base'],
'mailer.port' => ['mailerPort', 'base'],
'mailer.encryption' => ['mailerEncryption', 'base'],
'mailer.allowSelfSignedCerts' => ['mailerAllowSelfSignedCerts', 'base'],
'mailer.systemEmailAddress' => ['mailerSystemEmailAddress', 'base'],
'mailer.systemEmailName' => ['mailerSystemEmailName', 'base'],
'mailer.systemEmailReplyTo' => ['mailerSystemEmailReplyTo', 'base'],
],
static $translations = [
'mailer.transportType' => 'mailerTransportType',
'mailer.dsn' => 'mailerDsn',
'mailer.hostname' => 'mailerHostname',
'mailer.username' => 'mailerUsername',
'mailer.password' => 'mailerPassword',
'mailer.useSmtps' => 'mailerUseSmtps',
'mailer.port' => 'mailerPort',
'mailer.encryption' => 'mailerEncryption',
'mailer.allowSelfSignedCerts' => 'mailerAllowSelfSignedCerts',
'mailer.systemEmailAddress' => 'mailerSystemEmailAddress',
'mailer.systemEmailName' => 'mailerSystemEmailName',
'mailer.systemEmailReplyTo' => 'mailerSystemEmailReplyTo',
];
return $translation[$moduleId][$name] ?? [$name, $moduleId];
return ArrayHelper::getValue($translations, $name, $name);
}
/**

View File

@ -39,13 +39,13 @@ class SettingTest extends SettingActiveRecordTest
$this->assertCount(0, $settingAfter, "Setting 'testSetting' for 'base' was not deleted.");
}
public function testDeprecatedFixModuleIdAndName()
public function testDeprecatedFixKey()
{
$this->assertEquals(['foo', 'bar'], Setting::fixModuleIdAndName('foo', 'bar'), "Translation messed things up!");
$this->assertEquals('foo', Setting::fixDeprecatedSettingKeys('foo'), "Translation messed things up!");
$this->assertEquals(
['allowGuestAccess', 'user'],
Setting::fixModuleIdAndName('allowGuestAccess', 'authentication_internal'),
'mailerTransportType',
Setting::fixDeprecatedSettingKeys('mailer.transportType'),
"Translation messed things up!",
);
}