summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkpavlitski2014-03-10 00:48:47 (GMT)
committerJeremy Andrews2014-03-10 00:48:47 (GMT)
commit92483f639ff80d01c5995ba193129503be121362 (patch)
tree38b9fd4fd8a105a0f54f7dbf07fc5d6205e43008
parent2f7f371e711b6ed8918f55608202d952b4f2207f (diff)
Issue #1806120 by markpavlitski: warn if an unsupported PECL version is being used.
-rw-r--r--README.txt4
-rw-r--r--memcache.install19
-rw-r--r--tests/memcache.test11
3 files changed, 30 insertions, 4 deletions
diff --git a/README.txt b/README.txt
index 0a77f47..a3e816a 100644
--- a/README.txt
+++ b/README.txt
@@ -24,8 +24,8 @@ is important.
2. Install your chosen PECL memcache extension -- this is the memcache client
library which will be used by the Drupal memcache module to interact with
the memcached server(s). Generally PECL memcache (3.0.6+) is recommended,
- but PECL memcached (2.0.1+) also works well for some people. Use of older
- versions may cause problems.
+ but PECL memcached (2.0.1+) also works well for some people. There are
+ known issues with older version.
3. Put your site into offline mode.
4. Download and install the memcache module.
5. If you have previously been running the memcache module, run update.php.
diff --git a/memcache.install b/memcache.install
index 26b1a1c..950ffb3 100644
--- a/memcache.install
+++ b/memcache.install
@@ -5,6 +5,9 @@
* Install, update and uninstall functions for the memcache module.
*/
+define('MEMCACHE_PECL_RECOMMENDED', '3.0.6');
+define('MEMCACHED_PECL_RECOMMENDED', '2.0.1');
+
/**
* Implements hook_enable().
*/
@@ -65,10 +68,22 @@ function memcache_requirements($phase) {
else {
$extension = dmemcache_extension();
if ($extension == 'Memcache') {
- $requirements['memcache_extension']['value'] = phpversion('memcache') . _memcache_statistics_link();
+ $version = phpversion('memcache');
+ $recommended = MEMCACHE_PECL_RECOMMENDED;
+ $requirements['memcache_extension']['value'] = $version . _memcache_statistics_link();
}
elseif ($extension == 'Memcached') {
- $requirements['memcache_extension']['value'] = phpversion('memcached') . _memcache_statistics_link();
+ $version = phpversion('memcached');
+ $recommended = MEMCACHED_PECL_RECOMMENDED;
+ $requirements['memcache_extension']['value'] = $version . _memcache_statistics_link();
+ }
+
+ if (version_compare($version, $recommended, '<')) {
+ $errors[] = $t('PECL !extension version %version is unsupported. Please update to %recommended or newer.', array(
+ '!extension' => $extension,
+ '%version' => $version,
+ '%recommended' => $recommended,
+ ));
}
// Make a test connection to all configured memcache servers.
diff --git a/tests/memcache.test b/tests/memcache.test
index de956f0..ed7ad0b 100644
--- a/tests/memcache.test
+++ b/tests/memcache.test
@@ -328,6 +328,17 @@ class MemCacheSavingCase extends MemcacheTestCase {
}
/**
+ * Test saving and restoring an integer value directly with dmemcache_set().
+ */
+ function testIntegerValue() {
+ $key = $this->randomName(100);
+ $val = rand(1, 1000);
+ dmemcache_set($key, $val, 0, 'cache');
+ $cache = dmemcache_get($key, 'cache');
+ $this->assertTrue($val === $cache, t('Integer is saved and restored properly with key @key', array('@key' => $key)));
+ }
+
+ /**
* Check or a variable is stored and restored properly.
*/
public function checkVariable($var, $key = 'test_var') {