Skip to content

Commit

Permalink
Merge pull request #633 from pantheon-systems/fix_mass-update
Browse files Browse the repository at this point in the history
sites mass-update now differentiates between SFTP-mode and updated sites
  • Loading branch information
TeslaDethray committed Oct 27, 2015
2 parents 191821b + 5cdaf18 commit e71c314
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 268 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project starting with the 0.6.0 release will be docu
##MASTER
### Fixed
- `site backups get` will now find and retrieve backups properly. (#632)
- `sites mass-update` now differentiates between an updated site and one in SFTP mode and warns user appropriately. (#633)

##[0.9.0] - 2015-10-22
### Added
Expand Down
22 changes: 15 additions & 7 deletions php/commands/sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,10 @@ public function mass_update($args, $assoc_args) {
$this->sites->rebuildCache();
$sites = $this->sites->all();

$env = 'dev';
$upstream = Input::optional('upstream', $assoc_args, false);
$data = array();
$report = Input::optional('report', $assoc_args, false);
$confirm = Input::optional('confirm', $assoc_args, false);
$data = array();
$report = Input::optional('report', $assoc_args, false);
$confirm = Input::optional('confirm', $assoc_args, false);

// Start status messages.
if($upstream) $this->log()->info('Looking for sites using '.$upstream.'.');
Expand All @@ -321,21 +320,30 @@ public function mass_update($args, $assoc_args) {

if( $updates->behind > 0 ) {
$data[$site->get('name')] = array('site'=> $site->get('name'), 'status' => "Needs update");
$env = $site->environments->get('dev');
if ($env->getConnectionMode() == 'sftp') {
$this->log()->warning(
'{site} has available updates, but is in SFTP mode. Switch to Git mode to apply updates.',
array('site' => $site->get('name'))
);
$data[$site->get('name')] = array('site'=> $site->get('name'), 'status' => "Needs update - switch to Git mode");
continue;
}
$updatedb = !Input::optional($assoc_args, 'updatedb', false);
$xoption = Input::optional($assoc_args, 'xoption', 'theirs');
if (!$report) {
$confirmed = Input::yesno("Apply upstream updates to %s ( run update.php:%s, xoption:%s ) ", array($site->get('name'), var_export($update,1), var_export($xoption,1)));
$confirmed = Input::yesno("Apply upstream updates to %s ( run update.php:%s, xoption:%s ) ", array($site->get('name'), var_export($updatedb,1), var_export($xoption,1)));
if(!$confirmed) continue; // User says No, go back to start.

// Backup the DB so the client can restore if something goes wrong.
$this->log()->info('Backing up '.$site->get('name').'.');
$backup = $site->environments->get('dev')->createBackup(array('element'=>'all'));
$backup = $env->createBackup(array('element'=>'all'));
// Only continue if the backup was successful.
if($backup) {
$this->log()->info("Backup of ".$site->get('name')." created.");
$this->log()->info('Updating '.$site->get('name').'.');
// Apply the update, failure here would trigger a guzzle exception so no need to validate success.
$response = $site->applyUpstreamUpdates($env, $updatedb, $xoption);
$response = $site->applyUpstreamUpdates($env->get('id'), $updatedb, $xoption);
$data[$site->get('name')]['status'] = 'Updated';
$this->log()->info($site->get('name').' is updated.');
} else {
Expand Down
Loading

0 comments on commit e71c314

Please sign in to comment.