diff --git a/securesite.install b/securesite.install index 26c03ce..09b6690 100644 --- a/securesite.install +++ b/securesite.install @@ -9,6 +9,8 @@ * Implements hook_enable(). */ function securesite_enable() { + // Make sure other boot functions run before ours. + securesite_ensure_module_weight(); if (variable_get('securesite_enabled', SECURESITE_DISABLED) == SECURESITE_403) { if (($site_403 = variable_get('site_403', '')) != 'securesite_403') { variable_set('securesite_403', variable_get('site_403', '')); @@ -61,3 +63,24 @@ function securesite_update_6200() { variable_del('securesite_filter_pages'); variable_del('securesite_filter_pages_type'); } + +/** + * Implementation of hook_update_N(). + * Make sure other boot functions run before ours. + */ +function securesite_update_6201() { + securesite_ensure_module_weight(); +} + + +function securesite_ensure_module_weight() { + $boot = drupal_map_assoc(module_implements('boot')); + unset($boot['securesite']); + if (!empty($boot)) { + $weight = db_query("SELECT MAX(weight) FROM {system} WHERE type = 'module' AND status = 1 AND name IN (:names)", array(':names' => $boot))->fetchField(); + if (!is_numeric($weight)) { + $weight = 0; + } + db_query("UPDATE {system} SET weight = :weight WHERE type = 'module' AND status = 1 AND name = 'securesite'", array(':weight' => ++$weight)); + } +} \ No newline at end of file