2010-12-16 20:36:29 +00:00
|
|
|
<?php
|
2011-01-22 12:20:08 +00:00
|
|
|
/**
|
2011-01-27 15:04:37 +00:00
|
|
|
* cliUpgrade.php
|
|
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
|
|
|
|
* Copyright (C) 2011 Colosa Inc.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
|
|
|
*
|
|
|
|
|
* @author Alexandre Rosenfeld <alexandre@colosa.com>
|
2011-01-22 12:20:08 +00:00
|
|
|
* @package workflow-engine-bin-tasks
|
2011-01-28 14:16:58 +00:00
|
|
|
*/
|
2010-12-16 20:36:29 +00:00
|
|
|
|
|
|
|
|
G::LoadClass("system");
|
|
|
|
|
G::LoadClass("wsTools");
|
|
|
|
|
|
2011-01-27 15:04:37 +00:00
|
|
|
CLI::taskName('upgrade');
|
|
|
|
|
CLI::taskDescription(<<<EOT
|
2012-09-26 10:15:20 -04:00
|
|
|
Upgrade workspaces.
|
2011-01-27 15:04:37 +00:00
|
|
|
|
2012-09-26 10:15:20 -04:00
|
|
|
This command should be run after ProcessMaker files are upgraded so that all
|
|
|
|
|
workspaces are upgraded to the current version.
|
2011-01-27 15:04:37 +00:00
|
|
|
EOT
|
|
|
|
|
);
|
2012-09-26 14:37:43 -04:00
|
|
|
CLI::taskOpt("buildACV", "If the option is enabled, performs the Build Cache View.", "ACV", "buildACV");
|
2011-01-27 15:04:37 +00:00
|
|
|
CLI::taskRun(run_upgrade);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-02-21 15:35:50 +00:00
|
|
|
* A version of rm_dir which does not exits on error.
|
2011-01-27 15:04:37 +00:00
|
|
|
*
|
|
|
|
|
* @param string $filename directory or file to remove
|
|
|
|
|
* @param bool $filesOnly either to remove the containing directory as well or not
|
|
|
|
|
*/
|
2012-09-26 10:15:20 -04:00
|
|
|
function rm_dir($filename, $filesOnly = false)
|
|
|
|
|
{
|
|
|
|
|
if (is_file($filename)) {
|
|
|
|
|
@unlink($filename) or CLI::logging(CLI::error("Could not remove file $filename")."\n");
|
|
|
|
|
} else {
|
|
|
|
|
foreach (glob("$filename/*") as $f) {
|
|
|
|
|
rm_dir($f);
|
|
|
|
|
}
|
|
|
|
|
if (!$filesOnly) {
|
|
|
|
|
@rmdir($filename) or CLI::logging(CLI::error("Could not remove directory $filename")."\n");
|
|
|
|
|
}
|
2011-01-27 15:04:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-12-16 20:36:29 +00:00
|
|
|
|
2012-09-26 10:15:20 -04:00
|
|
|
function run_upgrade($command, $args)
|
|
|
|
|
{
|
|
|
|
|
CLI::logging("UPGRADE", PROCESSMAKER_PATH . "upgrade.log");
|
|
|
|
|
CLI::logging("Checking files integrity...\n");
|
2012-10-16 10:17:25 -04:00
|
|
|
//setting flag to true to check into sysGeneric.php
|
|
|
|
|
$flag = G::isPMUnderUpdating(1);
|
|
|
|
|
//start to upgrade
|
2012-09-26 10:15:20 -04:00
|
|
|
$checksum = System::verifyChecksum();
|
|
|
|
|
if ($checksum === false) {
|
|
|
|
|
CLI::logging(CLI::error("checksum.txt not found, integrity check is not possible") . "\n");
|
|
|
|
|
if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) {
|
|
|
|
|
CLI::logging("Upgrade failed\n");
|
2013-01-18 16:10:12 -04:00
|
|
|
$flag = G::isPMUnderUpdating(0);
|
2012-09-26 10:15:20 -04:00
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!empty($checksum['missing'])) {
|
|
|
|
|
CLI::logging(CLI::error("The following files were not found in the installation:")."\n");
|
|
|
|
|
foreach ($checksum['missing'] as $missing) {
|
|
|
|
|
CLI::logging(" $missing\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!empty($checksum['diff'])) {
|
|
|
|
|
CLI::logging(CLI::error("The following files have modifications:")."\n");
|
|
|
|
|
foreach ($checksum['diff'] as $diff) {
|
|
|
|
|
CLI::logging(" $diff\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!(empty($checksum['missing']) || empty($checksum['diff']))) {
|
|
|
|
|
if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) {
|
|
|
|
|
CLI::logging("Upgrade failed\n");
|
2013-01-18 16:10:12 -04:00
|
|
|
$flag = G::isPMUnderUpdating(0);
|
2012-09-26 10:15:20 -04:00
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-20 15:26:23 +00:00
|
|
|
}
|
2012-09-26 10:15:20 -04:00
|
|
|
CLI::logging("Clearing cache...\n");
|
|
|
|
|
if (defined('PATH_C')) {
|
2012-12-05 15:17:57 -04:00
|
|
|
G::rm_dir(PATH_C);
|
2013-01-29 11:51:34 -04:00
|
|
|
G::mk_dir(PATH_C, 0777);
|
2010-12-16 20:36:29 +00:00
|
|
|
}
|
2012-10-05 16:58:26 -04:00
|
|
|
$workspaces = get_workspaces_from_args($command);
|
2012-09-26 10:15:20 -04:00
|
|
|
$count = count($workspaces);
|
|
|
|
|
$first = true;
|
|
|
|
|
$errors = false;
|
2013-01-24 14:19:25 -04:00
|
|
|
$countWorkspace = 1;
|
2012-10-05 16:58:26 -04:00
|
|
|
$buildCacheView = array_key_exists("buildACV", $args);
|
2012-09-26 10:15:20 -04:00
|
|
|
foreach ($workspaces as $index => $workspace) {
|
|
|
|
|
try {
|
2013-01-24 14:19:25 -04:00
|
|
|
$countWorkspace = $countWorkspace + $index;
|
|
|
|
|
CLI::logging("Upgrading workspaces ($countWorkspace/$count): " . CLI::info($workspace->name) . "\n");
|
2012-10-05 16:58:26 -04:00
|
|
|
$workspace->upgrade($first, $buildCacheView, $workspace->name);
|
2012-09-26 10:15:20 -04:00
|
|
|
$workspace->close();
|
|
|
|
|
$first = false;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n");
|
|
|
|
|
$errors = true;
|
|
|
|
|
}
|
2010-12-16 20:36:29 +00:00
|
|
|
}
|
2012-09-26 10:15:20 -04:00
|
|
|
if ($errors) {
|
|
|
|
|
CLI::logging("Upgrade finished but there were errors upgrading workspaces.\n");
|
|
|
|
|
CLI::logging(CLI::error("Please check the log above to correct any issues.")."\n");
|
|
|
|
|
} else {
|
|
|
|
|
CLI::logging("Upgrade successful\n");
|
2010-12-20 15:26:23 +00:00
|
|
|
}
|
2012-10-16 10:17:25 -04:00
|
|
|
//setting flag to false
|
|
|
|
|
$flag = G::isPMUnderUpdating(0);
|
2010-12-16 20:36:29 +00:00
|
|
|
}
|
|
|
|
|
|