From 05fb7aafd471e20272c79e36ad6e49d146e5c5b2 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Fri, 10 Aug 2018 18:11:37 +0800 Subject: [PATCH] Order by the field(s) used to find duplicates When searching for duplicates, also sort the results by the fields used to find the duplicates. --- admin/batch_manager_global.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php index 688bb5c49..fce6087f5 100644 --- a/admin/batch_manager_global.php +++ b/admin/batch_manager_global.php @@ -651,10 +651,15 @@ if (count($page['cat_elements_id']) > 0) $is_category = true; } + // If using the 'duplicates' filter, + // order by the fields that are used to find duplicates. if (isset($_SESSION['bulk_manager_filter']['prefilter']) - and 'duplicates' == $_SESSION['bulk_manager_filter']['prefilter']) + and 'duplicates' === $_SESSION['bulk_manager_filter']['prefilter'] + and isset($duplicates_on_fields)) { - $conf['order_by'] = ' ORDER BY file, id'; + // The $duplicates_on_fields variable is defined in ./batch_manager.php + $order_by_fields = array_merge( $duplicates_on_fields, array( 'id' ) ); + $conf['order_by'] = ' ORDER BY '.join(', ', $order_by_fields); } $query = '