From 05ba4976aa4e88d5cacf29da9de13f72ee4e5b3a Mon Sep 17 00:00:00 2001 From: Nigel Banks Date: Wed, 20 Nov 2013 00:32:52 +0100 Subject: [PATCH] Can now uninstall islandora and dependant solution packs. Drupal requires modules to be disabled before uninstalling. Thus classes Drupal would otherwise autoload when needed are no longer present in the registry during the uninstall hook. Also the required hook for uninstalling __islandora_required_objects__ is not availible. Now required classes for uninstalling are manually loaded, and the module file which contains the __islandora_required_objects__ hook is manually loaded as well. --- includes/solution_packs.inc | 11 ++++++++++- includes/tuque.inc | 1 + islandora.module | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/solution_packs.inc b/includes/solution_packs.inc index 7cf0351a..6a005a18 100644 --- a/includes/solution_packs.inc +++ b/includes/solution_packs.inc @@ -28,7 +28,16 @@ function islandora_solution_packs_get_required_objects($module = NULL) { if (!$required_objects) { $connection = islandora_get_tuque_connection(); - $required_objects = module_invoke_all('islandora_required_objects', $connection); + if (isset($module)) { + // The module may be disabled when this function runs, as modules must be + // disabled before they can be uninstalled. We must manually load the + // module file to use it's islandora_required_objects hook. + module_load_include('module', $module, $module); + $required_objects = module_invoke($module, 'islandora_required_objects', $connection); + } + else { + $required_objects = module_invoke_all('islandora_required_objects', $connection); + } } if ($module !== NULL) { diff --git a/includes/tuque.inc b/includes/tuque.inc index ec278192..7aed2556 100644 --- a/includes/tuque.inc +++ b/includes/tuque.inc @@ -85,6 +85,7 @@ class IslandoraTuque { } if (self::exists()) { + module_load_include('inc', 'islandora', 'includes/tuque_wrapper'); $this->connection = new IslandoraRepositoryConnection($url, $user_string, $pass_string); $this->connection->reuseConnection = TRUE; $this->api = new IslandoraFedoraApi($this->connection); diff --git a/islandora.module b/islandora.module index 4a1a051e..25244bbc 100644 --- a/islandora.module +++ b/islandora.module @@ -1113,6 +1113,7 @@ function islandora_default_islandora_printer_object($object, $alter) { * A IslandoraTuque instance */ function islandora_get_tuque_connection($user = NULL, $url = NULL) { + module_load_include('inc', 'islandora', 'includes/tuque'); $tuque = &drupal_static(__FUNCTION__); if (!$tuque) { if (IslandoraTuque::exists()) {