I'm building a custom views module and when I expose a sort field, there are too many values added to the $this->params['sort'] array.

I am using solr-data, but fields and filters work just fine. For example when I expose just one sort fields, $this->params['sort'] will contain both the default sort (as field name + sort) and the active sort (also as field name + sort). This messes up the actual queries I'm sending to the solr instance.

Any ideas? Is this a bug or did I do something wrong?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Danny_Joris’s picture

FileSize
143.8 KB

screenshot attached

Danny_Joris’s picture

Or: how do I figure out which function calls a handler and when, so I can trace this sort handler call back?

Danny_Joris’s picture

Two more attachments.
- One shows two exposed sort filters. It will always add the default setting of the first exposed filter in the row.
- The other shows two non-exposed filters. The result is fine here.

dawehner’s picture

In general this might be a problem of your custom handlers.

Here is a link to your project: https://github.com/DannyJoris/islandora_solr_views just for reference if someone else has a look at it.

dawehner’s picture

So i'm wondering whether you can reproduce that with a totally normal sql view on something like the node base table.

This at the end would dramatically simplify the route to the bugfix.

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Update status.

Danny_Joris’s picture

views_handler_sort::query() also passes the default sort first when exposed. The difference is that when it passes the values to views_plugin_query_default::add_orderby() , the views_plugin_query_default::orderby property gets populated, it doesn't seem to be the same property?

When I check $this->orderby in the same page load, it populates orderby with the default value first, but the second sort value doesn't seem to be added to this array, instead it looks like a new empty array.

$this->orderby[] = array(
  'field' => $as,
  'direction' => strtoupper($order)
);
esmerel’s picture

Status: Postponed (maintainer needs more info) » Active
esmerel’s picture

Issue summary: View changes

fixed wrong formatting