Commit 398cc27d authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

Fixed on-demand module loading. Add pre_verify and post_verify hooks. Added a...

Fixed on-demand module loading. Add pre_verify and post_verify hooks. Added a script which clears existing drupal caches to allow new modules that have been enabled etc, to be picked up
parent 4c0175e4
......@@ -502,10 +502,28 @@ function provision_drupal_provision_verify($url, &$data) {
// Requires at least the database settings to complete.
_provision_drupal_create_settings_file($url, $data);
}
}
/**
* Implementation of hook_provision_post_verify
*/
function provision_drupal_provision_post_verify($url, &$data) {
if ($url) {
_provision_drupal_rebuild_caches($url, $data);
}
}
/**
* Runs an external script to reload all the various drupal caches
*/
function _provision_drupal_rebuild_caches($url, &$data) {
if ($url) {
$cmd = sprintf("php %s/provision_drupal_clear.php %s", dirname(__FILE__), escapeshellarg($url));
provision_exec($cmd, $data);
}
}
/**
* Find available profiles on this platform.
*/
......
<?php
// $Id$
/**
* @file
* Rebuild all the caches
*/
if ($argv[1]) {
// Fake the necessary HTTP headers that Drupal needs:
$drupal_base_url = parse_url(sprintf("http://" . $argv[1]));
$_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
$_SERVER['PHP_SELF'] = $drupal_base_url['path'].'/index.php';
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
$_SERVER['REMOTE_ADDR'] = '';
$_SERVER['REQUEST_METHOD'] = NULL;
$_SERVER['SERVER_SOFTWARE'] = NULL;
require_once('includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once(dirname(__FILE__) . '/../provision.inc');
}
else {
print "USAGE: provision_drupal_clear.php url\n";
exit(PROVISION_FRAMEWORK_ERROR);
}
cache_clear_all();
provision_log('notice', t('Cleared all caches'));
node_types_rebuild();
provision_log('notice', t('Rebuild node type cache'));
module_rebuild_cache();
provision_log('notice', t('Rebuild module cache'));
system_theme_data();
provision_log('notice', t('Rebuild theme cache'));
node_access_rebuild();
provision_log('notice', t('Rebuild node access cache'));
menu_rebuild();
provision_log('notice', t('Rebuild menu cache'));
provision_output($argv[1], array());
......@@ -55,23 +55,29 @@ function provision_load_from_args() {
foreach ($args['options'] as $arg => $value) {
if (preg_match("/^load-([a-z\-]*)$/", $arg, $matches)) {
$module = str_replace("-", "_", $matches[1]);
provision_log("notice", t("Loaded @module on request", array("@module" => $module)));
drupal_load('module', $module);
$loaded[$module]['name'] = $module;
$loaded[$module]['filename'] = drupal_get_filename('module', $module);
// find file : can only search under provision path
$files = file_scan_directory(dirname(__FILE__), "$module.module", array('.', '..', 'CVS'), 0, TRUE, 'name');
if (isset($files[$module])) {
provision_log("notice", t("Loading @module on request", array("@module" => $module)));
$loaded[$module]['name'] = $module;
$loaded[$module]['filename'] = $files[$module]->filename;
include_once($loaded[$module]['filename']);
}
$reset = TRUE;
}
}
if ($reset) {
if ($reset && is_array($loaded)) {
$existing = array();
$list = module_list(TRUE, FALSE);
foreach ($list as $module) {
$loaded[$module]['name'] = $module;
$loaded[$module]['filename'] = drupal_get_filename('module', $module);
$existing[$module]['name'] = $module;
$existing[$module]['filename'] = drupal_get_filename('module', $module);
drupal_load('module', $module);
}
module_list(TRUE, FALSE, FALSE, $loaded);
$loaded = array_merge($existing, $loaded);
module_list(TRUE, FALSE, TRUE, $loaded);
// Force to regenerate the stored list of hook implementations.
module_implements('', FALSE, TRUE);
module_implements('', TRUE, TRUE);
// As we have missed the bootstrap phase, we need to run
// our own provision_init hook to initialize modules.
module_invoke_all('provision_init');
......@@ -592,7 +598,12 @@ function _provision_verify($url = NULL) {
$data = provision_get_site_data($url);
}
$rolled_back = provision_invoke("verify", $url, $data);
if (!$rolled_back = provision_invoke("pre_verify", $url, $data)) {
if (!$rolled_back = provision_invoke("verify", $url, $data)) {
$rolled_back = provision_invoke("post_verify", $url, $data);
}
}
// We only save the settings if they validated correctly, not before.
if (!$rolled_back) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment