diff --git a/lib/Doctrine/Common/Cache/CouchbaseCache.php b/lib/Doctrine/Common/Cache/CouchbaseCache.php index cd48f66de..f0e5f9072 100644 --- a/lib/Doctrine/Common/Cache/CouchbaseCache.php +++ b/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; } /** diff --git a/tests/Doctrine/Tests/Common/Cache/CacheTest.php b/tests/Doctrine/Tests/Common/Cache/CacheTest.php index 1bbc16505..ea7f75374 100644 --- a/tests/Doctrine/Tests/Common/Cache/CacheTest.php +++ b/tests/Doctrine/Tests/Common/Cache/CacheTest.php @@ -84,6 +84,18 @@ public function testGetStats() $this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILIABLE, $stats); } + /** + * Make sure that all supported caches return "false" instead of "null" to be compatible + * with ORM integration. + */ + public function testFalseOnFailedFetch() + { + $cache = $this->_getCacheDriver(); + $result = $cache->fetch('nonexistent_key'); + $this->assertFalse($result); + $this->assertNotNull($result); + } + /** * @return \Doctrine\Common\Cache\CacheProvider */