Permalink
Browse files

fix(search): hooks no longer reset order_by clauses

Search hooks now respect order_by clauses passed to the hook if no
sort parameter is set.
  • Loading branch information...
hypeJunction committed Feb 11, 2016
1 parent 741439a commit b15b9e946c66c3afe2721d2160ea1db742e0a6a8
Showing with 12 additions and 4 deletions.
  1. +12 −4 mod/search/search_hooks.php
@@ -35,7 +35,9 @@ function search_objects_hook($hook, $type, $value, $params) {
}
$params['count'] = FALSE;
- $params['order_by'] = search_get_order_by_sql('e', 'oe', $params['sort'], $params['order']);
+ if (isset($params['sort']) || !isset($params['order_by'])) {
+ $params['order_by'] = search_get_order_by_sql('e', 'oe', $params['sort'], $params['order']);
+ }
$params['preload_owners'] = true;
$entities = elgg_get_entities($params);
@@ -89,7 +91,9 @@ function search_groups_hook($hook, $type, $value, $params) {
}
$params['count'] = FALSE;
- $params['order_by'] = search_get_order_by_sql('e', 'ge', $params['sort'], $params['order']);
+ if (isset($params['sort']) || !isset($params['order_by'])) {
+ $params['order_by'] = search_get_order_by_sql('e', 'ge', $params['sort'], $params['order']);
+ }
$entities = elgg_get_entities($params);
// add the volatile data for why these entities have been returned.
@@ -165,7 +169,9 @@ function search_users_hook($hook, $type, $value, $params) {
}
$params['count'] = FALSE;
- $params['order_by'] = search_get_order_by_sql('e', 'ue', $params['sort'], $params['order']);
+ if (isset($params['sort']) || !isset($params['order_by'])) {
+ $params['order_by'] = search_get_order_by_sql('e', 'ue', $params['sort'], $params['order']);
+ }
$entities = elgg_get_entities($params);
// add the volatile data for why these entities have been returned.
@@ -279,7 +285,9 @@ function search_tags_hook($hook, $type, $value, $params) {
}
$params['count'] = FALSE;
- $params['order_by'] = search_get_order_by_sql('e', null, $params['sort'], $params['order']);
+ if (isset($params['sort']) || !isset($params['order_by'])) {
+ $params['order_by'] = search_get_order_by_sql('e', null, $params['sort'], $params['order']);
+ }
$entities = elgg_get_entities($params);
// add the volatile data for why these entities have been returned.

0 comments on commit b15b9e9

Please sign in to comment.