parse_filters() gets called in certain scenarios - I ran into it when adding an alias - that can cause issues.
Here's the scenario:
1. We set a handful of fixed filters to ensure that our query only returns certain results.
2. We set an alias.
3. We lose all our filters.
We have certain filters coming from the url, and others being manually set. So long as we do everything at the right time, things basically work. Ideally, we could add an alias at any point (prepare_query, modify_query, manually) and all of our manually set filters wouldn't disappear.
I'm not sure the attached patch is the perfect patch, but it allows non-querystring filters to persist. I've chosen to push non-querystring filters to the back of the pack.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 885950.patch | 763 bytes | jpmckinney |
| #11 | 885950.patch | 1.16 KB | jpmckinney |
| #2 | 885950-preserve-add-remove-2.patch | 3.34 KB | pwolanin |
| apachesolr.patch | 1.67 KB | csevb10 |
Comments
Comment #1
pwolanin commentedcan of worms.
for example, if I remove a filter which came from the URL, and then add an alias, that filter would come back
I think this patch is not really the right approach.
Comment #2
pwolanin commentedthis is totally untested, but I think it's a workable approach.
Comment #3
csevb10 commentedTested. It functions as expected. It seems like we're hacking around things to some degree, so the solution isn't one with which I'm wholly enamored, but the previous sticky situations around clearing and adding alias has been cleaned up. If a better solution comes up later, at least we managed to fix bugs surrounding alias now, and we can simply refactor later.
Comment #4
pwolanin commentedneeds some more code comments, but committed to 6.x-1.x for immediate use in the redesign.
Comment #5
dwwFYI: now deployed on d.o and working fine:
http://drupal.org/search/apachesolr_search/signup
Comment #6
pwolanin commentedCommitted this patch to all the active branches.
Comment #7
pwolanin commentedback to active for code comments.
Comment #8
jpmckinney commentedNo longer a bug.
Comment #9
jpmckinney commentedShouldn't we remove the filter from fields_removed if we add it back with add_filter?
Comment #10
jpmckinney commentedPort my patch to 6.x-2.x and 7.x if patch goes in.
Comment #11
jpmckinney commentedComment #12
pwolanin commentedWhich version is that patch for? Or it's just cleanup for 6.x-1.x?
Comment #13
jpmckinney commentedIt's a fix for all versions, starting with 6.x-1.x
Comment #14
pwolanin commentedLogic looks fine to me - looks like as much comment changes as anything.
afaikt, the only meaningful change is this, right?
Comment #15
jpmckinney commentedYes, that's it. I fixed comments so that the two functions are comparable.
Comment #16
jpmckinney commentedFixed in 6.1, 6.2 and 7.1.
Comment #17
scor commented$name is undefined in this function. This is causing notices # Notice: Undefined variable: name in SolrBaseQuery->add_filter() (line 191 of /sites/all/modules/apachesolr/Solr_Base_Query.php).
Comment #18
jpmckinney commentedRight. Fixed.