function drush_do_multiple_command
| 6.x drush.inc | drush_do_multiple_command($command, $source_record, $destination_record, $allow_single_source = FALSE) |
| 5.x drush.inc | drush_do_multiple_command($command, $source_record, $destination_record, $allow_single_source = FALSE) |
| 3.x drush.inc | drush_do_multiple_command($command, $source_record, $destination_record, $allow_single_source = FALSE) |
| 4.x drush.inc | drush_do_multiple_command($command, $source_record, $destination_record, $allow_single_source = FALSE) |
Used by functions that operate on lists of sites, moving information from the source to the destination. Currenlty this includes 'drush rsync' and 'drush sql sync'.
Related topics
2 calls to drush_do_multiple_command()
- drush_core_rsync in commands/
core/ rsync.core.inc - Entrypoint for drush rsync.
- drush_sql_sync in commands/
sql/ sync.sql.inc
File
- includes/
drush.inc, line 1354 - The drush API implementation and helpers.
Code
function drush_do_multiple_command($command, $source_record, $destination_record, $allow_single_source = FALSE) {
$is_multiple_command = FALSE;
if ((($allow_single_source == TRUE) || array_key_exists('site-list', $source_record)) && array_key_exists('site-list', $destination_record)) {
$is_multiple_command = TRUE;
$source_path = array_key_exists('path-component', $source_record) ? $source_record['path-component'] : '';
$destination_path = array_key_exists('path-component', $destination_record) ? $destination_record['path-component'] : '';
$target_list = array_values(drush_sitealias_resolve_sitelist($destination_record));
if (array_key_exists('site-list', $source_record)) {
$source_list = array_values(drush_sitealias_resolve_sitelist($source_record));
if (drush_sitealias_check_lists_alignment($source_list, $target_list) === FALSE) {
if (array_key_exists('unordered-list', $source_record) || array_key_exists('unordered-list', $destination_record)) {
drush_sitelist_align_lists($source_list, $target_list, $aligned_source, $aligned_target);
$source_list = $aligned_source;
$target_list = $aligned_target;
}
}
}
else {
$source_list = array_fill(0, count($target_list), $source_record);
}
if (!drush_get_context('DRUSH_SIMULATE')) {
drush_print(dt('You are about to !command between all of the following targets:', array('!command' => $command)));
$i = 0;
foreach ($source_list as $one_source) {
$one_target = $target_list[$i];
++$i;
drush_print(dt(' !source will overwrite !target', array('!source' => drush_sitealias_alias_record_to_spec($one_source) . $source_path, '!target' => drush_sitealias_alias_record_to_spec($one_target) . $destination_path)));
}
if (drush_confirm('Continue? ') === FALSE) {
return drush_user_abort();
}
}
$data = drush_redispatch_get_options();
$i = 0;
foreach ($source_list as $one_source) {
$one_target = $target_list[$i];
++$i;
$source_spec = drush_sitealias_alias_record_to_spec($one_source);
$target_spec = drush_sitealias_alias_record_to_spec($one_target);
drush_log(dt('Begin do_multiple !command via backend invoke', array('!command' => $command)));
$values = drush_invoke_process('@self', $command, array($source_spec . $source_path, $target_spec . $destination_path), $data);
drush_log(dt('Backend invoke is complete'));
}
}
return $is_multiple_command;
}