You are here

function hosting_migrate_platform_batch in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 migrate/hosting_migrate.batch.inc \hosting_migrate_platform_batch()
  2. 7.3 migrate/hosting_migrate.batch.inc \hosting_migrate_platform_batch()

Batch comparison of site packages between platforms to determine if the site can be migrated to the target platform or not.

1 string reference to 'hosting_migrate_platform_batch'
hosting_migrate_platform_submit in migrate/hosting_migrate.batch.inc
Implements hook_submit().

File

migrate/hosting_migrate.batch.inc, line 237
Implemented batch migration of sites.

Code

function hosting_migrate_platform_batch($site_id, $target_platform, $context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
  }
  $site = node_load($site_id);
  $profile = node_load($site->profile);
  $batch =& batch_get();

  // Determine whether the install profile is available on the target platform
  $profile_instance = hosting_package_instance_load(array(
    'i.rid' => $target_platform,
    'r.type' => 'platform',
    'n.nid' => $site->profile,
  ));
  if (!$profile_instance) {

    // Check if there is a possibly renamed profile available
    $profile_instance = hosting_package_instance_load(array(
      'i.rid' => $target_platform,
      'r.type' => 'platform',
      'p.old_short_name' => $profile->short_name,
    ));
  }
  if ($profile_instance) {
    $status = hosting_package_comparison($site->nid, $profile_instance->iid);
    $batch['form_state']['storage']['status'][$site->nid] = $status;
    $batch['form_state']['storage']['instance'][$site->nid] = $profile_instance->iid;

    // If there were no errors, this site passes and can be migrated
    if (!$status['error'] && $profile->short_name != 'hostmaster') {

      // The hostmaster site can not be upgraded via the interface.
      $batch['form_state']['storage']['passed'][$site->nid] = hosting_site_get_domain($site->title);
      return TRUE;
    }
  }
  else {
    $batch['form_state']['storage']['status'][$site->nid] = array(
      'error' => 1,
      'missing' => 0,
      'upgrade' => 0,
    );
  }
  $batch['form_state']['storage']['failed'][$site->nid] = hosting_site_get_domain($site->title);
}