Page MenuHomePhabricator

D20582.id.diff
No OneTemporary

D20582.id.diff

diff --git a/src/utils/utils.php b/src/utils/utils.php
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -394,6 +394,23 @@
function msort(array $list, $method) {
$surrogate = mpull($list, $method);
+ // See T13303. A "PhutilSortVector" is technically a sortable object, so
+ // a method which returns a "PhutilSortVector" is suitable for use with
+ // "msort()". However, it's almost certain that the caller intended to use
+ // "msortv()", not "msort()", and forgot to add a "v". Treat this as an error.
+
+ if ($surrogate) {
+ $item = head($surrogate);
+ if ($item instanceof PhutilSortVector) {
+ throw new Exception(
+ pht(
+ 'msort() was passed a method ("%s") which returns '.
+ '"PhutilSortVector" objects. Use "msortv()", not "msort()", to '.
+ 'sort a list which produces vectors.',
+ $method));
+ }
+ }
+
asort($surrogate);
$result = array();

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 30, 11:17 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7578910
Default Alt Text
D20582.id.diff (936 B)

Event Timeline