Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We had a problem where the Solr Views cache was returning wrong results when we used exposed filters. The cache was not tracking distinct result sets based on all possible parameters. I tracked the problem down to the fact that get_results_key() didn't have all the information it needed to create a unique results key for each possible result set. My fix for this, included in the patch here, was to add the query and params arrays to the $view->build_info array as those really are build parameters. This way, the caching code can track results for all possible distinct result sets properly.
Comment | File | Size | Author |
---|---|---|---|
#15 | apachesolr_views_results_cache-882424-15.patch | 2.39 KB | caminadaf |
#9 | apachesolr_views_results_cache-882424-9.patch | 2.4 KB | caminadaf |
| |||
#4 | patch-418774-2.patch | 662 bytes | JeremyFrench |
apachesolr_views_results_cache.patch | 467 bytes | mgriego | |
Comments
Comment #1
Scott Reynolds CreditAttribution: Scott Reynolds commentedPerhaps I am looking at the wrong thing. This is views_plugin_cache::get_results_key
both query and apachesolr_params aren't in there.
Does this mean we need to override get_results_key in the cache plugin?
Comment #2
mgriego CreditAttribution: mgriego commentedNo, we don't need to override get_results_key. I specifically tried to avoid that actually. The query and apachesolr_params are added to $view->build_info, which is the first element added to $key_data.
Comment #3
JeremyFrench CreditAttribution: JeremyFrench commentedThings may have moved on a bit in views since this bugs was raised. I have had more luck adding a method
get_cache_info()
to the apachesolr_views_query object.Get_results_key()
now calls this and if not present it will not cache.If I get some robust code in there I'll submit a patch.
Comment #4
JeremyFrench CreditAttribution: JeremyFrench commentedAttached is patch, first patch I have done from git so apologies if formatting is wrong.
Comment #5
JeremyFrench CreditAttribution: JeremyFrench commentedComment #6
mgriego CreditAttribution: mgriego commentedThat looks right to me. I'll be testing that patch in our environment this week and will report back how it works.
Comment #7
mgriego CreditAttribution: mgriego commentedThis does appear to be working for us.
Comment #8
caminadaf CreditAttribution: caminadaf at CI&T for Pfizer, Inc. commentedThis is not working on 7.x, a views cache plugin class needs to be implemented.
Comment #9
caminadaf CreditAttribution: caminadaf at CI&T for Pfizer, Inc. commentedI took the liberty of creating the cache plugin and doing a get_cache_key for this module, since apachesolr_views' query variable is not an object, but a string.
Comment #11
caminadaf CreditAttribution: caminadaf at CI&T for Pfizer, Inc. commentedI mistakenly triggered a test build, but there are no tests for this module... Moving back to review
Comment #14
MiroslavBanov CreditAttribution: MiroslavBanov as a volunteer commentedLooks fine.
But I almost never use views cache, and I am not using this module currently, so will wait for other reviewer to RTBC.
Comment #15
caminadaf CreditAttribution: caminadaf at CI&T for Pfizer, Inc. commentedUpdating the patch since the typehint broke the fix