Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 2 commits into from

5 participants

@daschl

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.

@daschl daschl [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.
fc81e68
@doctrinebot
Collaborator

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DCOM-158

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() {
@lsmith77 Collaborator
lsmith77 added a note

opening { should be on the next line

@Ocramius Owner
Ocramius added a note

Not only for couchbase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@daschl daschl [Cache] Refactoring testFalseOnFailedFetch into CacheTest
This changeset makes sure that all supported caches return
false and not null when a key is not found. This ensures
compatibility with the ORM layer.
dee33aa
@daschl

Okay, this also refactors the method one level up the tree so that it will be used for all caching adapters. I think this is necessary in order to make sure we don't break compatibility to the ORM layer which expects false and not null when no doc is found on fetch.

If possible, please merge since the CouchbaseCache doesn't work in combination with the ORM layer otherwise.

@stof stof merged commit c07ce5f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 7, 2013
  1. @daschl

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

    daschl authored
    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.
  2. @daschl

    [Cache] Refactoring testFalseOnFailedFetch into CacheTest

    daschl authored
    This changeset makes sure that all supported caches return
    false and not null when a key is not found. This ensures
    compatibility with the ORM layer.
This page is out of date. Refresh to see the latest.
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
12 tests/Doctrine/Tests/Common/Cache/CacheTest.php
@@ -85,6 +85,18 @@ public function testGetStats()
}
/**
+ * 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
*/
abstract protected function _getCacheDriver();
Something went wrong with that request. Please try again.