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

Commit

Permalink
Merge pull request zendframework/zendframework#7039 from marc-mabe/ho…
Browse files Browse the repository at this point in the history
…tfix/5860_5863

Cache: better fix for zendframework/zendframework#5860 introduced in zendframework/zendframework#5863
  • Loading branch information
Ocramius committed Jan 1, 2015
2 parents 362644d + d3b89d4 commit da594a3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Pattern/PatternOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public function getObjectCacheMethods()
* Used by:
* - ObjectCache
*
* @param mixed $objectKey
* @param null|string $objectKey The object key or NULL to use the objects class name
* @return PatternOptions
*/
public function setObjectKey($objectKey)
Expand All @@ -597,7 +597,7 @@ public function setObjectKey($objectKey)
*/
public function getObjectKey()
{
if (!$this->objectKey) {
if ($this->objectKey === null) {
return get_class($this->getObject());
}
return $this->objectKey;
Expand Down
6 changes: 3 additions & 3 deletions src/Storage/Plugin/PluginOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PluginOptions extends AbstractOptions
/**
* Used by:
* - ExceptionHandler
* @var callable
* @var null|callable
*/
protected $exceptionCallback;

Expand Down Expand Up @@ -99,7 +99,7 @@ public function getClearingFactor()
* Used by:
* - ExceptionHandler
*
* @param callable $exceptionCallback
* @param null|callable $exceptionCallback
* @throws Exception\InvalidArgumentException
* @return PluginOptions
*/
Expand All @@ -118,7 +118,7 @@ public function setExceptionCallback($exceptionCallback)
* Used by:
* - ExceptionHandler
*
* @return callable
* @return null|callable
*/
public function getExceptionCallback()
{
Expand Down
15 changes: 15 additions & 0 deletions test/Pattern/ObjectCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ public function testUnsetProperty()
$this->assertFalse(isset($this->_pattern->property));
}

/**
* @group 7039
*/
public function testEmptyObjectKeys()
{
$this->_options->setObjectKey('0');
$this->assertSame('0', $this->_options->getObjectKey(), "Can't set string '0' as object key");

$this->_options->setObjectKey('');
$this->assertSame('', $this->_options->getObjectKey(), "Can't set an empty string as object key");

$this->_options->setObjectKey(null);
$this->assertSame(get_class($this->_options->getObject()), $this->_options->getObjectKey());
}

protected function _testCall($method, array $args)
{
$returnSpec = 'foobar_return(' . implode(', ', $args) . ') : ';
Expand Down

0 comments on commit da594a3

Please sign in to comment.