ExtensionsUpgrade.php 1.12 KB
Newer Older
totten's avatar
totten committed
1 2 3 4 5 6 7 8 9 10 11 12
<?php

require_once 'CRM/Core/Page.php';

/**
 * Display a page which displays a progress bar while executing
 * upgrade tasks.
 */
class CRM_Admin_Page_ExtensionsUpgrade extends CRM_Core_Page {
  const END_URL = 'civicrm/admin/extensions';
  const END_PARAMS = 'reset=1';

eileen's avatar
eileen committed
13 14 15
  /**
   * Run Page.
   */
16
  public function run() {
totten's avatar
totten committed
17
    $queue = CRM_Extension_Upgrades::createQueue();
18
    $runner = new CRM_Queue_Runner([
totten's avatar
totten committed
19 20
      'title' => ts('Database Upgrades'),
      'queue' => $queue,
totten's avatar
totten committed
21
      'errorMode' => CRM_Queue_Runner::ERROR_ABORT,
22
      'onEnd' => ['CRM_Admin_Page_ExtensionsUpgrade', 'onEnd'],
23
      'onEndUrl' => !empty($_GET['destination']) ? $_GET['destination'] : CRM_Utils_System::url(self::END_URL, self::END_PARAMS),
24
    ]);
totten's avatar
totten committed
25 26

    CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Start upgrades');
27 28
    // does not return
    $runner->runAllViaWeb();
totten's avatar
totten committed
29 30 31
  }

  /**
32
   * Handle the final step of the queue.
Eileen McNaughton's avatar
Eileen McNaughton committed
33 34
   *
   * @param \CRM_Queue_TaskContext $ctx
totten's avatar
totten committed
35
   */
36
  public static function onEnd(CRM_Queue_TaskContext $ctx) {
totten's avatar
totten committed
37 38
    CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Finish upgrades');
  }
39

totten's avatar
totten committed
40
}