? .patch ? drush.kpf ? tmp.patch ? tmp.patch.patch ? updatedb.patch ? includes/table.inc 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.16 diff -u -F '^f' -p -r1.16 update_7.inc --- commands/core/drupal/update_7.inc 23 Dec 2009 15:46:15 -0000 1.16 +++ commands/core/drupal/update_7.inc 18 Jan 2010 01:02:38 -0000 @@ -53,6 +53,18 @@ function drush_update_do_one($module, $n return; } + // Check for closeness to memory limit + $usage = memory_get_usage(); + $memory_limit = drush_memory_limit(); + $pct_memory = ($usage/$memory_limit) * 100; + if ($pct_memory > drush_get_option('memory_threshold', 50)) { + // Low on memory. Spawn a subshell. + drush_do_command_redispatch('updatedb'); + // TODO: Mark batch as finished + return; + } + + // Drupal's update.php does not log queries anymore. $context['log'] = FALSE; $ret = array(); @@ -82,7 +94,7 @@ function drush_update_do_one($module, $n if ($context['log']) { $ret['queries'] = Database::getLog($function); -# _drush_log_update_sql($ret); + _drush_log_update_sql($ret); } } @@ -125,7 +137,7 @@ function drush_update_do_one($module, $n */ function update_check_requirements() { $warnings = FALSE; - + // Check the system module and update.php requirements only. $requirements = system_requirements('update'); $requirements += update_extra_requirements(); @@ -185,17 +197,17 @@ function update_main() { // Check the update requirements for Drupal. update_check_requirements(); - // update_fix_d7_requirements() needs to run before bootstrapping beyond path. + // update_fix_d7_requirements() needs to run before bootstrapping beyond path. // So bootstrap to DRUPAL_BOOTSTRAP_LANGUAGE then include unicode.inc. drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE); - + update_fix_d7_requirements(); - + // Now proceed with a full bootstrap. - + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_maintenance_theme(); - + drush_errors_on(); include_once DRUPAL_ROOT . '/includes/batch.inc'; @@ -336,4 +348,3 @@ function drush_update_finished($success, drupal_flush_all_caches(); variable_set('site_offline', FALSE); } - Index: includes/drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/drush.inc,v retrieving revision 1.77 diff -u -F '^f' -p -r1.77 drush.inc --- includes/drush.inc 15 Jan 2010 00:44:59 -0000 1.77 +++ includes/drush.inc 18 Jan 2010 01:02:38 -0000 @@ -767,27 +767,27 @@ function drush_remote_command() { $site_list = explode(',', $site_list); } $args = drush_get_arguments(); - + if (!drush_get_context('DRUSH_SIMULATE')) { drush_print(dt('You are about to use the experimental MULTIPLE-TARGET drush command feature.')); drush_print(dt('This code is new; please be careful (make backups), and use at your own risk!')); - + drush_print(dt("You are about to execute '!command' on all of the following targets:", array('!command' => implode(" ", $args)))); foreach ($site_list as $one_destination) { drush_print(dt(' !target', array('!target' => $one_destination))); } - + // Temporary: ask what the user wants to do // Once this code works, we'll replace this with a // simple 'drush_confirm', so -y will work. // You must manually confirm every time until this // code is tested. Help out at issue #628996 // if this is annoying to you. - + $options['s'] = 'Run simulation first (add -s flag) WARNING: ignored by some commands!'; $options['g'] = 'Go!'; $choice = drush_choice($options, 'Enter a number to choose which action to take.'); - + if ($choice === FALSE) { drush_die('Aborting.'); } @@ -823,12 +823,12 @@ function drush_remote_command() { */ function drush_do_multiple_command($command, $source_record, $destination_record, $allow_single_source = FALSE) { $is_multiple_command = FALSE; - + if ((($allow_single_source == TRUE) || array_key_exists('site-list', $source_record)) && array_key_exists('site-list', $destination_record)) { $is_multiple_command = TRUE; $source_path = array_key_exists('path-component', $source_record) ? $source_record['path-component'] : ''; $destination_path = array_key_exists('path-component', $destination_record) ? $destination_record['path-component'] : ''; - + $target_list = drush_sitealias_resolve_sitelist($destination_record); if (array_key_exists('site-list', $source_record)) { $source_list = drush_sitealias_resolve_sitelist($source_record); @@ -844,10 +844,10 @@ function drush_do_multiple_command($comm else { $source_list = array_fill(0, count($target_list), $source_record); } - + drush_print($source_path); drush_print($destination_path); - + if (!drush_get_context('DRUSH_SIMULATE')) { drush_print(dt('You are about to use the experimental MULTIPLE-SYNCHRONIZED-TARGET drush !command feature.', array('!command' => $command))); drush_print(dt('This code is new; please be careful (make backups), and use at your own risk!')); @@ -879,22 +879,22 @@ function drush_do_multiple_command($comm drush_set_context('DRUSH_SIMULATE', TRUE); } } - + $data = drush_redispatch_get_options(); $i = 0; foreach ($source_list as $one_source) { $one_target = $target_list[$i]; ++$i; - + $source_spec = drush_sitealias_alias_record_to_spec($one_source); $target_spec = drush_sitealias_alias_record_to_spec($one_target); - + drush_log(dt('Begin do_multiple !command via backend invoke', array('!command' => $command))); $values = drush_backend_invoke_args($command, array($source_spec . $source_path, $target_spec . $destination_path), $data, 'GET', TRUE); drush_log(dt('Backend invoke is complete')); } } - + return $is_multiple_command; } @@ -1243,6 +1243,25 @@ function drush_watchdog_format_message($ } /** + * 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; +} + + +/** * Log the return value of Drupal hook_update_n functions. * * This is used during install and update to log the output