This commit is contained in:
Julio Cesar Laura Avendaño
2019-03-18 13:36:08 -04:00
parent d4c81fe47f
commit b29170b87b
7 changed files with 268 additions and 547 deletions

View File

@@ -80,7 +80,6 @@ return array(
'ToolBar' => ToolBar::class, 'ToolBar' => ToolBar::class,
'Tree' => PmTree::class, 'Tree' => PmTree::class,
'triggerLibrary' => TriggerLibrary::class, 'triggerLibrary' => TriggerLibrary::class,
'Upgrade' => Upgrade::class,
'workspaceTools' => WorkspaceTools::class, 'workspaceTools' => WorkspaceTools::class,
'wsBase' => WsBase::class, 'wsBase' => WsBase::class,
'wsResponse' => WsResponse::class, 'wsResponse' => WsResponse::class,

View File

@@ -5,14 +5,16 @@ use ProcessMaker\Core\System;
CLI::taskName('upgrade'); CLI::taskName('upgrade');
CLI::taskDescription("Upgrade workspaces.\n\n This command should be run after upgrading ProcessMaker to a new version so that all workspaces are also upgraded to the\n new version."); CLI::taskDescription("Upgrade workspaces.\n\n This command should be run after upgrading ProcessMaker to a new version so that all workspaces are also upgraded to the\n new version.");
CLI::taskOpt('child', "Used by the main upgrade thread", 'child', 'child');
CLI::taskOpt('buildACV', 'If this option is enabled, the Cache View is built.', 'ACV', 'buildACV'); CLI::taskOpt('buildACV', 'If this option is enabled, the Cache View is built.', 'ACV', 'buildACV');
CLI::taskOpt('noxml', 'If this option is enabled, the XML files translation is not built.', 'NoXml', 'no-xml'); CLI::taskOpt('noxml', 'If this option is enabled, the XML files translation is not built.', 'NoXml', 'no-xml');
CLI::taskOpt('nomafe', 'If this option is enabled, the MAFE files translation is not built.', 'nomafe', 'no-mafe');
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::taskOpt('keep_dyn_content', "Include the DYN_CONTENT_HISTORY value. Ex: --keep_dyn_content", 'i', 'keep_dyn_content'); CLI::taskOpt('keep_dyn_content', "Include the DYN_CONTENT_HISTORY value. Ex: --keep_dyn_content", 'i', 'keep_dyn_content');
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::taskRun("run_upgrade"); CLI::taskRun("run_upgrade");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::taskName('unify-database'); CLI::taskName('unify-database');
CLI::taskDescription( CLI::taskDescription(
<<<EOT <<<EOT
@@ -36,177 +38,160 @@ CLI::taskRun("run_unify_database");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
/** /**
* A version of rm_dir which does not exits on error. * Execute the upgrade
* *
* @param string $filename directory or file to remove * @param array $parameters
* @param bool $filesOnly either to remove the containing directory as well or not * @param array $args
*/ */
function rm_dir($filename, $filesOnly = false) function run_upgrade($parameters, $args)
{ {
if (is_file($filename)) { // Get values from command and arguments
@unlink($filename) or CLI::logging(CLI::error("Could not remove file $filename")."\n"); $workspaces = get_workspaces_from_args($parameters);
} else { $mainThread = $printHF = !array_key_exists('child', $args);
foreach (glob("$filename/*") as $f) { $updateXmlForms = !array_key_exists('noxml', $args);
rm_dir($f); $updateMafe = !array_key_exists('nomafe', $args);
} $keepDynContent = false;
if (!$filesOnly) { /*----------------------------------********---------------------------------*/
@rmdir($filename) or CLI::logging(CLI::error("Could not remove directory $filename")."\n"); $keepDynContent = array_key_exists('keep_dyn_content', $args); //In community version this section will be removed
} /*----------------------------------********---------------------------------*/
}
}
function run_upgrade($command, $args) // Initializing variables
{ $globalStartTime = microtime(true);
CLI::logging("UPGRADE", PROCESSMAKER_PATH . "upgrade.log"); $numberOfWorkspaces = count($workspaces);
CLI::logging("Checking files integrity...\n"); $countWorkspace = 1;
//setting flag to true to check into sysGeneric.php
$workspaces = get_workspaces_from_args($command); if ($printHF) {
$oneWorkspace = 'true'; // Set upgrade flag
if (count($workspaces) == 1) { if (count($workspaces) === 1) {
foreach ($workspaces as $index => $workspace) { // For the specific workspace send in the command
$oneWorkspace = $workspace->name; G::isPMUnderUpdating(1, $workspaces[0]->name);
} else {
// For all workspaces
G::isPMUnderUpdating(1);
} }
// Print information when start the upgrade process
CLI::logging('UPGRADE LOG INITIALIZED', PROCESSMAKER_PATH . 'upgrade.log');
CLI::logging("UPGRADE STARTED\n");
} }
$flag = G::isPMUnderUpdating(1, $oneWorkspace);
//start to upgrade foreach ($workspaces as $workspace) {
$checksum = System::verifyChecksum(); if ($mainThread) {
if ($checksum === false) { CLI::logging("FOLDERS AND FILES OF THE SYSTEM\n");
CLI::logging(CLI::error("checksum.txt not found, integrity check is not possible") . "\n"); // Upgrade actions for global files
if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) { CLI::logging("* Start cleaning compiled folder...\n");
CLI::logging("Upgrade failed\n"); $start = microtime(true);
$flag = G::isPMUnderUpdating(0); if (defined('PATH_C')) {
die(); G::rm_dir(PATH_C);
} G::mk_dir(PATH_C, 0777);
} 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");
} }
} CLI::logging("* End cleaning compiled folder...(Completed on " . (microtime(true) - $start) . " seconds)\n");
if (!empty($checksum['diff'])) {
CLI::logging(CLI::error("The following files have modifications:")."\n"); CLI::logging("* Start to remove deprecated files...\n");
foreach ($checksum['diff'] as $diff) { $start = microtime(true);
CLI::logging(" $diff\n"); $workspace->removeDeprecatedFiles();
CLI::logging("* End to remove deprecated files...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start checking Enterprise folder/files...\n");
$start = microtime(true);
$workspace->verifyFilesOldEnterprise();
CLI::logging("* End checking Enterprise folder/files...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start checking framework paths...\n");
$start = microtime(true);
$workspace->checkFrameworkPaths();
CLI::logging("* End checking framework paths...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start fixing serialized instance in serverConf.singleton file...\n");
$start = microtime(true);
$serverConf = ServerConf::getSingleton();
$serverConf->updateClassNameInFile();
CLI::logging("* End fixing serialized instance in serverConf.singleton file...(Completed on " .
(microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start the safe upgrade for javascript files cached by the browser (Maborak, ExtJs)...\n");
$start = microtime(true);
G::browserCacheFilesSetUid();
CLI::logging("* End the safe upgrade for javascript files cached by the browser (Maborak, ExtJs)...(Completed on " .
(microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start to backup patch files...\n");
$arrayPatch = glob(PATH_TRUNK . 'patch-*');
if ($arrayPatch) {
foreach ($arrayPatch as $value) {
if (file_exists($value)) {
// Copy patch content
$names = pathinfo($value);
$nameFile = $names['basename'];
$contentFile = file_get_contents($value);
$contentFile = preg_replace("[\n|\r|\n\r]", '', $contentFile);
CLI::logging($contentFile . ' installed (' . $nameFile . ')', PATH_DATA . 'log/upgrades.log');
// Move patch file
$newFile = PATH_DATA . $nameFile;
G::rm_dir($newFile);
copy($value, $newFile);
G::rm_dir($value);
}
}
} }
} CLI::logging("* End to backup patch files...(Completed on " . (microtime(true) - $start) . " seconds)\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");
$flag = G::isPMUnderUpdating(0);
die();
}
}
}
CLI::logging("Clearing cache...\n");
if (defined('PATH_C')) {
G::rm_dir(PATH_C);
G::mk_dir(PATH_C, 0777);
}
$count = count($workspaces); CLI::logging("* Start to backup log files...\n");
$first = true; $start = microtime(true);
$errors = false; $workspace->backupLogFiles();
$countWorkspace = 0; CLI::logging("* End to backup log files... (Completed on " . (microtime(true) - $start) . " seconds)\n");
$buildCacheView = array_key_exists('buildACV', $args);
$flagUpdateXml = !array_key_exists('noxml', $args);
$optionMigrateHistoryData = [
/*----------------------------------********---------------------------------*/
'keepDynContent' => array_key_exists('keep_dyn_content', $args)
/*----------------------------------********---------------------------------*/
];
foreach ($workspaces as $index => $workspace) { // The previous actions should be executed only the first time
if (empty(config("system.workspace"))) { $mainThread = false;
define("SYS_SYS", $workspace->name);
config(["system.workspace" => $workspace->name]);
} }
if ($numberOfWorkspaces === 1) {
// Displaying information of the current workspace to upgrade
CLI::logging("UPGRADING DATABASE AND FILES OF WORKSPACE '{$workspace->name}' ($countWorkspace/$numberOfWorkspaces)\n");
if (!defined("PATH_DATA_SITE")) { // Build parameters
define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP); $arrayOptTranslation = [
} 'updateXml' => $updateXmlForms,
'updateMafe' => $updateMafe
];
$optionMigrateHistoryData = [
'keepDynContent' => $keepDynContent
];
if (!defined('DB_ADAPTER')) { // Upgrade database and files from a specific workspace
define('DB_ADAPTER', 'mysql'); $workspace->upgrade($workspace->name, true, SYS_LANG, $arrayOptTranslation, $optionMigrateHistoryData);
}
try {
$countWorkspace++;
CLI::logging("Upgrading workspaces ($countWorkspace/$count): " . CLI::info($workspace->name) . "\n");
$workspace->upgrade($buildCacheView, $workspace->name, false, 'en', ['updateXml' => $flagUpdateXml, 'updateMafe' => $first], $optionMigrateHistoryData);
$workspace->close(); $workspace->close();
$first = false; } else {
$flagUpdateXml = false; // Build arguments
} catch (Exception $e) { $args = '--child';
CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"); $args .= $updateXmlForms ? '' : ' --no-xml';
$errors = true; $args .= $updateMafe ? '' : ' --no-mafe';
$args .= $keepDynContent ? ' --keep_dyn_content' : '';
// Build and execute command in another thread
$command = PHP_BINARY . ' processmaker upgrade ' . $args . ' ' . $workspace->name;
passthru($command);
} }
// After the first execution is required set this values to false
$updateXmlForms = false;
$updateMafe = false;
// Increment workspaces counter
$countWorkspace++;
} }
//Verify the information of the singleton ServConf by changing the name of the class if is required. if ($printHF) {
CLI::logging("\nCheck/Fix serialized instance in serverConf.singleton file\n\n"); // Print information when finish the upgrade process
$serverConf = ServerConf::getSingleton(); CLI::logging('UPGRADE FINISHED (Completed on ' . (microtime(true) - $globalStartTime) .
$serverConf->updateClassNameInFile(); ' seconds), ProcessMaker ' . System::getVersion() . ' installed)' . "\n\n");
// SAVE Upgrades/Patches // Delete upgrade flag
$arrayPatch = glob(PATH_TRUNK . 'patch-*'); G::isPMUnderUpdating(0);
if ($arrayPatch) {
foreach ($arrayPatch as $value) {
if (file_exists($value)) {
// copy content the patch
$names = pathinfo($value);
$nameFile = $names['basename'];
$contentFile = file_get_contents($value);
$contentFile = preg_replace("[\n|\r|\n\r]", '', $contentFile);
CLI::logging($contentFile . ' installed (' . $nameFile . ')', PATH_DATA . 'log/upgrades.log');
// move file of patch
$newFile = PATH_DATA . $nameFile;
G::rm_dir($newFile);
copy($value, $newFile);
G::rm_dir($value);
}
}
} else {
CLI::logging('ProcessMaker ' . System::getVersion(). ' installed', PATH_DATA . 'log/upgrades.log');
} }
//Safe upgrade for JavaScript files
CLI::logging("\nSafe upgrade for files cached by the browser\n\n");
G::browserCacheFilesSetUid();
//Status
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");
}
//setting flag to false
$flag = G::isPMUnderUpdating(0);
} }
function listFiles($dir)
{
$files = array();
$lista = glob($dir.'/*');
foreach ($lista as $valor) {
if (is_dir($valor)) {
$inner_files = listFiles($valor);
if (is_array($inner_files)) {
$files = array_merge($files, $inner_files);
}
}
if (is_file($valor)) {
array_push($files, $valor);
}
}
return $files;
}
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
function run_unify_database($args) function run_unify_database($args)
{ {

View File

@@ -106,26 +106,6 @@ EOT
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_plugins_database_upgrade"); CLI::taskRun("run_plugins_database_upgrade");
CLI::taskName('workspace-upgrade');
CLI::taskDescription(<<<EOT
Upgrade the specified workspace(s).
If no workspace is specified, the command will be run in all workspaces. More
than one workspace can be specified.
This command is a shortcut to execute all the upgrade commands for workspaces.
Upgrading a workspace will make it correspond to the current version of
ProcessMaker.
Use this command to upgrade workspaces individually, otherwise use the
'processmaker upgrade' command to upgrade the entire system.
EOT
);
CLI::taskArg('workspace-name', true, true);
CLI::taskOpt('buildACV', 'If this option is enabled, the Cache View is built.', 'ACV', 'buildACV');
CLI::taskOpt('noxml', 'If this option is enabled, the XML files translation is not built.', 'NoXml', 'no-xml');
CLI::taskRun("run_workspace_upgrade");
CLI::taskName('translation-repair'); CLI::taskName('translation-repair');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Upgrade or repair translations for the specified workspace(s). Upgrade or repair translations for the specified workspace(s).
@@ -412,69 +392,6 @@ function run_info($args, $opts)
} }
} }
/**
* Check if we need to execute the workspace-upgrade
* If we apply the command for all workspaces, we will need to execute one by one by redefining the constants
*
* @param string $args, workspace name that we need to apply the database-upgrade
* @param string $opts, additional arguments
*
* @return void
*/
function run_workspace_upgrade($args, $opts)
{
//Read the additional parameters for this command
$parameters = '';
$parameters .= array_key_exists('buildACV', $opts) ? '--buildACV ' : '';
$parameters .= array_key_exists('noxml', $opts) ? '--no-xml ' : '';
$parameters .= array_key_exists("lang", $opts) ? 'lang=' . $opts['lang'] : 'lang=' . SYS_LANG;
//Check if the command is executed by a specific workspace
if (count($args) === 1) {
workspace_upgrade($args, $opts);
} else {
$workspaces = get_workspaces_from_args($args);
foreach ($workspaces as $workspace) {
passthru(PHP_BINARY . ' processmaker upgrade ' . $parameters . ' ' . $workspace->name);
}
}
}
/**
* This function is executed only by one workspace, for the command workspace-upgrade
*
* @param array $args, workspace name for to apply the upgrade
* @param array $opts, specify additional arguments for language, flag for buildACV, flag for noxml
*
* @return void
*/
function workspace_upgrade($args, $opts) {
$first = true;
$workspaces = get_workspaces_from_args($args);
$lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';
$buildCacheView = array_key_exists('buildACV', $opts);
$flagUpdateXml = !array_key_exists('noxml', $opts);
$wsName = $workspaces[key($workspaces)]->name;
Bootstrap::setConstantsRelatedWs($wsName);
//Loop, read all the attributes related to the one workspace
foreach ($workspaces as $workspace) {
try {
$workspace->upgrade(
$buildCacheView,
$workspace->name,
false,
$lang,
['updateXml' => $flagUpdateXml, 'updateMafe' => $first]
);
$first = false;
$flagUpdateXml = false;
} catch (Exception $e) {
G::outRes("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n");
}
}
}
/** /**
* We will upgrade the CONTENT table * We will upgrade the CONTENT table
* If we apply the command for all workspaces, we will need to execute one by one by redefining the constants * If we apply the command for all workspaces, we will need to execute one by one by redefining the constants
@@ -1210,7 +1127,7 @@ function migrate_content($args, $opts)
foreach ($workspaces as $workspace) { foreach ($workspaces as $workspace) {
print_r('Regenerating content in: ' . pakeColor::colorize($workspace->name, 'INFO') . "\n"); print_r('Regenerating content in: ' . pakeColor::colorize($workspace->name, 'INFO') . "\n");
CLI::logging("-> Regenerating content \n"); CLI::logging("-> Regenerating content \n");
$workspace->migrateContentRun($workspace->name, $lang); $workspace->migrateContentRun($lang);
} }
$stop = microtime(true); $stop = microtime(true);
CLI::logging("<*> Optimizing content data Process took " . ($stop - $start) . " seconds.\n"); CLI::logging("<*> Optimizing content data Process took " . ($stop - $start) . " seconds.\n");

View File

@@ -1,128 +0,0 @@
<?php
use ProcessMaker\Core\System;
class Upgrade
{
private $addon = null;
public function __construct($addon)
{
$this->addon = $addon;
}
public function install()
{
$filter = new InputFilter();
$start = microtime(1);
$filename = $this->addon->getDownloadFilename();
$time = microtime(1);
$archive = new Archive_Tar ($filename);
$time = microtime(1);
$extractDir = dirname($this->addon->getDownloadFilename()) . "/extract";
$extractDir = $filter->xssFilterHard($extractDir);
$backupDir = dirname($this->addon->getDownloadFilename()) . "/backup";
$backupDir = $filter->xssFilterHard($backupDir);
if (file_exists($extractDir)) {
G::rm_dir($extractDir);
}
if (file_exists($backupDir)) {
G::rm_dir($backupDir);
}
if (!is_dir($backupDir)) {
mkdir($backupDir);
}
$time = microtime(1);
echo "Extracting files...\n";
$archive->extractModify($extractDir, 'processmaker');
$checksumFile = file_get_contents("$extractDir/checksum.txt");
$time = microtime(1);
$checksums = array();
foreach (explode("\n", $checksumFile) as $line) {
$checksums[trim(substr($line, 33))] = substr($line, 0, 32);
}
$checksum = array();
$changedFiles = array();
$time = microtime(1);
$files = $this->ls_dir($extractDir);
echo "Updating ProcessMaker files...\n";
$time = microtime(1);
$checksumTime = 0;
foreach ($checksums as $filename => $checksum) {
if (is_dir("$extractDir/$filename")) {
$filename = $filter->xssFilterHard($filename);
print $filename;
continue;
}
$installedFile = PATH_TRUNK . "/$filename";
if (!file_exists($installedFile)) {
$installedMD5 = "";
} else {
$time = microtime(1);
$installedMD5 = G::encryptFileOld($installedFile);
$checksumTime += microtime(1) - $time;
}
$archiveMD5 = $checksum;
if (strcasecmp($archiveMD5, $installedMD5) != 0) {
$changedFiles[] = $filename;
if (!is_dir(dirname($backupDir.'/'.$filename))) {
mkdir(dirname($backupDir.'/'.$filename), 0777, true);
}
if (file_exists($installedFile) && is_file($installedFile)) {
copy($installedFile, $backupDir.'/'.$filename);
}
if (!is_dir(dirname($installedFile))) {
mkdir(dirname($installedFile), 0777, true);
}
if (!copy("$extractDir/$filename", $installedFile)) {
throw new Exception("Could not overwrite '$filename'");
}
}
}
printf("Updated %d files\n", count($changedFiles));
printf("Clearing cache...\n");
if (defined('PATH_C')) {
G::rm_dir(PATH_C);
mkdir(PATH_C, 0777, true);
}
$workspaces = System::listWorkspaces();
$count = count($workspaces);
$first = true;
$num = 0;
foreach ($workspaces as $index => $workspace) {
try {
$num += 1;
printf("Upgrading workspaces ($num/$count): {$workspace->name}\n");
$workspace->upgrade(false, config("system.workspace"), false, 'en', ['updateXml' => $first, 'updateMafe' => $first]);
$workspace->close();
$first = false;
} catch (Exception $e) {
printf("Errors upgrading workspace {$workspace->name}: {$e->getMessage()}\n");
}
}
}
private function ls_dir($dir, $basename = null)
{
$files = array();
if ($basename == null) {
$basename = $dir;
}
foreach (glob("$dir/*") as $filename) {
if (is_dir($filename)) {
$files = array_merge($files, $this->ls_dir($filename, $basename));
} else {
$files[] = substr($filename, strlen($basename) + 1);
}
}
return $files;
}
}

View File

@@ -218,160 +218,115 @@ class WorkspaceTools
/** /**
* Upgrade this workspace to the latest system version * Upgrade this workspace to the latest system version
* *
* @param bool $buildCacheView * @param string $workspace
* @param string $workSpace
* @param bool $onedb * @param bool $onedb
* @param string $lang * @param string $lang
* @param array $arrayOptTranslation * @param array $arrayOptTranslation
* @param array $optionMigrateHistoryData
* *
* @return void * @return void
*/ */
public function upgrade($buildCacheView = false, $workSpace = null, $onedb = false, $lang = 'en', array $arrayOptTranslation = null, $optionMigrateHistoryData = []) public function upgrade($workspace, $onedb = false, $lang = 'en', array $arrayOptTranslation = null, $optionMigrateHistoryData = [])
{ {
if ($workSpace === null) {
$workSpace = config("system.workspace");
}
if (is_null($arrayOptTranslation)) { if (is_null($arrayOptTranslation)) {
$arrayOptTranslation = ['updateXml' => true, 'updateMafe' => true]; $arrayOptTranslation = ['updateXml' => true, 'updateMafe' => true];
} }
CLI::logging("* Start updating database schema...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Remove deprecated files...\n");
$this->removeDeprecatedFiles();
$stop = microtime(true);
CLI::logging("<*> Remove deprecated files took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Updating database...\n");
$this->upgradeDatabase($onedb); $this->upgradeDatabase($onedb);
$stop = microtime(true); CLI::logging("* End updating database schema...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("<*> Database Upgrade Process took " . ($stop - $start) . " seconds.\n");
CLI::logging("* Start updating translations...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Check Intermediate Email Event...\n");
$this->checkIntermediateEmailEvent();
$stop = microtime(true);
CLI::logging("<*> Database Upgrade Process took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Verify enterprise old...\n");
$this->verifyFilesOldEnterprise($workSpace);
$stop = microtime(true);
CLI::logging("<*> Verify took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Updating translations...\n");
$this->upgradeTranslation($arrayOptTranslation['updateXml'], $arrayOptTranslation['updateMafe']); $this->upgradeTranslation($arrayOptTranslation['updateXml'], $arrayOptTranslation['updateMafe']);
$stop = microtime(true); CLI::logging("* End updating translations...(Completed on " . (microtime(true) - $start) . " seconds)\n");
$final = $stop - $start;
CLI::logging("<*> Updating Translations Process took $final seconds.\n"); CLI::logging("* Start checking MAFE requirements...\n");
$start = microtime(true);
$this->checkMafeRequirements($workspace, $lang);
CLI::logging("* End checking MAFE requirements...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start to update CONTENT table...\n");
$start = microtime(true);
$this->upgradeContent($workspace);
CLI::logging("* End to update CONTENT table... (Completed on " . (microtime(true) - $start) . " seconds)\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Updating Content...\n"); CLI::logging("* Start to migrate texts/values from 'CONTENT' table to the corresponding object tables...\n");
$this->upgradeContent($workSpace); $this->migrateContent($lang);
$stop = microtime(true); CLI::logging("* End to migrate texts/values from 'CONTENT' table to the corresponding object tables... (Completed on " .
$final = $stop - $start; (microtime(true) - $start) . " seconds)\n");
CLI::logging("<*> Updating Content Process took $final seconds.\n");
CLI::logging("* Start updating rows in Web Entry table for classic processes...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Check Mafe Requirements...\n"); $this->updatingWebEntryClassicModel(true);
$this->checkMafeRequirements($workSpace, $lang); CLI::logging("* End updating rows in Web Entry table for classic processes...(Completed on " .
$stop = microtime(true); (microtime(true) - $start) . " seconds)\n");
$final = $stop - $start;
CLI::logging("<*> Check Mafe Requirements Process took $final seconds.\n");
CLI::logging("* Start to update Files Manager...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Updating Triggers...\n"); $this->processFilesUpgrade($workspace);
$this->updateTriggers(true, $lang); CLI::logging("* End to update Files Manager... (Completed on " . (microtime(true) - $start) . " seconds)\n");
$stop = microtime(true);
$final = $stop - $start;
CLI::logging("<*> Updating Triggers Process took $final seconds.\n");
$start = microtime(true);
CLI::logging("> Backup log files...\n");
$this->backupLogFiles();
$stop = microtime(true);
$final = $stop - $start;
CLI::logging("<*> Backup log files Process took $final seconds.\n");
$start = microtime(true);
CLI::logging("> Optimizing content data...\n");
$this->migrateContent($workSpace, $lang);
$stop = microtime(true);
CLI::logging("<*> Optimizing content data took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Migrating and populating indexing for avoiding the use of table APP_CACHE_VIEW...\n");
$this->migratePopulateIndexingACV($workSpace);
$stop = microtime(true);
CLI::logging("<*> Migrating an populating indexing for avoiding the use of table APP_CACHE_VIEW process took " . ($stop - $start) . " seconds.\n");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::logging("* Start migrating to new list tables...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Migrate new lists...\n"); $this->migrateList(true, $lang);
$this->migrateList($workSpace, false, $lang); CLI::logging("* End migrating to new list tables...(Completed on " . (microtime(true) - $start) . " seconds)\n");
$stop = microtime(true);
$final = $stop - $start;
CLI::logging("<*> Migrate new lists Process took $final seconds.\n");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::logging("* Start migrating and populating plugin singleton data...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Updating Files Manager...\n"); $this->migrateSingleton($workspace);
$this->processFilesUpgrade(); CLI::logging("* End migrating and populating plugin singleton data...(Completed on " .
$stop = microtime(true); (microtime(true) - $start) . " seconds)\n");
CLI::logging("<*> Updating Files Manager took " . ($stop - $start) . " seconds.\n");
CLI::logging("* Start cleaning expired tokens...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Clean access and refresh tokens...\n"); $this->cleanTokens();
$this->cleanTokens($workSpace); CLI::logging("* End cleaning expired tokens...(Completed on " . (microtime(true) - $start) . " seconds)\n");
$stop = microtime(true);
CLI::logging("<*> Clean access and refresh tokens took " . ($stop - $start) . " seconds.\n");
CLI::logging("* Start to check Intermediate Email Event...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Optimizing Self-Service data...\n"); $this->checkIntermediateEmailEvent();
$this->migrateSelfServiceRecordsRun($workSpace); CLI::logging("* End to check Intermediate Email Event... (Completed on " . (microtime(true) - $start) . " seconds)\n");
$stop = microtime(true);
CLI::logging("<*> Migrating Self-Service records Process took " . ($stop - $start) . " seconds.\n");
CLI::logging("* Start cleaning DYN_CONTENT in APP_HISTORY...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Updating rows in Web Entry table for classic processes...\n");
$this->updatingWebEntryClassicModel($workSpace);
$stop = microtime(true);
CLI::logging("<*> Updating rows in Web Entry table for classic processes took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Update framework paths...\n");
$this->updateFrameworkPaths($workSpace);
$stop = microtime(true);
CLI::logging("<*> Update framework paths took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Migrating and populating plugin singleton data...\n");
$this->migrateSingleton($workSpace);
$stop = microtime(true);
CLI::logging("<*> Migrating and populating plugin singleton data took " . ($stop - $start) . " seconds.\n");
$keepDynContent = isset($optionMigrateHistoryData['keepDynContent']) && $optionMigrateHistoryData['keepDynContent'] === true; $keepDynContent = isset($optionMigrateHistoryData['keepDynContent']) && $optionMigrateHistoryData['keepDynContent'] === true;
//Review if we need to remove the 'History of use' from APP_HISTORY
$start = microtime(true);
CLI::logging("> Clearing History of Use from APP_HISTORY table...\n");
$this->clearDynContentHistoryData(false, $keepDynContent); $this->clearDynContentHistoryData(false, $keepDynContent);
$stop = microtime(true); CLI::logging("* End cleaning DYN_CONTENT in APP_HISTORY...(Completed on " . (microtime(true) - $start) . " seconds)\n");
CLI::logging("<*> Clearing History of Use from APP_HISTORY table took " . ($stop - $start) . " seconds.\n");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::logging("* Start migrating history data...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Migrating history data...\n"); $this->migrateAppHistoryToAppDataChangeLog(true);
$this->migrateAppHistoryToAppDataChangeLog(false); CLI::logging("* End migrating history data...(Completed on " . (microtime(true) - $start) . " seconds)\n");
$stop = microtime(true);
CLI::logging("<*> Migrating history data took " . ($stop - $start) . " seconds.\n");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::logging("* Start migrating and populating indexing for avoiding the use of table APP_CACHE_VIEW...\n");
$start = microtime(true);
$this->migratePopulateIndexingACV();
CLI::logging("* End migrating and populating indexing for avoiding the use of table APP_CACHE_VIEW...(Completed on " .
(microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP....\n");
$start = microtime(true);
$this->migrateSelfServiceRecordsRun();
CLI::logging("* End optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP....(Completed on " .
(microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start adding new fields and populating values in tables related to feature self service by value...\n");
$start = microtime(true); $start = microtime(true);
CLI::logging("> Optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP....\n");
$this->upgradeSelfServiceData(); $this->upgradeSelfServiceData();
$stop = microtime(true); CLI::logging("* End adding new fields and populating values in tables related to feature self service by value...(Completed on " .
CLI::logging("<*> Optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP took " . ($stop - $start) . " seconds.\n"); (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start updating MySQL triggers...\n");
$start = microtime(true);
$this->updateTriggers(true, $lang);
CLI::logging("* End updating MySQL triggers...(" . (microtime(true) - $start) . " seconds)\n");
} }
/** /**
@@ -391,6 +346,9 @@ class WorkspaceTools
CLI::logging("<*> Database Upgrade Structure Process took $final seconds.\n"); CLI::logging("<*> Database Upgrade Structure Process took $final seconds.\n");
} }
/**
* Update the email events with the current email server
*/
public function checkIntermediateEmailEvent() public function checkIntermediateEmailEvent()
{ {
$oEmailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); $oEmailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
@@ -629,9 +587,11 @@ class WorkspaceTools
} }
/** /**
* Upgrade this workspace Content. * Upgrade this workspace Content
*
* @param string $workspace * @param string $workspace
* @param boolean $executeRegenerateContent * @param boolean $executeRegenerateContent
*
* @return void * @return void
*/ */
public function upgradeContent($workspace = null, $executeRegenerateContent = false) public function upgradeContent($workspace = null, $executeRegenerateContent = false)
@@ -683,7 +643,7 @@ class WorkspaceTools
} }
/** /**
* Upgrade this workspace translations from all avaliable languages. * Upgrade the workspace translations from all available languages
* *
* @param bool $flagXml Update XML * @param bool $flagXml Update XML
* @param bool $flagMafe Update MAFE * @param bool $flagMafe Update MAFE
@@ -1055,10 +1015,12 @@ class WorkspaceTools
} }
/** /**
* Upgrade this workspace database to the latest system schema * Upgrade the workspace database to the latest system schema
* *
* @param bool $checkOnly only check if the upgrade is needed if true * @param bool $onedb Was installed in one DB or not
* @return array bool upgradeSchema for more information * @param bool $checkOnly Only check if the upgrade is needed if true
*
* @return bool upgradeSchema
*/ */
public function upgradeDatabase($onedb = false, $checkOnly = false) public function upgradeDatabase($onedb = false, $checkOnly = false)
{ {
@@ -2173,6 +2135,9 @@ class WorkspaceTools
return $result; return $result;
} }
/**
* Backup the log files
*/
public function backupLogFiles() public function backupLogFiles()
{ {
$config = System::getSystemConfiguration(); $config = System::getSystemConfiguration();
@@ -2189,6 +2154,12 @@ class WorkspaceTools
} }
} }
/**
* Check if the workspace have the clients used by MAFE registered
*
* @param string $workspace
* @param string $lang
*/
public function checkMafeRequirements($workspace, $lang) public function checkMafeRequirements($workspace, $lang)
{ {
$this->initPropel(true); $this->initPropel(true);
@@ -2265,9 +2236,8 @@ class WorkspaceTools
return true; return true;
} }
public function verifyFilesOldEnterprise($workspace) public function verifyFilesOldEnterprise()
{ {
$this->initPropel(true);
$pathBackup = PATH_DATA . 'backups'; $pathBackup = PATH_DATA . 'backups';
if (!file_exists($pathBackup)) { if (!file_exists($pathBackup)) {
G::mk_dir($pathBackup, 0777); G::mk_dir($pathBackup, 0777);
@@ -2381,12 +2351,12 @@ class WorkspaceTools
/** /**
* Migrate all cases to New list * Migrate all cases to New list
* *
* @param string $workSpace Workspace
* @param bool $flagReinsert Flag that specifies the re-insertion * @param bool $flagReinsert Flag that specifies the re-insertion
* @param string $lang
* *
* @return void * @return void
*/ */
public function migrateList($workSpace, $flagReinsert = false, $lang = 'en') public function migrateList($flagReinsert = false, $lang = 'en')
{ {
$this->initPropel(true); $this->initPropel(true);
@@ -3034,19 +3004,21 @@ class WorkspaceTools
} }
/** /**
* Process-Files upgrade * Process files upgrade, store the information in the DB
*
* @param string $workspace
* *
* return void * return void
*/ */
public function processFilesUpgrade() public function processFilesUpgrade($workspace)
{ {
try { try {
if (!defined("PATH_DATA_MAILTEMPLATES")) { if (!defined("PATH_DATA_MAILTEMPLATES")) {
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates" . PATH_SEP); define("PATH_DATA_MAILTEMPLATES", PATH_DATA . 'sites' . PATH_SEP . $workspace . PATH_SEP . "mailTemplates" . PATH_SEP);
} }
if (!defined("PATH_DATA_PUBLIC")) { if (!defined("PATH_DATA_PUBLIC")) {
define("PATH_DATA_PUBLIC", PATH_DATA_SITE . "public" . PATH_SEP); define("PATH_DATA_PUBLIC", PATH_DATA . 'sites' . PATH_SEP . $workspace . PATH_SEP . "public" . PATH_SEP);
} }
$this->initPropel(true); $this->initPropel(true);
@@ -3559,8 +3531,12 @@ class WorkspaceTools
return $response; return $response;
} }
/**
public function migrateContent($workspace, $lang = SYS_LANG) * Migrate texts/values from "CONTENT" table to the corresponding object tables
*
* @param string $lang
*/
public function migrateContent($lang = SYS_LANG)
{ {
if ((!class_exists('Memcache') || !class_exists('Memcached')) && !defined('MEMCACHED_ENABLED')) { if ((!class_exists('Memcache') || !class_exists('Memcached')) && !defined('MEMCACHED_ENABLED')) {
define('MEMCACHED_ENABLED', false); define('MEMCACHED_ENABLED', false);
@@ -3573,7 +3549,7 @@ class WorkspaceTools
$blackList = $oConfig['CFG_VALUE'] == 'true' ? array('Groupwf', 'Process', 'Department', 'Task', 'InputDocument', 'Application') : unserialize($oConfig['CFG_VALUE']); $blackList = $oConfig['CFG_VALUE'] == 'true' ? array('Groupwf', 'Process', 'Department', 'Task', 'InputDocument', 'Application') : unserialize($oConfig['CFG_VALUE']);
} }
$blackList = $this->migrateContentRun($workspace, $lang, $blackList); $blackList = $this->migrateContentRun($lang, $blackList);
$data["CFG_UID"] = 'MIGRATED_CONTENT'; $data["CFG_UID"] = 'MIGRATED_CONTENT';
$data["OBJ_UID"] = 'content'; $data["OBJ_UID"] = 'content';
$data["CFG_VALUE"] = serialize($blackList); $data["CFG_VALUE"] = serialize($blackList);
@@ -3640,13 +3616,14 @@ class WorkspaceTools
} }
/** /**
* Migration * Migrate from "CONTENT" table to the corresponding object tables
*
* @param string $lang
* @param array $blackList
* *
* @param $workspace
* @param mixed|string $lang
* @return array * @return array
*/ */
public function migrateContentRun($workspace, $lang = SYS_LANG, $blackList = array()) public function migrateContentRun($lang = SYS_LANG, $blackList = [])
{ {
if ((!class_exists('Memcache') || !class_exists('Memcached')) && !defined('MEMCACHED_ENABLED')) { if ((!class_exists('Memcache') || !class_exists('Memcached')) && !defined('MEMCACHED_ENABLED')) {
define('MEMCACHED_ENABLED', false); define('MEMCACHED_ENABLED', false);
@@ -3662,7 +3639,10 @@ class WorkspaceTools
return $blackList; return $blackList;
} }
public function cleanTokens($workspace, $lang = SYS_LANG) /**
* Clean the expired access and refresh tokens
*/
public function cleanTokens()
{ {
$this->initPropel(true); $this->initPropel(true);
$oCriteria = new Criteria(); $oCriteria = new Criteria();
@@ -3750,7 +3730,10 @@ class WorkspaceTools
} }
} }
public function migrateSelfServiceRecordsRun($workspace) /**
* Migrate the concatenated strings with UIDs from groups to the table "APP_ASSIGN_SELF_SERVICE_VALUE_GROUP"
*/
public function migrateSelfServiceRecordsRun()
{ {
// Initializing // Initializing
$this->initPropel(true); $this->initPropel(true);
@@ -3797,7 +3780,10 @@ class WorkspaceTools
CLI::logging(" Migrating Self-Service by Value Cases Done \n"); CLI::logging(" Migrating Self-Service by Value Cases Done \n");
} }
public function migratePopulateIndexingACV($workspace) /**
* Populate new fields used for avoiding the use of the "APP_CACHE_VIEW" table
*/
public function migratePopulateIndexingACV()
{ {
// Migrating and populating new indexes // Migrating and populating new indexes
CLI::logging("-> Migrating an populating indexing for avoiding the use of table APP_CACHE_VIEW Start \n"); CLI::logging("-> Migrating an populating indexing for avoiding the use of table APP_CACHE_VIEW Start \n");
@@ -4062,9 +4048,10 @@ class WorkspaceTools
* It populates the WEB_ENTRY table for the classic processes, this procedure * It populates the WEB_ENTRY table for the classic processes, this procedure
* is done to verify the execution of php files generated when the WebEntry * is done to verify the execution of php files generated when the WebEntry
* is configured. * is configured.
* @param type $workSpace *
* @param bool $force
*/ */
public function updatingWebEntryClassicModel($workSpace, $force = false) public function updatingWebEntryClassicModel($force = false)
{ {
//We obtain from the configuration the list of proUids obtained so that //We obtain from the configuration the list of proUids obtained so that
//we do not go through again. //we do not go through again.
@@ -4160,8 +4147,9 @@ class WorkspaceTools
/** /**
* Updating triggers * Updating triggers
* @param $flagRecreate *
* @param $lang * @param bool $flagRecreate
* @param string $lang
*/ */
public function updateTriggers($flagRecreate, $lang) public function updateTriggers($flagRecreate, $lang)
{ {
@@ -4170,6 +4158,8 @@ class WorkspaceTools
} }
/** /**
* Migrate the data of the "plugin.singleton" file to the "PLUGIN_REGISTRY" table
*
* @param $workspace * @param $workspace
*/ */
public function migrateSingleton($workspace) public function migrateSingleton($workspace)
@@ -4215,14 +4205,11 @@ class WorkspaceTools
} }
/** /**
* Updating framework directory structure * Check/Create framework's directories
* *
*/ */
private function updateFrameworkPaths($workSpace = null) public function checkFrameworkPaths()
{ {
if ($workSpace === null) {
$workSpace = config("system.workspace");
}
$paths = [ $paths = [
PATH_DATA . 'framework' => 0770, PATH_DATA . 'framework' => 0770,
PATH_DATA . 'framework' . DIRECTORY_SEPARATOR . 'cache' => 0770, PATH_DATA . 'framework' . DIRECTORY_SEPARATOR . 'cache' => 0770,

View File

@@ -385,13 +385,7 @@ class AddonsManager extends BaseAddonsManager
$this->setState(); $this->setState();
} else { } else {
if ($this->getAddonType() == "core") { throw new Exception("Addon type {$this->getAddonType()} not supported.");
$upgrade = new Upgrade($this);
$upgrade->install();
} else {
throw new Exception("Addon type {$this->getAddonType()} not supported.");
}
} }
} }

View File

@@ -243,39 +243,6 @@ class System
return $items; return $items;
} }
/**
* Review the checksum.txt
*
* @return array $result
*/
public static function verifyChecksum()
{
if (!file_exists(PATH_TRUNK . "checksum.txt")) {
return false;
}
$lines = explode("\n", file_get_contents(PATH_TRUNK . "checksum.txt"));
$result = array("diff" => array(), "missing" => array()
);
foreach ($lines as $line) {
if (empty($line)) {
continue;
}
list ($checksum, $empty, $filename) = explode(" ", $line);
//Skip xmlform because these files always change.
if (strpos($filename, "/xmlform/") !== false) {
continue;
}
if (file_exists(realpath($filename))) {
if (strcmp($checksum, G::encryptFileOld(realpath($filename))) != 0) {
$result['diff'][] = $filename;
}
} else {
$result['missing'][] = $filename;
}
}
return $result;
}
/** /**
* This function checks files to do updated to pm * This function checks files to do updated to pm
* *