Page MenuHomePhabricator

D17543.diff
No OneTemporary

D17543.diff

diff --git a/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php b/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
--- a/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
+++ b/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
@@ -119,6 +119,7 @@
foreach ($list as $file) {
$map['alphanumeric/'.$file] = $root.$file;
}
+
return $map;
}
@@ -138,11 +139,11 @@
$border_seed = $username.'_border';
$pack_key =
- PhabricatorHash::digestToRange($pack_seed, 1, $pack_count);
+ PhabricatorHash::digestToRange($pack_seed, 0, $pack_count - 1);
$color_key =
- PhabricatorHash::digestToRange($color_seed, 1, $color_count);
+ PhabricatorHash::digestToRange($color_seed, 0, $color_count - 1);
$border_key =
- PhabricatorHash::digestToRange($border_seed, 1, $border_count);
+ PhabricatorHash::digestToRange($border_seed, 0, $border_count - 1);
$pack = $pack_map[$pack_key];
$icon = 'alphanumeric/'.$pack.'/'.$file.'.png';
@@ -188,7 +189,7 @@
->withFollowSymlinks(false)
->find();
- return $map;
+ return array_values($map);
}
public static function getBorderMap() {
diff --git a/src/infrastructure/util/PhabricatorHash.php b/src/infrastructure/util/PhabricatorHash.php
--- a/src/infrastructure/util/PhabricatorHash.php
+++ b/src/infrastructure/util/PhabricatorHash.php
@@ -88,9 +88,10 @@
}
$hash = sha1($string, $raw_output = true);
- $value = head(unpack('L', $hash));
+ // Make sure this ends up positive, even on 32-bit machines.
+ $value = head(unpack('L', $hash)) & 0x7FFFFFFF;
- return $min + ($value % ($max - $min));
+ return $min + ($value % (1 + $max - $min));
}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 2:50 AM (8 h, 23 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6924521
Default Alt Text
D17543.diff (1 KB)

Event Timeline