Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15453371
D20582.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
936 B
Referenced Files
None
Subscribers
None
D20582.id.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D20582: Consider "msort()" on "PhutilSortVector" objects to be an error
Attached
Detach File
Event Timeline
Log In to Comment