You are here

function hosting_package_comparison in Hosting 7.3

Same name and namespace in other branches
  1. 6.2 package/hosting_package.instance.inc \hosting_package_comparison()
  2. 7.4 package/hosting_package.instance.inc \hosting_package_comparison()

@todo Please document this function.

See also

http://drupal.org/node/1354

2 calls to hosting_package_comparison()
hosting_migrate_platform_batch in migrate/hosting_migrate.batch.inc
Batch comparison of site packages between platforms to determine if the site can be migrated to the target platform or not.
hosting_task_migrate_form in migrate/hosting_migrate.module
Implements hook_form().

File

package/hosting_package.instance.inc, line 332
API for mapping packages to various Hosting node types

Code

function hosting_package_comparison($current, $target) {
  $current_table = _hosting_package_temporary_table($current);
  $target_table = _hosting_package_temporary_table($target);
  $status = array();
  $result = db_query("SELECT count(c.nid) AS error\n                      FROM {$current_table} c\n                      LEFT JOIN {$target_table} t\n                      ON c.nid=t.nid\n                      WHERE (t.schema_version > 0) && (c.schema_version > t.schema_version)\n                      AND c.status = :cstatus", array(
    ':cstatus' => 1,
  ));
  foreach ($result as $obj) {
    $status['error'] = $obj->error;
  }
  $result = db_query("SELECT COUNT(c.nid) AS missing\n                      FROM {$current_table} c\n                      LEFT JOIN {$target_table} t\n                      ON c.nid=t.nid\n                      WHERE t.nid IS NULL\n                      AND c.status = :c_status", array(
    ':c_status' => 1,
  ));
  foreach ($result as $obj) {
    $status['missing'] = $obj->missing;
  }
  $result = db_query("SELECT COUNT(c.nid) as upgrade\n                      FROM {$current_table} c\n                      LEFT JOIN {$target_table} t\n                      ON c.nid=t.nid\n                      WHERE (c.version_code < t.version_code) OR (c.schema_version < t.schema_version)\n                      AND c.status = :c_status", array(
    ':c_status' => 1,
  ));
  foreach ($result as $obj) {
    $status['upgrade'] = $obj->upgrade;
  }
  $result = db_query("SELECT count(c.nid) AS downgrade\n                      FROM {$current_table} c\n                      LEFT JOIN {$target_table} t\n                      ON c.nid=t.nid\n                      WHERE (c.version_code > t.version_code)");
  foreach ($result as $obj) {
    $status['downgrade'] = $obj->downgrade;
  }
  return $status;
}