diff --git a/commands/core/drupal/batch.inc b/commands/core/drupal/batch.inc index 2823dd6..307d9f5 100644 --- a/commands/core/drupal/batch.inc +++ b/commands/core/drupal/batch.inc @@ -140,6 +140,7 @@ function _drush_batch_worker() { 'finished' => &$finished, 'message' => &$task_message, ); + $batch_context = new BatchArrayObject($batch_context); call_user_func_array($function, array_merge($args, array(&$batch_context))); if ($finished == 1) { diff --git a/commands/core/drupal/batch_6.inc b/commands/core/drupal/batch_6.inc index 4caba3b..e7d6ead 100644 --- a/commands/core/drupal/batch_6.inc +++ b/commands/core/drupal/batch_6.inc @@ -105,6 +105,7 @@ function _drush_batch_worker() { // Build the 'context' array, execute the function call, // and retrieve the user message. $batch_context = array('sandbox' => &$current_set['sandbox'], 'results' => &$current_set['results'], 'finished' => &$finished, 'message' => &$task_message); + $batch_context = new BatchArrayObject($batch_context); // Process the current operation. call_user_func_array($function, array_merge($args, array(&$batch_context))); } diff --git a/includes/batch.inc b/includes/batch.inc index 5260046..f0e70ed 100644 --- a/includes/batch.inc +++ b/includes/batch.inc @@ -27,6 +27,20 @@ /** + * Class used to wrap $context and catch when message keys change. + */ +class BatchArrayObject extends ArrayObject { + function offsetSet($name, $value) { + if ($name == 'message') { + drush_log($value, 'ok'); + } + elseif ($name == 'error_message') { + drush_log($value, 'error'); + } + } +} + +/** * Process a Drupal batch by spawning multiple Drush processes. * * This function will include the correct batch engine for the current