#605292 by dww: Work-around BatchAPI's inability to propagate failure in update manager.

merge-requests/26/head
Angie Byron 2009-10-29 07:08:38 +00:00
parent 58dd4caa98
commit b1dc42eb92
1 changed files with 16 additions and 14 deletions

View File

@ -326,14 +326,21 @@ function update_manager_update_form_submit($form, &$form_state) {
* Batch callback invoked when the download batch is completed.
*/
function update_manager_download_batch_finished($success, $results) {
if ($success) {
$_SESSION['update_manager_update_projects'] = $results;
if (!empty($results['errors'])) {
$error_list = array(
'title' => t('Downloading updates failed:'),
'items' => $results['errors'],
);
drupal_set_message(theme('item_list', $error_list), 'error');
}
elseif ($success) {
$_SESSION['update_manager_update_projects'] = $results['projects'];
drupal_goto('admin/update/confirm');
}
else {
foreach($results as $project => $message) {
drupal_set_message($message, 'error');
}
// Ideally we're catching all Exceptions, so they should never see this,
// but just in case, we have to tell them something.
drupal_set_message(t('Fatal error trying to download.'), 'error');
}
}
@ -758,17 +765,13 @@ function update_manager_batch_project_get($project, $url, &$context) {
if (!isset($context['sandbox']['started'])) {
$context['sandbox']['started'] = TRUE;
$context['message'] = t('Downloading %project', array('%project' => $project));
$context['success'] = TRUE;
$context['finished'] = 0;
return;
}
// Assume failure until we make it to the bottom and succeed.
$context['success'] = FALSE;
// Actually try to download the file.
if (!($local_cache = update_manager_file_get($url))) {
$context['results'][$project] = t('Failed to download %project from %url', array('%project' => $project, '%url' => $url));
$context['results']['errors'][$project] = t('Failed to download %project from %url', array('%project' => $project, '%url' => $url));
return;
}
@ -778,7 +781,7 @@ function update_manager_batch_project_get($project, $url, &$context) {
update_manager_archive_extract($local_cache, $extract_directory);
}
catch (Exception $e) {
$context['results'][$project] = $e->getMessage();
$context['results']['errors'][$project] = $e->getMessage();
return;
}
@ -787,13 +790,12 @@ function update_manager_batch_project_get($project, $url, &$context) {
update_manager_archive_verify($project, $local_cache, $extract_directory);
}
catch (Exception $e) {
$context['results'][$project] = $e->getMessage();
$context['results']['errors'][$project] = $e->getMessage();
return;
}
// Yay, success.
$context['success'] = TRUE;
$context['results'][$project] = $url;
$context['results']['projects'][$project] = $url;
$context['finished'] = 1;
}