Skip to content

Commit e2d856e

Browse files
authored
Merge pull request #683 from cakephp/issue-682
Don't proxy invalid configuration
2 parents 2926788 + 07e56fa commit e2d856e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/Panel/CachePanel.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ public function initialize()
4141
$config = Cache::getConfig($name);
4242
if (isset($config['className']) && $config['className'] instanceof DebugEngine) {
4343
$instance = $config['className'];
44-
} else {
44+
} elseif (isset($config['className'])) {
4545
Cache::drop($name);
4646
$instance = new DebugEngine($config);
4747
Cache::setConfig($name, $instance);
4848
}
49-
$this->_instances[$name] = $instance;
49+
if (isset($instance)) {
50+
$this->_instances[$name] = $instance;
51+
}
5052
}
5153
}
5254

tests/TestCase/Panel/CachePanelTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function tearDown()
4848
{
4949
parent::tearDown();
5050
Cache::drop('debug_kit_test');
51+
Cache::drop('incomplete');
5152
}
5253

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

68+
/**
69+
* test initialize incomplete data
70+
*
71+
* @return void
72+
*/
73+
public function testInitializeNoProxyIncompleteConfig()
74+
{
75+
$data = ['duration' => '+2 seconds'];
76+
Cache::setConfig('incomplete', $data);
77+
$this->panel->initialize();
78+
79+
$config = Cache::getConfig('incomplete');
80+
$this->assertSame($data, $config);
81+
}
82+
6783
/**
6884
* test initialize incomplete data
6985
*

0 commit comments

Comments
 (0)