Commit 3befa224 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

Attempt to capture drupal error messages and integrate them with provision...

Attempt to capture drupal error messages and integrate them with provision errors, to keep them in the correct order
parent ee4d0fa4
......@@ -120,7 +120,7 @@ function _provision_mysql_import_dump($dump_file, $db_name, $db_user, $db_passwd
PROVISION_PERM_ERROR);
if ($readable) {
provision_log("notice", sprintf("Importing database using command: mysql -u%s -p%s -h%s %s < %s",
$db_user, 'XXXXXXXXXX', $db_host, $db_name, $dump_file));
$db_user, $db_passwd, $db_host, $db_name, $dump_file));
provision_shell_exec("mysql -u%s -p%s -h%s %s < %s",
$db_user, $db_passwd, $db_host, $db_name, $dump_file );
}
......
......@@ -36,12 +36,15 @@
*
*/
function provision_invoke($hook, $url, &$data, $rollback = false) {
if (!$rollback) {
foreach (module_implements("provision_$hook") as $name) {
_provision_log_messages();
$completed[] = $name;
$func = $name . "_provision_" . $hook;
$func($url, $data);
# this is run before and after so that messages appear in the correct order.
_provision_log_messages();
if (provision_get_error()) {
# As soon as an error occurs, roll back
$rollback = TRUE;
......@@ -68,6 +71,30 @@ function provision_invoke($hook, $url, &$data, $rollback = false) {
}
}
/**
* Turn drupal_set_message errors into provision_log errors
*/
function _provision_log_messages() {
$messages = drupal_get_messages();
# Drupal message errors.
foreach ((array) $messages['error'] as $error) {
if (preg_match("/^warning:/", $error)) {
provision_log("warning", ereg_replace("/^warning: /", '', $error));
}
elseif (preg_match("/^user warning:/", $error)) {
provision_log("error", ereg_replace("/^user warning: /", '', $error));
}
else {
provision_log("error", $error);
}
}
}
/**
* Return output to the command line.
*
......
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