From: Frank J. Gómez Date: Tue, 17 Jun 2014 16:47:57 +0000 (-0400) Subject: CRM-14871: Supply api call extension.upgrade for admins who manage extensions outside... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9a477d10394ae822eec3cf684fffb52d09376d43;p=civicrm-core.git CRM-14871: Supply api call extension.upgrade for admins who manage extensions outside of CiviCRM (e.g., manual download). --- diff --git a/api/v3/Extension.php b/api/v3/Extension.php index 2e9d56857f..8ea07d1a6d 100644 --- a/api/v3/Extension.php +++ b/api/v3/Extension.php @@ -68,6 +68,36 @@ function civicrm_api3_extension_install($params) { return civicrm_api3_create_success(); } +/** + * Upgrade an extension - runs upgrade_N hooks and system.flush + * + * @return array API result + * @static void + * @access public + * + */ +function civicrm_api3_extension_upgrade() { + CRM_Core_Invoke::rebuildMenuAndCaches(TRUE); + $queue = CRM_Extension_Upgrades::createQueue(); + $runner = new CRM_Queue_Runner(array( + 'title' => 'Extension Upgrades', + 'queue' => $queue, + 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, + )); + + try { + $result = $runner->runAll(); + } catch (CRM_Extension_Exception $e) { + return civicrm_api3_create_error($e->getMessage()); + } + + if ($result === TRUE) { + return civicrm_api3_create_success(); + } else { + return $result; + } +} + /** * Enable an extension *