// "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'))));
}
}
+/**
+ * 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
*/
$record->timemodified = time();
return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
-
}
/**
/// 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)