You are here

function rotor_check_update_abort in Rotor Banner 7

Same name and namespace in other branches
  1. 6.2 rotor.install \rotor_check_update_abort()

Helper function for rolling back updates if dependency checks fail.

Parameters

$modules: An associative array of modules to check. Key is module name, value is human-readable name.

$current_update: The current update.

Return value

If a dependency check fails, a return array marked as failed (with a user message) -- otherwise, an empty array.

1 call to rotor_check_update_abort()
rotor_update_6200 in ./rotor.install

File

./rotor.install, line 191
Provides install and uninstall functions for rotor.

Code

function rotor_check_update_abort($modules, $current_update) {
  $ret = array();

  // Dependency check failed.
  if ($message = rotor_check_dependencies($modules)) {

    // Remove all subsequent rotor updates.
    if (is_array($_SESSION['updates_remaining'])) {
      foreach ($_SESSION['updates_remaining'] as $key => $update) {
        if ($update['module'] = 'rotor' && intval($update['version']) > $current_update) {
          unset($_SESSION['updates_remaining'][$key]);
        }
      }

      // Reset the internal pointer on this session variable, otherwise
      // core's update_do_updates() function could have a problem
      // unsetting the currently running update.
      reset($_SESSION['updates_remaining']);

      // Clarify the nature of the error, and what to do next.
      // Unfortunately, there's no elegant way to properly reset the schema version
      // programatically, so we'll have to instruct the user to redo the update
      // manually.
      $message .= '<p>' . t("This and all subsequent updates of Rotor were safely aborted.\n          Correct the problems listed above, then <a href=\"!update_path\">re-run update.php</a>,\n          click 'Select versions', select update %update for rotor, and click 'Update'.", array(
        '%update' => $current_update,
        '!update_path' => base_path() . 'update.php?op=selection',
      )) . '</p><p><em>' . t("Note: you will most likely need to disable the Rotor module temporarily in order to resolve the issues above.\n          If necessary, please refer to Rotor's UPGRADE.txt for further details regarding this upgrade problem.") . '</em></p>';
      $ret['#abort'] = array(
        'success' => FALSE,
        'query' => $message,
      );
    }
  }
  return $ret;
}