diff options
Diffstat (limited to 'modules/update/update.manager.inc')
-rw-r--r-- | modules/update/update.manager.inc | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/modules/update/update.manager.inc b/modules/update/update.manager.inc index d149027bd..7649852bf 100644 --- a/modules/update/update.manager.inc +++ b/modules/update/update.manager.inc @@ -557,11 +557,16 @@ function update_manager_install_form_submit($form, &$form_state) { // Unfortunately, we can only use the directory name for this. :( $project = drupal_substr($files[0], 0, -1); - try { - update_manager_archive_verify($project, $local_cache, $directory); - } - catch (Exception $e) { - form_set_error($field, $e->getMessage()); + $archive_errors = update_manager_archive_verify($project, $local_cache, $directory); + if (!empty($archive_errors)) { + form_set_error($field, array_shift($archive_errors)); + // @todo: Fix me in D8: We need a way to set multiple errors on the same + // form element and have all of them appear! + if (!empty($archive_errors)) { + foreach ($archive_errors as $error) { + drupal_set_message($error, 'error'); + } + } return; } @@ -682,15 +687,13 @@ function update_manager_archive_extract($file, $directory) { * @param string $directory * The directory that the archive was extracted into. * - * @return void - * @throws Exception on failure. + * @return array + * An array of error messages to display if the archive was invalid. If + * there are no errors, it will be an empty array. * */ function update_manager_archive_verify($project, $archive_file, $directory) { - $failures = module_invoke_all('verify_update_archive', $project, $archive_file, $directory); - if (!empty($failures)) { - throw new Exception(t('Unable to extract %file', array('%file' => $archive_file))); - } + return module_invoke_all('verify_update_archive', $project, $archive_file, $directory); } /** @@ -770,11 +773,13 @@ function update_manager_batch_project_get($project, $url, &$context) { } // Verify it. - try { - update_manager_archive_verify($project, $local_cache, $extract_directory); - } - catch (Exception $e) { - $context['results']['errors'][$project] = $e->getMessage(); + $archive_errors = update_manager_archive_verify($project, $local_cache, $extract_directory); + if (!empty($archive_errors)) { + // We just need to make sure our array keys don't collide, so use the + // numeric keys from the $archive_errors array. + foreach ($archive_errors as $key => $error) { + $context['results']['errors']["$project-$key"] = $error; + } return; } |