Browse files

[Cache/CouchbaseCache] Return false instead of null for compat.

This changeset fixes and verifies that instead of null, false is returned
from the fetch method. This fixes a bug which causes CouchbaseCache not
to work in combination with the ORM library. Test added.
  • Loading branch information...
1 parent a31435a commit fc81e684b3970d86666b774501834bf0a3d2df80 @daschl daschl committed Jan 7, 2013
View
2 lib/Doctrine/Common/Cache/CouchbaseCache.php
@@ -63,7 +63,7 @@ public function getCouchbase()
*/
protected function doFetch($id)
{
- return $this->couchbase->get($id);
+ return $this->couchbase->get($id) ?: false;
}
/**
View
7 tests/Doctrine/Tests/Common/Cache/CouchbaseCacheTest.php
@@ -38,6 +38,13 @@ public function testLongLifetime()
$this->assertTrue($cache->contains('key'), 'Couchbase provider should support TTL > 30 days');
}
+ public function testFalseOnFailedFetch() {
+ $cache = $this->_getCacheDriver();
+ $result = $cache->fetch('nonexistent_key');
+ $this->assertFalse($result);
+ $this->assertNotNull($result);
+ }
+
protected function _getCacheDriver()
{
$driver = new CouchbaseCache();

0 comments on commit fc81e68

Please sign in to comment.