On a recent project, I ran into an issue with the hash that gets generated off $searcher, $realm_name, $facet_name. We have a fairly typical dev, stage, prod setup. Each of our searchers are for different environment setups with different solr servers. This is working for us, until we use context to place blocks on our site.
Since the searcher changes by environment, the hash changes and a block that was displaying in dev no longer displays in stage. This adds a drupal_alter to the hash so we can alter it to have essentially the same hash in all environments. Example implementation provided.
function example_facetapi_hash_alter(&$hash, $delta) {
preg_match('/(.+@)(.+?)(:.+)/', $delta, $matches);
$delta = $matches[1] . EXAMPLE_SEARCHER_ID . $matches[3];
$hash = substr(drupal_hash_base64($delta), 0, 32);
$hash = strtr($hash, array('-' => '0', '_' => '1'));
}
Comments
Comment #1
heddnComment #3
cpliakas commentedThanks, heddn!
I like the idea of this patch. Specifically, I think it will buy us some time with the bug posted at #1818796: CSS id and classes should be case sensitive matching $delta in addition to the use case you mentioned. Moving to the 7.x-1.x-dev branch so the test bot can hack at the latest code.
Out of curiosity, are you using Search API or Apache Solr Search Integration?
Thanks,
Chris
Comment #4
heddnComment #5
heddnSorry I missed your question about search api or solr. For the project in question we are using apachesolr.
Comment #6
mvcworked perfectly to work around #1818796: CSS id and classes should be case sensitive matching $delta with facetapi 7.x-1.2. with this patch i was able to run the following hook:
fwiw i did have to manually update block.delta (i think that module was checking case-insensitively to see if deltas already existed).
thanks!
Comment #7
heddnCan we get this committed? I ran into this same problem on another site. Several hours of troubleshooting later, I remembered I filed this issue. And it fixed the problem right away.
Comment #7.0
heddnre-worked the example implementation
Comment #8
cpliakas commentedComment #10
cpliakas commented