Index: includes/update.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/update.inc,v retrieving revision 1.2 diff -u -p -r1.2 update.inc --- includes/update.inc 3 Aug 2009 19:37:38 -0000 1.2 +++ includes/update.inc 18 Aug 2009 04:01:56 -0000 @@ -308,9 +308,28 @@ function update_do_one($module, $number, return; } + if (!isset($context['update_log_queries'])) { + $context['log'] = (bool) variable_get('update_log_queries', FALSE); + } + + $ret = array(); $function = $module . '_update_' . $number; if (function_exists($function)) { - $ret = $function($context['sandbox']); + try { + if ($context['log']) { + Database::startLog($function); + } + $ret = $function($context['sandbox']); + } + catch (DrupalUpdateException $e) { + $ret['#abort'] = array('success' => FALSE, 'query' => $e->getMessage()); + } + catch (Exception $e) { + $ret['#abort'] = array('success' => FALSE, 'query' => $e->getMessage()); + } + if ($context['log']) { + $ret['queries'] = Database::getLog($function); + } } if (isset($ret['#finished'])) { @@ -338,6 +357,12 @@ function update_do_one($module, $number, } /** + * @class Exception class used to throw error if a module update fails. + */ +class DrupalUpdateException extends Exception { +} + +/** * Start the database update batch process. * * @param $start