Problem/Motivation
When you use the facetapi_pretty_paths module in combination with page_manager, you get a solr error every time you clear the cache.
Steps to reproduce:
I started with a clean Drupal installation and created a new content type with a term reference field.
I created a solr server and a node index. I added the term reference field to solr and created a facet block for it.
In facet display I added a pretty path alias and checked the Reuse term alias checkbox.
I created a new view content pane for this node index.
Then i created a new page using page manager and i placed the view on it and the facets.
When I activate a filter everything works fine, but when I clear the cache using crush and I immediately refresh the page with pretty paths it gives an Solr java.lang.NumberFormatException.
When I disable this module, everything works fine again.
After some couple of hours digging into the code I found out that when I comment this line of code on line 693 in facetapi.module I always get this error. :
function facetapi_get_facet_info() {
....
//cache_set($cid, $facet_info[$searcher], 'cache', CACHE_TEMPORARY);
}
When i Comment this line of code the facet info no longer comes from the cache.
Any ideas?
Edit: I changed the Solr server to a database server and it doesn't show the facet filters or the view.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | facetapi_pretty_paths-hook_facetpai_facet_info_alter-2233741-4.patch | 2.45 KB | jaydub |
Comments
Comment #1
jeroentI think it has something to do with the hook_facetapi_facet_info_alter().
When I delete the facetapi_adapter_load and replace it with $facet_settings->settings['pretty_paths_taxonomy_pathauto'] = 1; I don't get the error.
Comment #2
jeroentComment #3
dasjocould you provide a patch for others to try out? that would be very much appreciated.
https://drupal.org/node/707484
Comment #4
jaydub commentedI ran into this problem or at least a variation on this. I also believe that issue #2327729: Flush cache that makes views empty and show machine_name-tid is caused by the same issue.
I think I have figured out what is happening and have a patch that addresses the issue.
What happens is that on a cache clear, the facet info that is defined by this and other modules is rebuilt. Facet API Pretty Paths adds to the defined facet data in its hook_facetapi_facet_info_alter() hook. In this hook the facetapi_adapter_load() function is called. When this function is called the relevant defined searchers are retrieved or in the case of post cache clear are rebuilt and stored in cache. When this rebuild happens the searcher class in question is instantiated. When the class is instantiated a couple methods are run which in the end results in the fetchParams() method of the FacetapiUrlProcessorPrettyPaths class in url_processor_pretty_paths.inc to be called. This will attempt to process the current URL in order to parse the pretty path facets. However since the logic to append the facet info in hook_facetapi_facet_info_alter() happens AFTER this method is run (again, via facetapi_adapter_load), the result is that the current URL is parsed before the defined facets will have been altered to add in custom handling for taxonomy facets.
This is why you get a Solr error as Solr is sent a taxonomy facet without the facet having been parsed to pull out the taxonomy term ID alone.
The attached patch replaces the facetapi_adapter_load() call which is only there to extract facet settings with a direct call to facetapi_get_searcher_settings(). This gets the necessary facet settings w/o the side effect of the instantiation of the searcher class.
The patch includes a long comment to explain all this so the module maintainer can feel free to remove or shorten as necessary.
In my own testing locally this has resolved the issue with the failed searches (using Search API in our case).
Comment #5
jeroent@Jaydub,
Thank you for your patch! I tried it, and the error was gone when I clear the cache.
Comment #6
dabbor commentedThanks jaydub, the patch works for me too. I can confirm the need for such a patch, I was already worried I would need to continue debugging the Facet API Pretty Paths and figure the solution myself. I appreciate your detailed explanation of the problem ;)
Comment #8
dasjoThanks @jaydub!
Patch looks solid. I was able to reproduce the problem on a local site and verified that the patch solves the issue.
Committed