3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Perform an upgrade without using the web-frontend
31 class CRM_Upgrade_Headless
{
34 * Perform an upgrade without using the web-frontend
36 * @param bool $enablePrint
40 * @return array, with keys:
41 * - message: string, HTML-ish blob
43 function run($enablePrint = TRUE) {
44 // lets get around the time limit issue if possible for upgrades
45 if (!ini_get('safe_mode')) {
49 $upgrade = new CRM_Upgrade_Form();
50 list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
52 if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
53 throw new Exception($error);
56 // Disable our SQL triggers
57 CRM_Core_DAO
::dropTriggers();
60 $preUpgradeMessage = NULL;
61 $upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
63 $postUpgradeMessageFile = CRM_Utils_File
::tempnam('civicrm-post-upgrade');
64 $queueRunner = new CRM_Queue_Runner(array(
65 'title' => ts('CiviCRM Upgrade Tasks'),
66 'queue' => CRM_Upgrade_Form
::buildQueue($currentVer, $latestVer, $postUpgradeMessageFile),
68 $queueResult = $queueRunner->runAll();
69 if ($queueResult !== TRUE) {
70 $errorMessage = CRM_Core_Error
::formatTextException($queueResult['exception']);
71 CRM_Core_Error
::debug_log_message($errorMessage);
75 throw $queueResult['exception']; // FIXME test
78 CRM_Upgrade_Form
::doFinish();
81 'latestVer' => $latestVer,
82 'message' => file_get_contents($postUpgradeMessageFile),