From e8a072673782187f584b7ea82f6ef8f2c6f38e97 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 14 Oct 2015 21:56:01 -0400 Subject: [PATCH 1/5] Fix error when Memcached::getAllKeys() fails. Refs #7546 --- lib/Cake/Cache/Engine/MemcachedEngine.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Cache/Engine/MemcachedEngine.php b/lib/Cake/Cache/Engine/MemcachedEngine.php index a2611396a..331b8a352 100644 --- a/lib/Cake/Cache/Engine/MemcachedEngine.php +++ b/lib/Cake/Cache/Engine/MemcachedEngine.php @@ -273,7 +273,8 @@ class MemcachedEngine extends CacheEngine { * * @param bool $check If true no deletes will occur and instead CakePHP will rely * on key TTL values. - * @return bool True if the cache was successfully cleared, false otherwise + * @return bool True if the cache was successfully cleared, false otherwise. Will + * also return false if you are using a binary protocol. */ public function clear($check) { if ($check) { @@ -281,6 +282,9 @@ class MemcachedEngine extends CacheEngine { } $keys = $this->_Memcached->getAllKeys(); + if ($keys === false) { + return false; + } foreach ($keys as $key) { if (strpos($key, $this->settings['prefix']) === 0) { From e2a1094e69fa37e772fb9549ef7c4a5c3af4e7c2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 16 Oct 2015 23:07:25 -0400 Subject: [PATCH 2/5] Define variables before they are used. Refs #7563 --- lib/Cake/Model/Datasource/DboSource.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 75a18dcf4..04cd13247 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -1562,6 +1562,7 @@ class DboSource extends DataSource { } } else { if (is_array($merge[0][$association])) { + $mergeAssocTmp = array(); foreach ($dataAssociation as $k => $v) { if (!is_array($v)) { $dataAssocTmp[$k] = $v; @@ -3586,4 +3587,4 @@ class DboSource extends DataSource { parent::__destruct(); } -} \ No newline at end of file +} From dea32345c8ef2fad80f3966a3047a10f42a39ba7 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 17 Oct 2015 20:54:40 -0400 Subject: [PATCH 3/5] Add failing test for #7570 Documented behavior that exists in 3.x is not working in 2.x --- .../Case/Controller/Component/FlashComponentTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php index 56905c545..64fe0ec7f 100644 --- a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php @@ -158,6 +158,16 @@ class FlashComponentTest extends CakeTestCase { $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); + $this->Flash->alert('It worked', array('plugin' => 'MyPlugin')); + $expected = array( + 'message' => 'It worked', + 'key' => 'flash', + 'element' => 'MyPlugin.Flash/alert', + 'params' => array() + ); + $result = CakeSession::read('Message.flash'); + $this->assertEquals($expected, $result); + $this->Flash->error('It did not work', array('element' => 'error_thing')); $expected = array( 'message' => 'It did not work', From fd50d1976a4f083889f05e1616738510d7cbfe9e Mon Sep 17 00:00:00 2001 From: gmponos Date: Sat, 17 Oct 2015 15:56:01 +0300 Subject: [PATCH 4/5] Flash Component was not handling plugin option --- lib/Cake/Controller/Component/FlashComponent.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index 2e0fa4e68..df89d34c3 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -38,6 +38,7 @@ class FlashComponent extends Component { 'key' => 'flash', 'element' => 'default', 'params' => array(), + 'plugin' => '', ); /** @@ -79,7 +80,11 @@ class FlashComponent extends Component { list($plugin, $element) = pluginSplit($options['element']); if ($plugin) { - $options['element'] = $plugin . '.Flash/' . $element; + $options['plugin'] = $plugin; + } + + if (!empty($options['plugin'])) { + $options['element'] = $options['plugin'] . '.Flash/' . $element; } else { $options['element'] = 'Flash/' . $element; } From 925647ae2b2a7713f030a6df16e61038e7769678 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 17 Oct 2015 20:59:02 -0400 Subject: [PATCH 5/5] Simplify code used to generate plugin flash messages. --- lib/Cake/Controller/Component/FlashComponent.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index df89d34c3..cab43f305 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -38,7 +38,6 @@ class FlashComponent extends Component { 'key' => 'flash', 'element' => 'default', 'params' => array(), - 'plugin' => '', ); /** @@ -77,17 +76,11 @@ class FlashComponent extends Component { $message = $message->getMessage(); } - list($plugin, $element) = pluginSplit($options['element']); - - if ($plugin) { - $options['plugin'] = $plugin; - } - + list($plugin, $element) = pluginSplit($options['element'], true); if (!empty($options['plugin'])) { - $options['element'] = $options['plugin'] . '.Flash/' . $element; - } else { - $options['element'] = 'Flash/' . $element; + $plugin = $options['plugin'] . '.'; } + $options['element'] = $plugin . 'Flash/' . $element; CakeSession::write('Message.' . $options['key'], array( 'message' => $message,