Skip to content

Commit 0f47617

Browse files
authored
fix(cache): delegate legacy Hashtable storage to modern adapter
Horde_Cache_Storage_Hashtable still called get() with an array of keys, which breaks with Horde\HashTable\HashTable drivers that require a string. Route modern backends through Horde\Cache\HashtableStorage so ActiveSync and other cache users work with Memcache again.
1 parent 9e17c08 commit 0f47617

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

lib/Horde/Cache/Storage/Hashtable.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@ class Horde_Cache_Storage_Hashtable extends Horde_Cache_Storage_Base
2626
/**
2727
* HashTable object.
2828
*
29-
* @var Horde_HashTable
29+
* @var Horde_HashTable|\Horde\HashTable\HashTable
3030
*/
3131
protected $_hash;
3232

33+
/**
34+
* Modern storage adapter for Horde\HashTable\HashTable backends.
35+
*
36+
* @var \Horde\Cache\HashtableStorage|null
37+
*/
38+
protected ?\Horde\Cache\HashtableStorage $_modern = null;
39+
3340
/**
3441
* @param array $params Additional parameters:
3542
* <pre>
@@ -54,12 +61,23 @@ public function __construct(array $params = array())
5461
protected function _initOb()
5562
{
5663
$this->_hash = $this->_params['hashtable'];
64+
65+
if ($this->_hash instanceof \Horde\HashTable\HashTable) {
66+
$this->_modern = new \Horde\Cache\HashtableStorage(
67+
hashtable: $this->_hash,
68+
prefix: $this->_params['prefix']
69+
);
70+
}
5771
}
5872

5973
/**
6074
*/
6175
public function get($key, $lifetime = 0)
6276
{
77+
if ($this->_modern) {
78+
return $this->_modern->getWithLifetime($key, $lifetime);
79+
}
80+
6381
$dkey = $this->_getKey($key);
6482
$query = array($dkey);
6583
if ($lifetime) {
@@ -80,6 +98,12 @@ public function get($key, $lifetime = 0)
8098
*/
8199
public function set($key, $data, $lifetime = 0)
82100
{
101+
if ($this->_modern) {
102+
$this->_modern->set($key, $data, $lifetime);
103+
104+
return;
105+
}
106+
83107
$opts = array_filter(array(
84108
'expire' => $lifetime
85109
));
@@ -99,6 +123,12 @@ public function exists($key, $lifetime = 0)
99123
*/
100124
public function expire($key)
101125
{
126+
if ($this->_modern) {
127+
$this->_modern->delete($key);
128+
129+
return;
130+
}
131+
102132
$this->_hash->delete(array(
103133
$this->_getKey($key),
104134
$this->_getKey($key, true)

0 commit comments

Comments
 (0)