Drupal has an annoying "feature" which causes update hooks for disabled modules to be executed by update.php (or drush updb).

When using alternative search methods (apachesolr module), the search_api and panopoly_search modules are disabled.

However, when updates are run, panopoly_search update 7005 causes this error:

Fatal error: Call to undefined function search_api_index_load_multiple() in /opt/clients/demo.openatrium.com/drupal/profiles/openatrium/modules/panopoly/panopoly_search/panopoly_search.install on line 110
Drush command terminated abnormally due to an unrecoverable error.

In update hooks, always check to see module_exists before calling a module that might be disabled.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

caschbre’s picture

Status: Active » Needs review
FileSize
1.73 KB
dsnopek’s picture

Status: Needs review » Needs work

Thanks, @caschbre!

Let's do module_exists("panopoly_search") rather than "search_api" - because that's really what this is about. We can't have "panopoly_search" enabled without "search_api" and reverting our Feature if our Feature isn't enabled isn't really going to help anything.

caschbre’s picture

Ah, ok... so have the module check if itself is enabled?

caschbre’s picture

Status: Needs work » Needs review
FileSize
1.73 KB
dsnopek’s picture

Title: Check if search_api exists in panopoly_search update 7005 » Check if panopoly_search is enabled in panopoly_search update 7005

Yeah... Now that I know that Drupal runs update hooks for disabled modules, we should probably do an audit of our update hooks. I'll make an issue about it.

caschbre’s picture

Yeah, I've never run across that issue before. Is there a d.o. issue somewhere on it? Might see what we can do to fix it there.

dsnopek’s picture

  • dsnopek committed 7e739b5 on 7.x-1.x
    Update Panopoly Search for Issue #2434591 by caschbre: Check if...
dsnopek’s picture

Status: Needs review » Fixed

Patch looks good, thanks! Committed.

Status: Fixed » Closed (fixed)

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

lunazoid’s picture

Status: Closed (fixed) » Needs review
FileSize
3.53 KB

Sorry to reopen this issue, but it seems like the place to put this. I just encountered this issue updating to Panopoly 1.27, as update hooks 7006 and 7007 didn't have the check in place. This patch adds it to those hooks as well.

dsnopek’s picture

Thanks for the patch! However, this should be a new issue to make it easy to dissect our git history later.

  • dsnopek committed 6a131a5 on 7.x-1.x authored by caschbre
    Issue #2434591 by caschbre: Check if panopoly_search is enabled in...
  • dsnopek committed 74588fb on 7.x-1.x authored by caschbre
    Issue #2434591 by caschbre: Check if panopoly_search is enabled in...