Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Zend\Cache\Pattern\CallbackCache doesn't work with NULL #4629

Closed
wants to merge 1 commit into from

2 participants

@FanFataL

https://github.com/zendframework/zf2/blob/master/library/Zend/Cache/Pattern/CallbackCache.php#L51

if (!isset($result[0])) {
throw new Exception\RuntimeException("Invalid cached data for key '{$key}'");
}

The cache has been saved and loaded correct but this condition returns false because isset returns false on NULL - should be replaced by array_key_exists

;)

@weierophinney weierophinney [#4629] Allow caching null values from callbacks
- Implemented test case for #4629
- Used fix suggested in original report
c397869
@mwillbanks mwillbanks closed this pull request from a commit
@mwillbanks mwillbanks Merge branch 'hotfix/4629'
Close #4629
bcda072
@mwillbanks mwillbanks referenced this pull request from a commit
@mwillbanks mwillbanks Merge branch 'hotfix/4629' into develop
Forward port #4629
44b73b0
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#4629] Allow caching null values from callbacks
- Implemented test case for #4629
- Used fix suggested in original report
2d1051b
@ghost Unknown referenced this pull request from a commit
@mwillbanks mwillbanks Merge branch 'hotfix/4629'
Close #4629
0cb6235
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-cache
@weierophinney weierophinney [zendframework/zf2#4629] Allow caching null values from callbacks
- Implemented test case for zendframework/zf2#4629
- Used fix suggested in original report
708dae0
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-cache
@mwillbanks mwillbanks Merge branch 'hotfix/4629' e8ecd1e
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-cache
@mwillbanks mwillbanks Merge branch 'hotfix/4629' into develop cb3093c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 11, 2013
  1. @weierophinney

    [#4629] Allow caching null values from callbacks

    weierophinney authored
    - Implemented test case for #4629
    - Used fix suggested in original report
This page is out of date. Refresh to see the latest.
View
2  library/Zend/Cache/Pattern/CallbackCache.php
@@ -48,7 +48,7 @@ public function call($callback, array $args = array())
$key = $this->generateCallbackKey($callback, $args);
$result = $storage->getItem($key, $success);
if ($success) {
- if (!isset($result[0])) {
+ if (!array_key_exists(0, $result)) {
throw new Exception\RuntimeException("Invalid cached data for key '{$key}'");
}
View
21 tests/ZendTest/Cache/Pattern/CallbackCacheTest.php
@@ -35,6 +35,14 @@ public static function emptyMethod() {}
}
+class FailableCallback
+{
+ public function __invoke()
+ {
+ throw new \Exception('This callback should either fail or never be invoked');
+ }
+}
+
/**
* Test function
* @see ZendTest\Cache\Pattern\Foo::bar
@@ -165,4 +173,17 @@ protected function _testCall($callback, array $args)
$this->assertEquals('', $data);
}
}
+
+ /**
+ * @group 4629
+ * @return void
+ */
+ public function testCallCanReturnCachedNullValues()
+ {
+ $callback = new FailableCallback();
+ $key = $this->_pattern->generateKey($callback, array());
+ $this->_storage->setItem($key, array(null));
+ $value = $this->_pattern->call($callback);
+ $this->assertNull($value);
+ }
}
Something went wrong with that request. Please try again.