Fixed ArrayUtils::pickRandom() when $rand=0.
Change-Id: Iba7db16a9ad08dd845fa1b4dd2bc02ffad8c5a32
This commit is contained in:
parent
9ace77f03c
commit
da8ddd18f1
1 changed files with 3 additions and 1 deletions
|
|
@ -58,7 +58,9 @@ class ArrayUtils {
|
|||
$sum = 0;
|
||||
foreach ( $weights as $i => $w ) {
|
||||
$sum += $w;
|
||||
if ( $sum >= $rand ) {
|
||||
# Do not return keys if they have 0 weight.
|
||||
# Note that the "all 0 weight" case is handed above
|
||||
if ( $w > 0 && $sum >= $rand ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue