From 46e774ba3808273ac11193468eca236a5e641e97 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Wed, 30 May 2018 07:29:00 -0400 Subject: [PATCH] Fix issue in FieldtypeComments::find() where "sort=something" selector wasn't always working if DatabaseQuerySelectFulltext modified the query --- .../Fieldtype/FieldtypeComments/FieldtypeComments.module | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module b/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module index 94be8867..472efb5c 100644 --- a/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module +++ b/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module @@ -1222,7 +1222,13 @@ class FieldtypeComments extends FieldtypeMulti { $countQuery->leftjoin($leftJoin); } - if(empty($sorts)) $sorts[] = "$table.created DESC"; + if(count($selectQuery->get('orderby')) && !empty($sorts)) { + $selectQuery->set('orderby', array()); + } + + if(empty($sorts)) { + $sorts[] = "$table.created DESC"; + } $selectQuery->orderby(implode(',', $sorts)); $selectQuery->limit("$start,$limit");