aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-01-14 15:00:41 +0100
committerVincent Petry <pvince81@owncloud.com>2016-05-24 14:50:42 +0200
commitcc4f6d6ae67da12b209c2da8dcf1359d0e1db7e6 (patch)
tree580e2e3763b69233ecffdde7e38c97f228814ebe
parentd1f8e172944a97f5aa8e36038ba7381583e7cefa (diff)
downloadnextcloud-server-cc4f6d6ae67da12b209c2da8dcf1359d0e1db7e6.tar.gz
nextcloud-server-cc4f6d6ae67da12b209c2da8dcf1359d0e1db7e6.zip
Allow indirect set in CappedMemoryCache
-rw-r--r--lib/private/cache/cappedmemorycache.php4
-rw-r--r--tests/lib/cache/cappedmemorycache.php12
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/cache/cappedmemorycache.php b/lib/private/cache/cappedmemorycache.php
index cfaf78c51df..e3efbf76a23 100644
--- a/lib/private/cache/cappedmemorycache.php
+++ b/lib/private/cache/cappedmemorycache.php
@@ -64,8 +64,8 @@ class CappedMemoryCache implements ICache, \ArrayAccess {
return $this->hasKey($offset);
}
- public function offsetGet($offset) {
- return $this->get($offset);
+ public function &offsetGet($offset) {
+ return $this->cache[$offset];
}
public function offsetSet($offset, $value) {
diff --git a/tests/lib/cache/cappedmemorycache.php b/tests/lib/cache/cappedmemorycache.php
index 5444d928421..a8fb273b80a 100644
--- a/tests/lib/cache/cappedmemorycache.php
+++ b/tests/lib/cache/cappedmemorycache.php
@@ -64,4 +64,16 @@ class CappedMemoryCache extends \Test_Cache {
$this->assertFalse($this->instance->hasKey('2_value1'));
$this->assertFalse($this->instance->hasKey('3_value1'));
}
+
+ function testIndirectSet() {
+ $this->instance->set('array', []);
+
+ $this->instance['array'][] = 'foo';
+
+ $this->assertEquals(['foo'], $this->instance->get('array'));
+
+ $this->instance['array']['bar'] = 'qwerty';
+
+ $this->assertEquals(['foo', 'bar' => 'qwerty'], $this->instance->get('array'));
+ }
}