]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-12716 fixed admin setting for rcache; more robust rcache handling in setup.php...
authorskodak <skodak>
Sun, 23 Dec 2007 13:10:35 +0000 (13:10 +0000)
committerskodak <skodak>
Sun, 23 Dec 2007 13:10:35 +0000 (13:10 +0000)
admin/settings/server.php
lib/adminlib.php
lib/setup.php

index 3dc8ba43e2c2e7620bb4e635ea28d73ed74ecca0..4f7e336a1c30ab0fc1b7af8b48745995fe47fbb2 100644 (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'))));
index f2c7b7744978097a19718d6d189171068908a845..6209cd82d7cb9cdd8de22e7cd596f9c506033dc6 100644 (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'));
     }
-
 }
 
 /**
index ca392352b8d3b25c4a1138c7154a8181c3d89138..65f20e36d08321d731804547b29af5b1a6c4399e 100644 (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)