From addf8ec1d29771a1ae5ea03b614cc1096f843c05 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Thu, 16 Dec 2010 14:37:46 +0100 Subject: [PATCH] Array keys are casted to integers if they look like numbers (WTF?). If a hash happens to be a number, ksort() fails because integers are always sorted after strings. Add a string to the hash key to make sure it's never casted to an integer. --- framework/Support/lib/Horde/Support/ConsistentHash.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/Support/lib/Horde/Support/ConsistentHash.php b/framework/Support/lib/Horde/Support/ConsistentHash.php index 6177f931b..ec1820cfd 100644 --- a/framework/Support/lib/Horde/Support/ConsistentHash.php +++ b/framework/Support/lib/Horde/Support/ConsistentHash.php @@ -2,14 +2,14 @@ /** * @category Horde * @package Support - * @copyright 2007-2009 The Horde Project (http://www.horde.org/) + * @copyright 2007-2010 The Horde Project (http://www.horde.org/) * @license http://opensource.org/licenses/bsd-license.php */ /** * @category Horde * @package Support - * @copyright 2007-2009 The Horde Project (http://www.horde.org/) + * @copyright 2007-2010 The Horde Project (http://www.horde.org/) * @license http://opensource.org/licenses/bsd-license.php * * For a thorough description of consistent hashing, see @@ -18,8 +18,8 @@ * http://www8.org/w8-papers/2a-webserver/caching/paper2.html * * @TODO Ideas for future enhancement: - * - provide a callback when a point is moved on the circle, so that the calling - * code can take an action (say, tranferring data). + * - provide a callback when a point is moved on the circle, so that the + * calling code can take an action (say, transferring data). */ class Horde_Support_ConsistentHash { @@ -230,7 +230,7 @@ class Horde_Support_ConsistentHash */ public function hash($key) { - return substr(hash('md5', $key), 0, 8); + return 'h' . substr(hash('md5', $key), 0, 8); } /** -- 2.11.0