Skip to content

Commit

Permalink
#1058874 by Xen and greg.1.anderson: show progress in backend invoke …
Browse files Browse the repository at this point in the history
…by displaying incremental output as it becomes available.
  • Loading branch information
greg-1-anderson committed Jun 9, 2011
1 parent f866d25 commit 510735a
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 276 deletions.
17 changes: 9 additions & 8 deletions commands/core/upgrade.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ function drush_upgrade_site_upgrade($target_key) {
}

// Get a list of enabled contrib extensions.
$values = drush_invoke_process_args('pm-list', array(), array('status'=>'enabled','no-core'=>TRUE, '#integrate' => FALSE, '#override-simulated' => TRUE));
$values = drush_invoke_process_args('pm-list', array(), array('status'=>'enabled','no-core'=>TRUE), array('integrate' => FALSE, 'override-simulated' => TRUE));
if ($values['error_status'] != 0) return FALSE;
$contrib_extensions = array_keys($values['object']);

// Get a list of enabled core extensions.
$values = drush_invoke_process_args('pm-list', array(), array('status'=>'enabled','core'=>TRUE, '#integrate' => FALSE, '#override-simulated' => TRUE));
$values = drush_invoke_process_args('pm-list', array(), array('status'=>'enabled','core'=>TRUE), array('integrate' => FALSE, 'override-simulated' => TRUE));
if ($values['error_status'] != 0) return FALSE;
$core_extensions = array_keys($values['object']);

Expand Down Expand Up @@ -188,7 +188,7 @@ function drush_upgrade_site_upgrade($target_key) {
// we are not ready to upgrade (but still can, without that project); if there is no RECOMMENDED
// release, then we might not be ready to upgrade (but still can, with a non-recommended release).
if (!empty($project_download_list)) {
$result = drush_invoke_sitealias_args(array('root' => '', 'uri' => ''), 'pm-releases', array_keys($project_download_list), array('default-major' => $target_version, '#integrate' => FALSE, '#override-simulated' => TRUE));
$result = drush_invoke_sitealias_args(array('root' => '', 'uri' => ''), 'pm-releases', array_keys($project_download_list), array('default-major' => $target_version), array('integrate' => FALSE, 'override-simulated' => TRUE));
$project_releases = $result['object'];
foreach ($project_download_list as $project => $extension_list) {
if (!array_key_exists($project, $project_releases)) {
Expand Down Expand Up @@ -312,7 +312,7 @@ function drush_upgrade_site_upgrade($target_key) {
}
}
}
$result = (drush_invoke_sitealias_args($modify_site, 'site-upgrade-prepare', $contrib_extensions, array('uninstall' => implode(',', $uninstall_extensions), 'yes' => TRUE, '#interactive' => TRUE)) == 0);
$result = (drush_invoke_sitealias_args($modify_site, 'site-upgrade-prepare', $contrib_extensions, array('uninstall' => implode(',', $uninstall_extensions), 'yes' => TRUE), array('interactive' => TRUE)) == 0);

// Delete the temporary site now that we're done with it.
if (isset($modify_site_conf_path)) {
Expand All @@ -326,7 +326,7 @@ function drush_upgrade_site_upgrade($target_key) {
// Run update.php in a subshell. It is run on @target site whereas this request was on @self.
drush_log(dt('About to perform updatedb for Drupal core on !target', array('!target' => $target_key)), 'ok');
// When we call drush_invoke_sitealias_args in #interactive mode, the result code comes from drush_op_system, where 0 == success.
$result = drush_invoke_sitealias_args($target_alias, 'updatedb', array(), array('yes' => TRUE, '#interactive' => TRUE)) == 0;
$result = drush_invoke_sitealias_args($target_alias, 'updatedb', array(), array('yes' => TRUE), array('interactive' => TRUE)) == 0;
if ($result === FALSE) {
return drush_set_error('DRUSH_DRUPAL_CORE_UPGRADE_FAILED', dt("The call to updatedb failed for Drupal core. This may be caused by a contrib module that is not yet ready for upgrade. Try running site-upgrade again with '--uninstall={module list}' to remove all contrib extensions prior to upgrade. Add modules back in until the problematic one is isolated. Please report problems in the issue queue of the module that is causing problems."));
}
Expand All @@ -338,7 +338,8 @@ function drush_upgrade_site_upgrade($target_key) {
// STEP 3: Download and re-enable the contrib modules.

if (!empty($contrib_extensions) && !drush_get_option('core-only')) {
$options = array('#interactive' => TRUE);
$options = array();
$backend_options = array('interactive' => TRUE);
if (!empty($project_download_list)) {
$projects = implode(',', array_keys($project_download_list));
$options['projects'] = $projects;
Expand All @@ -353,7 +354,7 @@ function drush_upgrade_site_upgrade($target_key) {

// Redispatch to site-upgrade-modules command, so that we will be
// bootstrapped to the target site.
$result = (drush_invoke_sitealias_args($target_alias, 'site-upgrade-modules', array_merge($core_extensions, array_diff($contrib_extensions, $unavailable_extensions, $uninstall_extensions)), $options) == 0);
$result = (drush_invoke_sitealias_args($target_alias, 'site-upgrade-modules', array_merge($core_extensions, array_diff($contrib_extensions, $unavailable_extensions, $uninstall_extensions)), $options, $backend_options) == 0);
}

return $result;
Expand Down Expand Up @@ -542,7 +543,7 @@ function drush_upgrade_site_upgrade_modules() {

// Run updatedb to update all of the contrib extensions.
drush_log(dt('About to perform updatedb for extensions'), 'ok');
$result = drush_invoke_process_args('updatedb', array(), array('yes' => TRUE, '#interactive' => TRUE));
$result = drush_invoke_process_args('updatedb', array(), array('yes' => TRUE), array('interactive' => TRUE));
if ($result === FALSE) {
return drush_set_error('DRUSH_DRUPAL_CONTRIB_UPGRADE_FAILED', dt("The call to updatedb failed for the enabled contrib modules. Try running site-upgrade again with '--uninstall={module list}' to remove all contrib extensions prior to upgrade. Add modules back in until the problematic one is isolated. Please report problems in the issue queue of the module that is causing problems."));
}
Expand Down
13 changes: 6 additions & 7 deletions drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,15 @@ function drush_shutdown() {
}
}

if (drush_get_context('DRUSH_BACKEND')) {
if (drush_get_context('DRUSH_BACKEND', FALSE)) {
drush_backend_output();
}
elseif (drush_get_context('DRUSH_QUIET')) {
elseif (drush_get_context('DRUSH_QUIET', FALSE)) {
ob_end_clean();
}

// If we are in pipe mode, emit the compact representation of the command, if available.
if (drush_get_context('DRUSH_PIPE')) {
drush_pipe_output();
// If we are in pipe mode, emit the compact representation of the command, if available.
if (drush_get_context('DRUSH_PIPE')) {
drush_pipe_output();
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion examples/example.aliases.drushrc.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
* Relative aliases are always taken from the Drupal root.
* '%drush-script': The path to the 'drush' script, or to 'drush.php' or
* 'drush.bat', as desired. This is used by backend invoke when drush
* runs a drush command. The default is 'drush' on remote machines, or
* runs a drush command. The default is 'drush' on remote machines, or
* the full path to drush.php on the local machine.
* '%drush': A read-only property: points to the folder that the drush script
* is stored in.
Expand All @@ -156,6 +156,9 @@
* '%files': Path to 'files' directory. This will be looked up if not specified.
* '%root': A reference to the Drupal root defined in the 'root' item
* in the site alias record.
* - 'php': path to custom php interpreter, defaults to /usr/bin/php
* - 'php-options': commandline options for php interpreter, you may
* want to set this to '-d error_reporting="E_ALL^E_DEPRECATED"'
* - 'command-specific': These options will only be set if the alias
* is used with the specified command. In the example below, the option
* `--no-cache` will be selected whenever the @stage alias
Expand Down
Loading

0 comments on commit 510735a

Please sign in to comment.