function DbUpdateController::handle

Same name in other branches
  1. 9 core/modules/system/src/Controller/DbUpdateController.php \Drupal\system\Controller\DbUpdateController::handle()
  2. 8.9.x core/modules/system/src/Controller/DbUpdateController.php \Drupal\system\Controller\DbUpdateController::handle()
  3. 11.x core/modules/system/src/Controller/DbUpdateController.php \Drupal\system\Controller\DbUpdateController::handle()

Returns a database update page.

Parameters

string $op: The update operation to perform. Can be any of the below:

  • info
  • selection
  • run
  • results

\Symfony\Component\HttpFoundation\Request $request: The current request object.

Return value

\Symfony\Component\HttpFoundation\Response A response object.

File

core/modules/system/src/Controller/DbUpdateController.php, line 152

Class

DbUpdateController
Controller routines for database update routes.

Namespace

Drupal\system\Controller

Code

public function handle($op, Request $request) {
    require_once $this->root . '/core/includes/install.inc';
    require_once $this->root . '/core/includes/update.inc';
    drupal_load_updates();
    if ($request->query
        ->get('continue')) {
        $request->getSession()
            ->set('update_ignore_warnings', TRUE);
    }
    $regions = [];
    $requirements = update_check_requirements();
    $severity = drupal_requirements_severity($requirements);
    if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING && !$request->getSession()
        ->has('update_ignore_warnings')) {
        $regions['sidebar_first'] = $this->updateTasksList('requirements');
        $output = $this->requirements($severity, $requirements, $request);
    }
    else {
        switch ($op) {
            case 'selection':
                $regions['sidebar_first'] = $this->updateTasksList('selection');
                $output = $this->selection($request);
                break;
            case 'run':
                $regions['sidebar_first'] = $this->updateTasksList('run');
                $output = $this->triggerBatch($request);
                break;
            case 'info':
                $regions['sidebar_first'] = $this->updateTasksList('info');
                $output = $this->info($request);
                break;
            case 'results':
                $regions['sidebar_first'] = $this->updateTasksList('results');
                $output = $this->results($request);
                break;
            // Regular batch ops : defer to batch processing API.
            default:
                require_once $this->root . '/core/includes/batch.inc';
                $regions['sidebar_first'] = $this->updateTasksList('run');
                $output = _batch_page($request);
                break;
        }
    }
    if ($output instanceof Response) {
        return $output;
    }
    $title = $output['#title'] ?? $this->t('Drupal database update');
    return $this->bareHtmlPageRenderer
        ->renderBarePage($output, $title, 'maintenance_page', $regions);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.