MDL-12716 fixed admin setting for rcache; more robust rcache handling in setup.php; merged from MOODLE_19_STABLE

This commit is contained in:
skodak 2007-12-23 13:10:35 +00:00
parent bca13de752
commit 392e73631e
3 changed files with 43 additions and 11 deletions

View File

@ -207,14 +207,14 @@ $ADMIN->add('server', new admin_externalpage('phpinfo', get_string('phpinfo'), "
// "performance" settingpage
$temp = new admin_settingpage('performance', get_string('performance', 'admin'));
$temp->add(new admin_setting_configselect('cachetype', get_string('cachetype', 'admin'),
$temp->add(new admin_setting_special_selectsetup('cachetype', get_string('cachetype', 'admin'),
get_string('configcachetype', 'admin'), '',
array( '' => get_string('none'),
'internal' => 'internal',
'memcached' => 'memcached',
'eaccelerator' => 'eaccelerator')));
// NOTE: $CFG->rcache is forced to bool in lib/setup.php
$temp->add(new admin_setting_configselect('rcache', get_string('rcache', 'admin'),
$temp->add(new admin_setting_special_selectsetup('rcache', get_string('rcache', 'admin'),
get_string('configrcache', 'admin'), 0,
array( '0' => get_string('no'),
'1' => get_string('yes'))));

View File

@ -2382,6 +2382,25 @@ class admin_setting_special_adminseesall extends admin_setting_configcheckbox {
}
}
/**
* Special select for settings that are altered in setup.php and can not be altered on the fly
*/
class admin_setting_special_selectsetup extends admin_setting_configselect {
function get_setting() {
// read directly from db!
return get_config(NULL, $this->name);
}
function write_setting($data) {
global $CFG;
// do not change active CFG setting!
$current = $CFG->{$this->name};
$result = parent::write_setting($data);
$CFG->{$this->name} = $current;
return $result;
}
}
/**
* Special select for frontpage - stores data in course table
*/
@ -2402,7 +2421,6 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
$record->timemodified = time();
return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
}
/**

View File

@ -283,25 +283,39 @@ global $HTTPSPAGEREQUIRED;
/// Shared-Memory cache init -- will set $MCACHE
/// $MCACHE is a global object that offers at least add(), set() and delete()
/// with similar semantics to the memcached PHP API http://php.net/memcache
/// Ensure we define rcache - so we can later check for it
/// with a really fast and unambiguous $CFG->rcache === false
if (!empty($CFG->cachetype)) {
if (array_key_exists('rcache', $CFG->config_php_settings)) {
$CFG->rcache = (bool)$CFG->config_php_settings['rcache']; // always use config.php setting if present
} else if (empty($CFG->rcache)) {
$CFG->rcache = false;
} else {
$CFG->rcache = true;
}
// do not try to initialize if cache disabled
if (!$CFG->rcache) {
$CFG->cachetype = '';
}
if ($CFG->cachetype === 'memcached' && !empty($CFG->memcachedhosts)) {
if (!init_memcached()) {
debugging("Error initialising memcached");
}
} elseif ($CFG->cachetype === 'eaccelerator') {
$CFG->cachetype = '';
$CFG->rcache = false;
} else if ($CFG->cachetype === 'eaccelerator') {
if (!init_eaccelerator()) {
debugging("Error initialising eaccelerator cache");
}
$CFG->cachetype = '';
$CFG->rcache = false;
}
} else { // just make sure it is defined
$CFG->cachetype = '';
}
/// Ensure we define rcache - so we can later check for it
/// with a really fast and unambiguous $CFG->rcache === false
if (empty($CFG->rcache)) {
$CFG->rcache = false;
} else {
$CFG->rcache = true;
$CFG->rcache = false;
}
/// Set a default enrolment configuration (see bug 1598)