From e33feacf41443f74c293a80096002bf8f2ee4da5 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Wed, 21 Sep 2016 15:26:01 -0400 Subject: [PATCH] HOR-1900 "Slowness in version upgrade" SOLVED Issue: Slowness in version upgrade Cause: El modulo de actualizacion de los XML files tiene un tiempo de procesamiento largo Solution: Se implementa la opcion "--no-xml" para los siguientes comandos: - ./processmaker upgrade --no-xml MyWorkspace //Un workspace - ./processmaker upgrade --no-xml //Todos los workspaces - ./processmaker workspace-upgrade --no-xml MyWorkspace //Un workspace - ./processmaker workspace-upgrade --no-xml //Todos los workspaces --- workflow/engine/bin/tasks/cliUpgrade.php | 12 ++++-- workflow/engine/bin/tasks/cliWorkspaces.php | 10 ++++- workflow/engine/classes/class.Upgrade.php | 3 +- workflow/engine/classes/class.wsTools.php | 44 +++++++++++++++------ 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/workflow/engine/bin/tasks/cliUpgrade.php b/workflow/engine/bin/tasks/cliUpgrade.php index 1d575fc81..36f2ee8e3 100644 --- a/workflow/engine/bin/tasks/cliUpgrade.php +++ b/workflow/engine/bin/tasks/cliUpgrade.php @@ -33,7 +33,8 @@ G::LoadClass("cli"); 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::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::taskRun("run_upgrade"); /*----------------------------------********---------------------------------*/ CLI::taskName('unify-database'); @@ -125,12 +126,14 @@ function run_upgrade($command, $args) G::rm_dir(PATH_C); G::mk_dir(PATH_C, 0777); } - $workspaces = get_workspaces_from_args($command); + $count = count($workspaces); $first = true; $errors = false; $countWorkspace = 0; - $buildCacheView = array_key_exists("buildACV", $args); + $buildCacheView = array_key_exists('buildACV', $args); + $flagUpdateXml = !array_key_exists('noxml', $args); + foreach ($workspaces as $index => $workspace) { if (!defined("SYS_SYS")) { define("SYS_SYS", $workspace->name); @@ -143,9 +146,10 @@ function run_upgrade($command, $args) try { $countWorkspace++; CLI::logging("Upgrading workspaces ($countWorkspace/$count): " . CLI::info($workspace->name) . "\n"); - $workspace->upgrade($first, $buildCacheView, $workspace->name); + $workspace->upgrade($buildCacheView, $workspace->name, false, 'en', ['updateXml' => $flagUpdateXml, 'updateMafe' => $first]); $workspace->close(); $first = false; + $flagUpdateXml = false; } catch (Exception $e) { CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"); $errors = true; diff --git a/workflow/engine/bin/tasks/cliWorkspaces.php b/workflow/engine/bin/tasks/cliWorkspaces.php index 144be3332..c15b79754 100644 --- a/workflow/engine/bin/tasks/cliWorkspaces.php +++ b/workflow/engine/bin/tasks/cliWorkspaces.php @@ -145,6 +145,8 @@ CLI::taskDescription(<<upgrade($first, false, $workspace->name, $lang); + $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" ); } @@ -336,7 +342,7 @@ function run_translation_upgrade($args, $opts) { foreach ($workspaces as $workspace) { try { G::outRes( "Upgrading translation for " . pakeColor::colorize($workspace->name, "INFO") . "\n" ); - $workspace->upgradeTranslation($first); + $workspace->upgradeTranslation($first, $first); $first = false; } catch (Exception $e) { G::outRes( "Errors upgrading translation of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n" ); diff --git a/workflow/engine/classes/class.Upgrade.php b/workflow/engine/classes/class.Upgrade.php index 2f0f0b903..8df3cb97d 100644 --- a/workflow/engine/classes/class.Upgrade.php +++ b/workflow/engine/classes/class.Upgrade.php @@ -134,7 +134,7 @@ class Upgrade try { $num += 1; printf("Upgrading workspaces ($num/$count): {$workspace->name}\n"); - $workspace->upgrade($first); + $workspace->upgrade(false, SYS_SYS, false, 'en', ['updateXml' => $first, 'updateMafe' => $first]); $workspace->close(); $first = false; } catch (Exception $e) { @@ -145,4 +145,3 @@ class Upgrade //printf("Time to install: %f\n", microtime(1) - $start); } } - diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index 98df65772..8c701ae5e 100644 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -58,10 +58,20 @@ class workspaceTools /** * Upgrade this workspace to the latest system version * - * @param bool $first true if this is the first workspace to be upgrade + * @param bool $buildCacheView + * @param string $workSpace + * @param bool $onedb + * @param string $lang + * @param array $arrayOptTranslation + * + * @return void */ - public function upgrade($first = false, $buildCacheView = false, $workSpace = SYS_SYS, $onedb = false, $lang = 'en') + public function upgrade($buildCacheView = false, $workSpace = SYS_SYS, $onedb = false, $lang = 'en', array $arrayOptTranslation = null) { + if (is_null($arrayOptTranslation)) { + $arrayOptTranslation = ['updateXml' => true, 'updateMafe' => true]; + } + $start = microtime(true); CLI::logging("> Updating database...\n"); $this->upgradeDatabase($onedb); @@ -82,7 +92,7 @@ class workspaceTools $start = microtime(true); CLI::logging("> Updating translations...\n"); - $this->upgradeTranslation($first); + $this->upgradeTranslation($arrayOptTranslation['updateXml'], $arrayOptTranslation['updateMafe']); $stop = microtime(true); $final = $stop - $start; CLI::logging("<*> Updating Translations Process took $final seconds.\n"); @@ -397,24 +407,36 @@ class workspaceTools /** * Upgrade this workspace translations from all avaliable languages. * - * @param bool $first if updating a series of workspace, true if the first + * @param bool $flagXml Update XML + * @param bool $flagMafe Update MAFE + * + * @return void */ - public function upgradeTranslation($first = true) + public function upgradeTranslation($flagXml = true, $flagMafe = true) { $this->initPropel(true); - //require_once ('classes/model/Language.php'); + G::LoadThirdParty('pear/json', 'class.json'); + + $language = new Language(); + foreach (System::listPoFiles() as $poFile) { $poName = basename($poFile); $names = explode(".", basename($poFile)); $extension = array_pop($names); $langid = array_pop($names); - CLI::logging("Updating database translations with $poName\n"); - Language::import($poFile, false, true, false); - if ($first) { - CLI::logging("Updating XML form translations with $poName\n"); - Language::import($poFile, true, false, true); + + CLI::logging('Updating Database translations with ' . $poName . "\n"); + + if ($flagXml) { + CLI::logging('Updating XML form translations with ' . $poName . "\n"); } + + if ($flagMafe) { + CLI::logging('Updating MAFE translations with ' . $poName . "\n"); + } + + $language->import($poFile, $flagXml, true, $flagMafe); } }