Skip to content

Commit

Permalink
Don't proxy invalid configuration
Browse files Browse the repository at this point in the history
If a cache configuration doesn't have a `className` we shouldn't proxy
it as it is malformed.

Fixes #682
  • Loading branch information
markstory committed May 31, 2019
1 parent 979c23e commit 07e56fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Panel/CachePanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ public function initialize()
$config = Cache::getConfig($name);
if (isset($config['className']) && $config['className'] instanceof DebugEngine) {
$instance = $config['className'];
} else {
} elseif (isset($config['className'])) {
Cache::drop($name);
$instance = new DebugEngine($config);
Cache::setConfig($name, $instance);
}
$this->_instances[$name] = $instance;
if (isset($instance)) {
$this->_instances[$name] = $instance;
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions tests/TestCase/Panel/CachePanelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function tearDown()
{
parent::tearDown();
Cache::drop('debug_kit_test');
Cache::drop('incomplete');
}

/**
Expand All @@ -64,6 +65,21 @@ public function testInitialize()
$this->assertArrayHasKey('_cake_model_', $result['metrics']);
}

/**
* test initialize incomplete data
*
* @return void
*/
public function testInitializeNoProxyIncompleteConfig()
{
$data = ['duration' => '+2 seconds'];
Cache::setConfig('incomplete', $data);
$this->panel->initialize();

$config = Cache::getConfig('incomplete');
$this->assertSame($data, $config);
}

/**
* test initialize incomplete data
*
Expand Down

0 comments on commit 07e56fa

Please sign in to comment.