? .svn ? drushrc.php ? update_status ? z ? commands/core/batch.drush.inc ? commands/core/drupal/batch_6.inc ? commands/core/drupal/batch_7.inc ? includes/table.inc Index: commands/core/core.drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/core/core.drush.inc,v retrieving revision 1.69 diff -u -r1.69 core.drush.inc --- commands/core/core.drush.inc 12 Jan 2010 14:45:09 -0000 1.69 +++ commands/core/core.drush.inc 19 Jan 2010 03:26:06 -0000 @@ -147,11 +147,21 @@ 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, 'aliases' => array('is'), ); + $items['batch-process'] = array( + 'description' => dt('Process operations in the specified batch set'), + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN, + ); + $items['updatedb-batch-process'] = array( + 'description' => dt('Perform update functions'), + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_SITE, + ); + return $items; } function core_drush_engine_drupal() { $engines = array(); + $engines['batch'] = array(); $engines['update'] = array(); $engines['environment'] = array(); return $engines; @@ -421,3 +431,25 @@ function drush_core_eval($command) { eval($command . ';'); } + + +function drush_backend_batch_process($command = 'batch-process') { + drush_include_engine('drupal', 'batch', drush_drupal_major_version()); + _drush_backend_batch_process($command); +} + +function drush_batch_command($id) { + include_once('includes/batch.inc'); + drush_include_engine('drupal', 'batch', drush_drupal_major_version()); + _drush_batch_command($id); +} + +// this is a command +function drush_core_batch_process($id) { + drush_batch_command($id); +} + +function drush_core_updatedb_batch_process($id) { + drush_include_engine('drupal', 'update', drush_drupal_major_version()); + _update_batch_command($id); +} Index: commands/core/drupal/update_6.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/core/drupal/update_6.inc,v retrieving revision 1.12 diff -u -r1.12 update_6.inc --- commands/core/drupal/update_6.inc 18 Jan 2010 19:23:46 -0000 1.12 +++ commands/core/drupal/update_6.inc 19 Jan 2010 03:26:07 -0000 @@ -273,9 +273,8 @@ return $ret; } - -function update_main() { - global $profile; +function update_main_prepare() { + global $profile; // Some unavoidable errors happen because the database is not yet up-to-date. // Our custom error handler is not yet installed, so we just suppress them. drush_errors_off(); @@ -335,6 +334,12 @@ _drush_log_update_sql(update_fix_d6_requirements()); _drush_log_update_sql(update_fix_compatibility()); + +} + +function update_main() { + update_main_prepare(); + $start = array(); $has_updates = FALSE; $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE); @@ -421,7 +426,7 @@ batch_set($batch); $batch =& batch_get(); $batch['progressive'] = FALSE; - batch_process(); + drush_backend_batch_process('updatedb-batch-process'); } else { drush_log(dt("No database updates required"), 'success'); @@ -442,6 +447,7 @@ } $function = $module .'_update_'. $number; + drush_log("Executing $function", 'success'); if (function_exists($function)) { $ret = $function($context['sandbox']); @@ -460,3 +466,8 @@ } +function _update_batch_command($id) { + update_main_prepare(); + drush_batch_command($id); +} + Index: commands/core/drupal/update_7.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/core/drupal/update_7.inc,v retrieving revision 1.17 diff -u -r1.17 update_7.inc --- commands/core/drupal/update_7.inc 18 Jan 2010 19:23:46 -0000 1.17 +++ commands/core/drupal/update_7.inc 19 Jan 2010 03:26:08 -0000 @@ -145,7 +145,7 @@ } -function update_main() { +function update_main_prepare() { // Some unavoidable errors happen because the database is not yet up-to-date. // Our custom error handler is not yet installed, so we just suppress them. drush_errors_off(); @@ -216,6 +216,12 @@ } module_list(TRUE, FALSE, TRUE); +} + + + +function update_main() { + update_main_prepare(); $pending = update_get_update_list(); @@ -249,6 +255,10 @@ } +function _update_batch_command($id) { + update_main_prepare(); + drush_batch_command($id); +} /** * Start the database update batch process. @@ -285,7 +295,6 @@ } $batch =& batch_get(); $batch['operations'] = $operations; - $batch['progressive'] = FALSE; $batch += array( 'title' => 'Updating', 'init_message' => 'Starting updates', @@ -294,48 +303,11 @@ 'file' => 'includes/update.inc', ); batch_set($batch); - batch_process(NULL, NULL, NULL); + drush_backend_batch_process('updatedb-batch-process'); } -/** - * A simplified version of the batch_do_one function from update.php - * - * This does not mess with sessions and the like, as it will be used - * from the command line - */ -function _update_do_one($module, $number, &$context) { - // If updates for this module have been aborted - // in a previous step, go no further. - if (!empty($context['results'][$module]['#abort'])) { - return; - } - - try { - $function = $module .'_update_'. $number; - if (function_exists($function)) { - drush_log("Running $function"); - $ret = $function($context['sandbox']); - $context['results'][$module] = $ret; - } - _drush_log_update_sql($ret); - } - catch (Exception $e) { - drush_log(var_dump($e, TRUE)); - } - - if (isset($ret['#finished'])) { - $context['finished'] = $ret['#finished']; - unset($ret['#finished']); - } - - if ($context['finished'] == 1 && empty($context['results'][$module]['#abort'])) { - drupal_set_installed_schema_version($module, $number); - } -} - - function drush_update_finished($success, $results, $operations) { // Clear the caches in case the data has been updated. drupal_flush_all_caches(); Index: includes/drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/drush.inc,v retrieving revision 1.77 diff -u -r1.77 drush.inc --- includes/drush.inc 15 Jan 2010 00:44:59 -0000 1.77 +++ includes/drush.inc 19 Jan 2010 03:26:10 -0000 @@ -1396,3 +1396,22 @@ /** * @} End of "defgroup errorhandling". */ + + /** + * Get the PHP memory_limit value in bytes. + */ +function drush_memory_limit() { + $value = trim(ini_get('memory_limit')); + $last = strtolower($value[strlen($value)-1]); + switch ($last) { + case 'g': + $value *= 1024; + case 'm': + $value *= 1024; + case 'k': + $value *= 1024; + } + + return $value; +} +