You are here

function coder_upgrade_conversions_apply in Coder 7.2

Same name and namespace in other branches
  1. 7 coder_upgrade/includes/conversion.inc \coder_upgrade_conversions_apply()

Applies the module conversion code.

Execute the selected module conversion code on the selected file types in the selected directories or modules.

Return value

boolean TRUE if conversion code was successful, FALSE otherwise.

1 call to coder_upgrade_conversions_apply()
coder_upgrade_conversions_form_submit in coder_upgrade/includes/conversion.inc
Submit handler for the module conversion form.

File

coder_upgrade/includes/conversion.inc, line 296

Code

function coder_upgrade_conversions_apply($form_state) {

  // Prepare conversion parameters.
  list($upgrades, $extensions, $items) = coder_upgrade_conversions_prepare($form_state);

  // Apply conversion routines.
  //   module_load_include('inc', 'coder_upgrade', 'includes/main');
  if (variable_get('coder_upgrade_use_separate_process', FALSE)) {

    // Conversion routines will be run in a separate process.
    drupal_set_message(t('Module conversion routines will run in a separate process.'));
    $path = coder_upgrade_parameters_save($upgrades, $extensions, $items);
    $script = drupal_get_path('module', 'coder_upgrade') . '/scripts/coder_upgrade.run.php';
    $output = coder_upgrade_directory_path('base') . 'coder_upgrade.run.txt';
    $command = "php {$script} -- file={$path} > {$output}";

    // " 2>&1";
    // Execute the command and capture the output.
    exec($command, $errors, $success);
    $success = $success === 0;
    if ($success && !empty($errors)) {
      drupal_set_message(trim(implode("\n", $errors)), 'error');
    }
  }
  else {

    // Conversion routines will be run in the same process.
    module_load_include('inc', 'coder_upgrade', 'includes/main');
    drupal_set_message(t('Module conversion routines will run in the same process.'));
    $success = coder_upgrade_start($upgrades, $extensions, $items);
  }
  return $success;
}