Same name and namespace in other branches
  1. 7.x modules/update/update.authorize.inc \update_authorize_install_batch_finished()
  2. 8.9.x core/modules/update/update.authorize.inc \update_authorize_install_batch_finished()
  3. 9 core/modules/update/update.authorize.inc \update_authorize_install_batch_finished()

Implements callback_batch_finished().

Performs actions when the authorized install batch is done.

This processes the results and stashes them into SESSION such that authorize.php will render a report. Also responsible for putting the site back online after a successful install if necessary.

Parameters

$success: TRUE if the batch operation was a success; FALSE if there were errors.

$results: An associative array of results from the batch operation.

1 string reference to 'update_authorize_install_batch_finished'
update_authorize_run_install in core/modules/update/update.authorize.inc
Installs a new project when invoked by authorize.php.

File

core/modules/update/update.authorize.inc, line 285
Callbacks and related functions invoked by authorize.php to update projects.

Code

function update_authorize_install_batch_finished($success, $results) {
  foreach ($results['log'] as $messages) {
    if (!empty($messages['#abort'])) {
      $success = FALSE;
    }
  }
  $offline = \Drupal::state()
    ->get('system.maintenance_mode');
  $session = \Drupal::request()
    ->getSession();

  // Unset the variable since it is no longer needed.
  $maintenance_mode = $session
    ->remove('maintenance_mode');
  if ($success) {

    // Take the site out of maintenance mode if it was previously that way.
    if ($offline && $maintenance_mode === FALSE) {
      \Drupal::state()
        ->set('system.maintenance_mode', FALSE);
      $page_message = [
        'message' => t('Files were added successfully. Your site has been taken out of maintenance mode.'),
        'type' => 'status',
      ];
    }
    else {
      $page_message = [
        'message' => t('Files were added successfully.'),
        'type' => 'status',
      ];
    }
  }
  elseif (!$success && !$offline) {
    $page_message = [
      'message' => t('File add failed! See the log below for more information.'),
      'type' => 'error',
    ];
  }
  else {
    $page_message = [
      'message' => t('File add failed! See the log below for more information. Your site is still in maintenance mode.'),
      'type' => 'error',
    ];
  }

  // Set all these values into the SESSION so authorize.php can display them.
  $session
    ->set('authorize_results', [
    'success' => $success,
    'page_message' => $page_message,
    'messages' => $results['log'],
    'tasks' => $results['tasks'],
  ]);
  $session
    ->set('authorize_page_title', t('Update manager'));
}