Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/4629' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Pattern/CallbackCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}'");
}

Expand Down
21 changes: 21 additions & 0 deletions test/Pattern/CallbackCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

0 comments on commit cb3093c

Please sign in to comment.