From 91ef655854e833c1dd9177c93899d5bc37c8ec2f Mon Sep 17 00:00:00 2001 From: Ujwal Trivedi Date: Mon, 17 Feb 2014 02:51:00 -0500 Subject: [PATCH 1/4] Update MemcacheEngine.php adding $limit=0 to clear function so it deletes all the keys for real --- lib/Cake/Cache/Engine/MemcacheEngine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 5ba9d4a59..14fccb3ec 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -205,13 +205,13 @@ class MemcacheEngine extends CacheEngine { if ($check) { return true; } - foreach ($this->_Memcache->getExtendedStats('slabs') as $slabs) { + foreach ($this->_Memcache->getExtendedStats('slabs', $limit=0) as $slabs) { foreach (array_keys($slabs) as $slabId) { if (!is_numeric($slabId)) { continue; } - foreach ($this->_Memcache->getExtendedStats('cachedump', $slabId) as $stats) { + foreach ($this->_Memcache->getExtendedStats('cachedump', $slabId, $limit=0) as $stats) { if (!is_array($stats)) { continue; } From cb0580a91a5ee29324f2c4989470564c9a6137a4 Mon Sep 17 00:00:00 2001 From: Ujwal Trivedi Date: Mon, 17 Feb 2014 15:29:49 -0500 Subject: [PATCH 2/4] Update MemcacheEngine.php removing variable assignment --- lib/Cake/Cache/Engine/MemcacheEngine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 14fccb3ec..4bd3d72f3 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -205,13 +205,13 @@ class MemcacheEngine extends CacheEngine { if ($check) { return true; } - foreach ($this->_Memcache->getExtendedStats('slabs', $limit=0) as $slabs) { + foreach ($this->_Memcache->getExtendedStats('slabs') as $slabs) { foreach (array_keys($slabs) as $slabId) { if (!is_numeric($slabId)) { continue; } - foreach ($this->_Memcache->getExtendedStats('cachedump', $slabId, $limit=0) as $stats) { + foreach ($this->_Memcache->getExtendedStats('cachedump', $slabId, 0) as $stats) { if (!is_array($stats)) { continue; } From 1045a5e0a549227078ab4578a87aaa2bde81bf0e Mon Sep 17 00:00:00 2001 From: Ujwal Trivedi Date: Tue, 18 Feb 2014 18:40:17 -0500 Subject: [PATCH 3/4] Update MemcacheEngine.php removed 0 from getExtendedStats('slabs') in my last commit, someone point that out in the comment. Adding it back. --- lib/Cake/Cache/Engine/MemcacheEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 4bd3d72f3..8d9de0ea9 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -205,7 +205,7 @@ class MemcacheEngine extends CacheEngine { if ($check) { return true; } - foreach ($this->_Memcache->getExtendedStats('slabs') as $slabs) { + foreach ($this->_Memcache->getExtendedStats('slabs', 0) as $slabs) { foreach (array_keys($slabs) as $slabId) { if (!is_numeric($slabId)) { continue; From 0a51458ffd6031bfa6041e7f69e660bc5b1ebb92 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 18 Feb 2014 22:18:56 -0500 Subject: [PATCH 4/4] Fix Validation::decimal() not working with localized floats. Use similar workarounds as DboSource::value() for accepting localized floats. Fixes #2853 --- lib/Cake/Test/Case/Utility/ValidationTest.php | 16 ++++++++++++++++ lib/Cake/Utility/Validation.php | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index aef449c74..073fe7926 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -1654,6 +1654,22 @@ class ValidationTest extends CakeTestCase { $this->assertFalse(Validation::decimal('.54321', null, '/^[-+]?[0-9]+(\\.[0-9]+)?$/s')); } +/** + * Test localized floats with decimal. + * + * @return void + */ + public function testDecimalLocaleSet() { + $this->skipIf(DS === '\\', 'The locale is not supported in Windows and affect the others tests.'); + $restore = setlocale(LC_NUMERIC, 0); + $this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available."); + + $this->assertTrue(Validation::decimal(1.54)); + $this->assertTrue(Validation::decimal('1.54')); + + setlocale(LC_NUMERIC, $restore); + } + /** * testEmail method * diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index b990b6ca9..14f06087c 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -425,6 +425,11 @@ class Validation { $regex = "/^{$sign}{$dnum}{$exp}$/"; } } + + // Workaround localized floats. + if (is_float($check)) { + $check = str_replace(',', '.', strval($check)); + } return self::_check($check, $regex); }