From cce7c00011cf5e55f4d10bd05ef8d71b32f1f68d Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Fri, 14 Jan 2011 16:39:11 +0000 Subject: [PATCH] [gh-74] Merging from testing into staging git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@431 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- sites/all/modules/unl/unl_site_creation.php | 47 +++++++-------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/sites/all/modules/unl/unl_site_creation.php b/sites/all/modules/unl/unl_site_creation.php index b8169cef..ea72be0c 100644 --- a/sites/all/modules/unl/unl_site_creation.php +++ b/sites/all/modules/unl/unl_site_creation.php @@ -164,15 +164,9 @@ function unl_site_updates($form, &$form_state) { '#description' => 'Using drush, do database updates and clear the caches of all sites.', ); - if ($form_state['rebuild']) { - $button_text = 'Continue Drush'; - } - else { - $button_text = 'Run Drush'; - } $form['root']['submit'] = array( '#type' => 'submit', - '#value' => $button_text, + '#value' => 'Run Drush', ); return $form; @@ -184,33 +178,24 @@ function unl_site_updates_submit($form, &$form_state) { ->execute() ->fetchAll(); - $start_time = time(); - if (isset($form_state['storage'])) { - $completed_sites = $form_state['storage']; - } - else { - $completed_sites = array(); - } + $operations = array(); foreach ($sites as $site) { - if (in_array($site->uri, $completed_sites)) { - continue; - } - - if (time() - $start_time > 30) { - $form_state['rebuild'] = TRUE; - $form_state['storage'] = $completed_sites; - drupal_set_message('Drush ran out of time to process every site. Click "Continue Drush" below.', 'warning'); - return; - } - - $uri = escapeshellarg($site->uri); - $root = escapeshellarg(DRUPAL_ROOT); - $command = "sites/all/modules/drush/drush.php -y --token=secret --root={$root} --uri={$uri} updatedb"; - drupal_set_message('Messages from ' . $site->uri . ':<br />' . PHP_EOL . '<pre>' . shell_exec($command) . '</pre>', 'status'); - - $completed_sites[] = $site->uri; + $operations[] = array('unl_site_updates_step', array($site->uri)); } + + $batch = array( + 'operations' => $operations, + 'file' => substr(__FILE__, strlen(DRUPAL_ROOT) + 1), + ); + batch_set($batch); +} + +function unl_site_updates_step($site_uri, &$context) { + $uri = escapeshellarg($site_uri); + $root = escapeshellarg(DRUPAL_ROOT); + $command = "sites/all/modules/drush/drush.php -y --token=secret --root={$root} --uri={$uri} updatedb"; + drupal_set_message('Messages from ' . $site_uri . ':<br />' . PHP_EOL . '<pre>' . shell_exec($command) . '</pre>', 'status'); } -- GitLab