| 1 | <?php |
| 2 | |
| 3 | require_once 'CRM/Core/Page.php'; |
| 4 | |
| 5 | /** |
| 6 | * Display a page which displays a progress bar while executing |
| 7 | * upgrade tasks. |
| 8 | */ |
| 9 | class CRM_Admin_Page_ExtensionsUpgrade extends CRM_Core_Page { |
| 10 | const END_URL = 'civicrm/admin/extensions'; |
| 11 | const END_PARAMS = 'reset=1'; |
| 12 | |
| 13 | public function run() { |
| 14 | $queue = CRM_Extension_Upgrades::createQueue(); |
| 15 | $runner = new CRM_Queue_Runner(array( |
| 16 | 'title' => ts('Database Upgrades'), |
| 17 | 'queue' => $queue, |
| 18 | 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, |
| 19 | 'onEnd' => array('CRM_Admin_Page_ExtensionsUpgrade', 'onEnd'), |
| 20 | 'onEndUrl' => CRM_Utils_System::url(self::END_URL, self::END_PARAMS), |
| 21 | )); |
| 22 | |
| 23 | CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Start upgrades'); |
| 24 | $runner->runAllViaWeb(); // does not return |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Handle the final step of the queue. |
| 29 | * |
| 30 | * @param \CRM_Queue_TaskContext $ctx |
| 31 | */ |
| 32 | public static function onEnd(CRM_Queue_TaskContext $ctx) { |
| 33 | CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Finish upgrades'); |
| 34 | } |
| 35 | |
| 36 | } |