diff --git a/memcache.inc b/memcache.inc index 443e57eabdde1a29936c3739f846ed1a9949394b..78ed4184a5e049f3ec2f741822963175900d3a51 100644 --- a/memcache.inc +++ b/memcache.inc @@ -296,7 +296,11 @@ class MemCacheDrupal implements DrupalCacheInterface { } if ($flush) { - $key_length = isset($this->wildcard_flushes[$this->bin]) ? strlen(reset(array_keys($this->wildcard_flushes[$this->bin]))) : $length; + $key_length = $length; + if (isset($this->wildcard_flushes[$this->bin])) { + $keys = array_keys($this->wildcard_flushes[$this->bin]); + $key_length = strlen(reset($keys)); + } $key = substr($cid, 0, $key_length); // Avoid too many calls to variable_set() by only recording a flush for // a fraction of the wildcard invalidation variable, per cid length.