Trying to debug a problem that turned out to be an overlong URL (myabe a point for future work) I discovered that the apachesolr_of module facets were still being requested even when that module was disabled. I'm working up a quick 1st pass patch, though wondering if there is a better approach.

In D7 I think there is a hook for when any module is disabled, but that doesn't help us for D5 and D6.

Comments

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new2.11 KB
Scott Reynolds’s picture

Scott Reynolds’s picture

In cck, the modules do a hook_disable and then a content_notify().

Content_notify allows content.module to clean up. I don't think you need that much but maybe ...

http://api.lullabot.com/content_notify

pwolanin’s picture

StatusFileSize
new0 bytes

Now with some little APi wrappers too. Since they are a BC addition, I think ok, for 1.x.

pwolanin’s picture

StatusFileSize
new4.14 KB

oops - bad patch - d.o CVS seems to have flaked out

pwolanin’s picture

Sure we could also do a general notify call instead of just specifically deleting facets.

Probably there is not much overhead to module_exists(0 so it may be worth jsut keeping that?

Scott Reynolds’s picture

Haven't tested but i like it

Index: apachesolr_search.module
===================================================================
--- apachesolr_search.module	(revision 5122)
+++ apachesolr_search.module	(working copy)
@@ -285,6 +285,10 @@
   $facet_missing = variable_get('apachesolr_facet_missing', array());
 
   foreach (apachesolr_get_enabled_facets() as $module => $module_facets) {
+    if (!module_exists($module)) {
+      // When modules are disabled their facet settings may remain.
+      continue;
+    }
     foreach($module_facets as $delta => $facet_field) {
       // TODO: generalize handling of date and range facets.
       if ($module == 'apachesolr_search' && ($facet_field == 'created' || $facet_field == 'changed')) {

Positive you need that hunk?

janusman’s picture

Code looks good, need to actually install OG and try it out =)

janusman’s picture

Status: Needs review » Reviewed & tested by the community

It works:

Before the patch:

With OG and apachesolr_og enabled, and the group filter enabled, a search request to Solr includes facet.field=im_og_gid
If the apachesolr_og module is then disabled, the search request still includes it.

After the patch:
When disabling the apachesolr_og module, the Solr request no longer includes that facet.

One caveat:
With the patch, when re-enabling apachesolr_og, one has to go to the "Enabled filters" tab and enable the OG facet again.
Is this expected behavior? If not a simple drupal_set_message() to the admin when disabling apachesolr_og could suffice =)

pwolanin’s picture

The behavior may happen anyway if you submit the enabled filters form while the module is disabled, so this way at least it is consistently disabled.

I'm not totally certain we need the module_exists() check, but not every module is going to clean up after itself.

pwolanin’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

committed to 6.x-1.x

claudiu.cristea’s picture

Patch for DRUPAL-5--2.

claudiu.cristea’s picture

Committed to 5.x-2.x.

robertdouglass’s picture

Status: Patch (to be ported) » Fixed

#610656 by pwolanin, claudiu.cristea | Scott Reynolds: Fixed Facets requests for non-enabled modules.

Now in Drupal 6.x-2.x as well.

Status: Fixed » Closed (fixed)

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