*
* NOTE: this function is called from lib/db/upgrade.php
*
- * @static string|false $siteidentifier The site identifier is not cached. We use this static cache so
- * that we need only fetch it once per request.
* @param string $plugin full component name
* @param string $name default null
* @return mixed hash-like object or single value, return false no config found
function get_config($plugin, $name = null) {
global $CFG, $DB;
- static $siteidentifier = null;
-
if ($plugin === 'moodle' || $plugin === 'core' || empty($plugin)) {
$forced =& $CFG->config_php_settings;
- $iscore = true;
+ $table = 'config';
+ $filter = [];
$plugin = 'core';
} else {
if (array_key_exists($plugin, $CFG->forced_plugin_settings)) {
$forced =& $CFG->forced_plugin_settings[$plugin];
} else {
- $forced = array();
+ $forced = [];
}
- $iscore = false;
+ $table = 'config_plugins';
+ $filter = ['plugin' => $plugin];
}
- if ($siteidentifier === null) {
- try {
- // This may fail during installation.
- // If you have a look at {@link initialise_cfg()} you will see that this is how we detect the need to
- // install the database.
- $siteidentifier = $DB->get_field('config', 'value', array('name' => 'siteidentifier'));
- } catch (dml_exception $ex) {
- // Set siteidentifier to false. We don't want to trip this continually.
- $siteidentifier = false;
- throw $ex;
- }
- }
-
- if (!empty($name)) {
- if (array_key_exists($name, $forced)) {
- return (string)$forced[$name];
- } else if ($name === 'siteidentifier' && $plugin == 'core') {
- return $siteidentifier;
- }
+ if (!empty($name) && array_key_exists($name, $forced)) {
+ return (string)$forced[$name];
}
$cache = cache::make('core', 'config');
$result = $cache->get($plugin);
if ($result === false) {
- // The user is after a recordset.
- if (!$iscore) {
- $result = $DB->get_records_menu('config_plugins', array('plugin' => $plugin), '', 'name,value');
- } else {
- // This part is not really used any more, but anyway...
- $result = $DB->get_records_menu('config', array(), '', 'name,value');;
- }
+ $result = $DB->get_records_menu($table, $filter, '', 'name,value');
$cache->set($plugin, $result);
}
return false;
}
- if ($plugin === 'core') {
- $result['siteidentifier'] = $siteidentifier;
- }
-
foreach ($forced as $key => $value) {
if (is_null($value) or is_array($value) or is_object($value)) {
// We do not want any extra mess here, just real settings that could be saved in db.