Download & Extend

Fix sort parameters to use field aliases, validate in query object

Project:Apache Solr Search Integration
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Currently the sort parameters don't respect any field aliases that are set into the query object - since this affects Drupal.org, we want to fix it. We also have sort validation happening in the module instead of inside the query object where it belongs.

Comments

#1

Status:active» needs work

here's a start

AttachmentSizeStatusTest resultOperations
sort-fix-507708-1.patch5.77 KBIgnored: Check issue status.NoneNone

#2

Status:needs work» needs review

I'm not sure about the variable return type of method get_solrsort() versus adding another method to the interface.

AttachmentSizeStatusTest resultOperations
sort-fix-507708-2.patch10.82 KBIgnored: Check issue status.NoneNone

#3

I'm not sure about the variable return type of method get_solrsort() versus adding another method to the interface.

AttachmentSizeStatusTest resultOperations
sort-fix-507708-2.patch10.82 KBIgnored: Check issue status.NoneNone

#4

slight cleanup

AttachmentSizeStatusTest resultOperations
sort-fix-507708-3.patch10.88 KBIgnored: Check issue status.NoneNone

#5

Overall good, here's one small point:

- function get_solrsort();
+ function get_solrsort($as_array = FALSE);

Generally speaking, a function should have only one return type. I suggest doing something like:

function get_sort_column()

function get_sort_direction()

or always return a structure.

#6

if (!empty($fv['apachesolr_search']['retain-filters']) && $fv['apachesolr_search']['querystring']) {
- $querystring = $fv['apachesolr_search']['querystring'] . '&retain-filters';
+ $querystring = $fv['apachesolr_search']['querystring'] . '&retain-filters=1';
}

This isn't really related, but whatever.

ummm.....

'type' => 'bigass'

?!?

+ $this->parse_sortstring($sortstring);

Too bad we don't have overloading in PHP. Really would be nicer as an overloaded set_solrsort.

public function set_available_sort($field, $sort) {
- $this->available_sorts[$field] = $sort;
+ public function set_available_sort($name, $sort) {
+ // We expect non-aliased sorts to be added.
+ $this->available_sorts[$name] = $sort;
+ }
+

A little unclear about this...

+ protected function parse_sortstring($sortstring) {
+ // Validate and set sort parameter
+ $fields = implode('|', array_keys($this->available_sorts));

Where is the | being used here? The function to set available sorts doesn't look like it would be expecting a pipe in the array key.

#7

Guess I left my test field aliases in there...

The '|' is for the later regex so we validate that we only have an allowed sort.

AttachmentSizeStatusTest resultOperations
sort-fix-507708-7.patch10.23 KBIgnored: Check issue status.NoneNone

#8

Looks good to me.

#9

doxygen fix

AttachmentSizeStatusTest resultOperations
sort-fix-507708-8.patch10.27 KBIgnored: Check issue status.NoneNone

#10

Status:needs review» fixed

committed to 6.x

#11

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here