1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-23 09:23:09 +02:00

MDL-46660 muc: add env check to memcache driver

This commit is contained in:
Petr Skoda 2014-08-04 15:01:30 +12:00
parent 14cb870f46
commit 67dabb5ace
5 changed files with 77 additions and 3 deletions

@ -0,0 +1,49 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Validate that the current db structure matches the install.xml files.
*
* @package core
* @copyright 2014 Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Petr Skoda <petr.skoda@totaralms.com>
*/
class cachestore_memcache_environment_check {
public static function check_memcache_version(environment_results $result) {
global $CFG;
if (empty($CFG->version) or !get_config('cachestore_memcache', 'testservers')) {
// Do not display warnings when plugin not configured,
// admins will see the warning after setting memcache server.
return null;
}
if (!extension_loaded('memcache') or !$version = phpversion('memcache')) {
// No need to mention this when not used.
return null;
}
$minversion = '3.0.3';
$result->setInfo(get_string('memcacheversioncheck', 'cachestore_memcache'));
if (version_compare($version, $minversion) < 0) {
$result->setStatus(false);
$result->setFeedbackStr(array('memcacheversionwarning', 'cachestore_memcache', array('minversion' => $minversion, 'version' => $version)));
} else {
$result->setStatus(true);
}
return $result;
}
}

9
cache/stores/memcache/environment.xml vendored Normal file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<COMPATIBILITY_MATRIX>
<MOODLE version="2.7">
<CUSTOM_CHECKS>
<CUSTOM_CHECK function="cachestore_memcache_environment_check::check_memcache_version" level="optional">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>

@ -33,6 +33,8 @@ The intended use case is to create an improved store for load-balanced configura
When this setting is enabled, the server listed above will be used for fetching.';
$string['clusteredheader'] = 'Split servers';
$string['memcacheversioncheck'] = 'memcache PHP extension';
$string['memcacheversionwarning'] = 'The installed memcache extension {$a->version} is lower than the recommended version {$a->minversion}, upgrading to at least the minimum version will result in better performance when using memcache.';
$string['pluginname'] = 'Memcache';
$string['prefix'] = 'Key prefix';
$string['prefix_help'] = 'This prefix is used for all key names on the memcache server.
@ -67,4 +69,4 @@ ipaddress:port
$string['sessionhandlerconflict'] = 'Warning: A memcache instance ({$a}) has being configured to use the same memcached server as sessions. Purging all caches will lead to sessions also being purged.';
$string['testservers'] = 'Test servers';
$string['testservers_desc'] = 'The test servers get used for unit tests and for performance tests. It is entirely optional to set up test servers. Servers should be defined one per line and consist of a server address and optionally a port and weight.
If no port is provided then the default port (11211) is used.';
If no port is provided then the default port (11211) is used.';

@ -26,8 +26,22 @@
defined('MOODLE_INTERNAL') || die;
$settings->add(new admin_setting_configtextarea(
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtextarea(
'cachestore_memcache/testservers',
new lang_string('testservers', 'cachestore_memcache'),
new lang_string('testservers_desc', 'cachestore_memcache'),
'', PARAM_RAW, 60, 3));
// This is an ugly hack, but the env page skips the warning if server not set...
require_once("$CFG->libdir/environmentlib.php");
$result = new environment_results('custom_check');
$result = cachestore_memcache_environment_check::check_memcache_version($result);
if ($result and $feedbackstr = $result->getFeedbackStr()) {
$settings->add(new admin_setting_heading(
'cachestoremucwarning',
new lang_string('warning'),
$result->strToReport($feedbackstr, 'statuswarning')));
}
unset($result);
}

@ -26,6 +26,6 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2014051200; // The current module version (Date: YYYYMMDDXX)
$plugin->version = 2014080400; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2014050800; // Requires this Moodle version.
$plugin->component = 'cachestore_memcache'; // Full name of the plugin.