dépôts
/
lhc
/
web
/
wiklou.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e87bb70
)
Strengthened validation for HashRing a bit.
author
Aaron Schulz
<aschulz@wikimedia.org>
Mon, 13 May 2013 18:20:11 +0000
(11:20 -0700)
committer
Aaron Schulz
<aschulz@wikimedia.org>
Mon, 13 May 2013 18:20:19 +0000
(11:20 -0700)
Change-Id: Ib0331662c785d806063ca730905dd88b6545d8f0
includes/HashRing.php
patch
|
blob
|
history
diff --git
a/includes/HashRing.php
b/includes/HashRing.php
index
227a287
..
73a38af
100644
(file)
--- a/
includes/HashRing.php
+++ b/
includes/HashRing.php
@@
-36,8
+36,8
@@
class HashRing {
* @param array $map (location => weight)
*/
public function __construct( array $map ) {
- $
sum = array_sum( $map
);
- if ( !count( $map )
|| $sum <= 0
) {
+ $
map = array_filter( $map, function( $w ) { return $w > 0; }
);
+ if ( !count( $map ) ) {
throw new MWException( "Ring is empty or all weights are zero." );
}
// Sort the locations based on the hash of their names