function drush_sitelist_align_lists

6.x sitealias.inc drush_sitelist_align_lists(&$source, &$target, &$source_result, &$target_result)
3.x sitealias.inc drush_sitelist_align_lists(&$source, &$target, &$source_result, &$target_result)
4.x sitealias.inc drush_sitelist_align_lists(&$source, &$target, &$source_result, &$target_result)
5.x sitealias.inc drush_sitelist_align_lists(&$source, &$target, &$source_result, &$target_result)

If the source and target lists contain alias records to the same sets of sites, but in different orders, this routine will re-order the lists so that they are in alignment.

TODO: Review the advisability of this operation.

1 call to drush_sitelist_align_lists()
drush_do_multiple_command in includes/drush.inc
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'.

File

includes/sitealias.inc, line 805
The site alias API.

Code

function drush_sitelist_align_lists(&$source, &$target, &$source_result, &$target_result) {
  $source_result = array();
  $target_result = array();

  foreach ($source as $key => $one_source) {
    $one_target = _drush_sitelist_find_in_list($one_source, $target);
    if ($one_target !== FALSE) {
      $source_result[] = $one_source;
      $target_result[] = $one_target;
      unset($source[$key]);
    }
  }

  $source = $source_result;
  $target = $target_result;
}