MDL-75937 admin: Fixed config data display inconsistency

This commit is contained in:
Stevani Andolo
2023-06-12 15:24:51 +08:00
parent 8c989335be
commit 56edfcf6d5
2 changed files with 55 additions and 2 deletions
+50 -2
View File
@@ -1820,7 +1820,7 @@ abstract class admin_setting {
global $CFG;
if (empty($this->plugin)) {
if (array_key_exists($this->name, $CFG->config_php_settings)) {
if ($this->is_forceable() && array_key_exists($this->name, $CFG->config_php_settings)) {
return true;
}
} else {
@@ -2164,6 +2164,18 @@ abstract class admin_setting {
public function has_custom_form_control(): bool {
return $this->customcontrol;
}
/**
* Whether the setting can be overridden in config.php.
*
* Returning true will allow the setting to be defined and overridden in config.php.
* Returning false will prevent the config setting from being overridden even when it gets defined in config.php.
*
* @return bool
*/
public function is_forceable(): bool {
return true;
}
}
/**
@@ -4600,6 +4612,15 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
return '';
}
/**
* admin_setting_sitesetselect is not meant to be overridden in config.php.
*
* @return bool
*/
public function is_forceable(): bool {
return false;
}
}
@@ -4810,6 +4831,15 @@ class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
return '';
}
/**
* admin_setting_sitesetcheckbox is not meant to be overridden in config.php.
*
* @return bool
*/
public function is_forceable(): bool {
return false;
}
}
/**
@@ -4892,6 +4922,15 @@ class admin_setting_sitesettext extends admin_setting_configtext {
return '';
}
/**
* admin_setting_sitesettext is not meant to be overridden in config.php.
*
* @return bool
*/
public function is_forceable(): bool {
return false;
}
}
@@ -4967,6 +5006,15 @@ class admin_setting_special_frontpagedesc extends admin_setting_confightmleditor
return '';
}
/**
* admin_setting_special_frontpagedesc is not meant to be overridden in config.php.
*
* @return bool
*/
public function is_forceable(): bool {
return false;
}
}
@@ -9044,7 +9092,7 @@ function format_admin_setting($setting, $title='', $form='', $description='', $l
$context->warning = $warning;
$context->override = '';
if (empty($setting->plugin)) {
if (array_key_exists($setting->name, $CFG->config_php_settings)) {
if ($setting->is_forceable() && array_key_exists($setting->name, $CFG->config_php_settings)) {
$context->override = get_string('configoverride', 'admin');
}
} else {