commit 79394224c86acc7bfbdd6be854942d9fbd163226 Author: Joel Pittet Date: Sun Feb 8 19:15:32 2015 -0800 batch on handler diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 384eeb0..be2219f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -421,7 +421,7 @@ function system_authorized_init($callback, $file, $arguments = array(), $page_ti * @see system_authorized_init() */ function system_authorized_get_url(array $options = array()) { - // Prefix with $base_url so url() treats it as an external link. + // Prefix with 'base:' so Url treats it as an external link. $url = Url::fromUri('base:core/authorize.php'); $url_options = $url->getOptions(); $url->setOptions($options + $url_options); @@ -439,6 +439,17 @@ function system_authorized_run($callback, $file, $arguments = array(), $page_tit } /** + * Use authorize.php to run batch_process(). + * + * @see batch_process() + */ +function system_authorized_batch($batch) { + $batch['url'] = system_authorized_get_url(['query' => ['batch' => '1']]); + $batch['batch_redirect'] = system_authorized_get_url()->toString(); + return $batch; +} + +/** * @} End of "defgroup authorize". */ diff --git a/core/modules/update/src/Form/UpdateManagerInstall.php b/core/modules/update/src/Form/UpdateManagerInstall.php index 4c0764b..081ee26 100644 --- a/core/modules/update/src/Form/UpdateManagerInstall.php +++ b/core/modules/update/src/Form/UpdateManagerInstall.php @@ -219,7 +219,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if (fileowner($project_real_location) == fileowner(conf_path())) { $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize'); $filetransfer = new Local($this->root); - call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments)); + $batch = call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments)); + batch_set($batch); } // Otherwise, go through the regular workflow to prompt for FTP/SSH @@ -227,8 +228,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // whatever FileTransfer object authorize.php creates for us. else { system_authorized_init('update_authorize_run_install', drupal_get_path('module', 'update') . '/update.authorize.inc', $arguments, $this->t('Update manager')); + $form_state->setRedirectUrl(system_authorized_get_url()); } - $form_state->setRedirectUrl(system_authorized_get_url()); } } diff --git a/core/modules/update/src/Form/UpdateReady.php b/core/modules/update/src/Form/UpdateReady.php index 4401d61..d1396c9 100644 --- a/core/modules/update/src/Form/UpdateReady.php +++ b/core/modules/update/src/Form/UpdateReady.php @@ -145,15 +145,16 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if (fileowner($project_real_location) == fileowner(conf_path())) { $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize'); $filetransfer = new Local($this->root); - update_authorize_run_update($filetransfer, $updates); + $batch = update_authorize_run_update($filetransfer, $updates); + batch_set($batch); } // Otherwise, go through the regular workflow to prompt for FTP/SSH // credentials and invoke update_authorize_run_update() indirectly with // whatever FileTransfer object authorize.php creates for us. else { system_authorized_init('update_authorize_run_update', drupal_get_path('module', 'update') . '/update.authorize.inc', array($updates), $this->t('Update manager')); + $form_state->setRedirectUrl(system_authorized_get_url()); } - $form_state->setRedirectUrl(system_authorized_get_url()); } } diff --git a/core/modules/update/update.authorize.inc b/core/modules/update/update.authorize.inc index 7493f81..dadcd7e 100644 --- a/core/modules/update/update.authorize.inc +++ b/core/modules/update/update.authorize.inc @@ -49,11 +49,10 @@ function update_authorize_run_update($filetransfer, $projects) { 'operations' => $operations, 'finished' => 'update_authorize_update_batch_finished', 'file' => drupal_get_path('module', 'update') . '/update.authorize.inc', - 'url' => system_authorized_get_url(['query' => ['batch' => '1']]), ); - - // Batch will be executed via authorize.php. - batch_set($batch); + // Batch will be excuted via authorized.php. + $batch = system_authorized_batch($batch); + return $batch; } /** @@ -94,11 +93,10 @@ function update_authorize_run_install($filetransfer, $project, $updater_name, $l // @todo Use a different finished callback for different messages? 'finished' => 'update_authorize_install_batch_finished', 'file' => drupal_get_path('module', 'update') . '/update.authorize.inc', - 'url' => system_authorized_get_url(['query' => ['batch' => '1']]), ); - // Batch will be excuted via authorized.php. - batch_set($batch); + $batch = system_authorized_batch($batch); + return $batch; } /**