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
This commit is contained in:
Victor Saisa Lopez
2016-09-21 15:26:01 -04:00
parent bb8f804d8d
commit e33feacf41
4 changed files with 50 additions and 19 deletions

View File

@@ -33,7 +33,8 @@ G::LoadClass("cli");
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("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::taskRun("run_upgrade");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
CLI::taskName('unify-database'); CLI::taskName('unify-database');
@@ -125,12 +126,14 @@ function run_upgrade($command, $args)
G::rm_dir(PATH_C); G::rm_dir(PATH_C);
G::mk_dir(PATH_C, 0777); G::mk_dir(PATH_C, 0777);
} }
$workspaces = get_workspaces_from_args($command);
$count = count($workspaces); $count = count($workspaces);
$first = true; $first = true;
$errors = false; $errors = false;
$countWorkspace = 0; $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) { foreach ($workspaces as $index => $workspace) {
if (!defined("SYS_SYS")) { if (!defined("SYS_SYS")) {
define("SYS_SYS", $workspace->name); define("SYS_SYS", $workspace->name);
@@ -143,9 +146,10 @@ function run_upgrade($command, $args)
try { try {
$countWorkspace++; $countWorkspace++;
CLI::logging("Upgrading workspaces ($countWorkspace/$count): " . CLI::info($workspace->name) . "\n"); 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(); $workspace->close();
$first = false; $first = false;
$flagUpdateXml = false;
} catch (Exception $e) { } catch (Exception $e) {
CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"); CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n");
$errors = true; $errors = true;

View File

@@ -145,6 +145,8 @@ CLI::taskDescription(<<<EOT
EOT EOT
); );
CLI::taskArg('workspace-name', true, true); 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::taskRun("run_workspace_upgrade");
CLI::taskName('translation-repair'); CLI::taskName('translation-repair');
@@ -308,6 +310,9 @@ function run_workspace_upgrade($args, $opts) {
$workspaces = get_workspaces_from_args($args); $workspaces = get_workspaces_from_args($args);
$first = true; $first = true;
$lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en'; $lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';
$buildCacheView = array_key_exists('buildACV', $opts);
$flagUpdateXml = !array_key_exists('noxml', $opts);
foreach ($workspaces as $workspace) { foreach ($workspaces as $workspace) {
try { try {
if (!defined("SYS_SYS")) { if (!defined("SYS_SYS")) {
@@ -318,8 +323,9 @@ function run_workspace_upgrade($args, $opts) {
define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP); define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP);
} }
$workspace->upgrade($first, false, $workspace->name, $lang); $workspace->upgrade($buildCacheView, $workspace->name, false, $lang, ['updateXml' => $flagUpdateXml, 'updateMafe' => $first]);
$first = false; $first = false;
$flagUpdateXml = false;
} catch (Exception $e) { } catch (Exception $e) {
G::outRes( "Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n" ); 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) { foreach ($workspaces as $workspace) {
try { try {
G::outRes( "Upgrading translation for " . pakeColor::colorize($workspace->name, "INFO") . "\n" ); G::outRes( "Upgrading translation for " . pakeColor::colorize($workspace->name, "INFO") . "\n" );
$workspace->upgradeTranslation($first); $workspace->upgradeTranslation($first, $first);
$first = false; $first = false;
} catch (Exception $e) { } catch (Exception $e) {
G::outRes( "Errors upgrading translation of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n" ); G::outRes( "Errors upgrading translation of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n" );

View File

@@ -134,7 +134,7 @@ class Upgrade
try { try {
$num += 1; $num += 1;
printf("Upgrading workspaces ($num/$count): {$workspace->name}\n"); printf("Upgrading workspaces ($num/$count): {$workspace->name}\n");
$workspace->upgrade($first); $workspace->upgrade(false, SYS_SYS, false, 'en', ['updateXml' => $first, 'updateMafe' => $first]);
$workspace->close(); $workspace->close();
$first = false; $first = false;
} catch (Exception $e) { } catch (Exception $e) {
@@ -145,4 +145,3 @@ class Upgrade
//printf("Time to install: %f\n", microtime(1) - $start); //printf("Time to install: %f\n", microtime(1) - $start);
} }
} }

View File

@@ -58,10 +58,20 @@ class workspaceTools
/** /**
* Upgrade this workspace to the latest system version * 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); $start = microtime(true);
CLI::logging("> Updating database...\n"); CLI::logging("> Updating database...\n");
$this->upgradeDatabase($onedb); $this->upgradeDatabase($onedb);
@@ -82,7 +92,7 @@ class workspaceTools
$start = microtime(true); $start = microtime(true);
CLI::logging("> Updating translations...\n"); CLI::logging("> Updating translations...\n");
$this->upgradeTranslation($first); $this->upgradeTranslation($arrayOptTranslation['updateXml'], $arrayOptTranslation['updateMafe']);
$stop = microtime(true); $stop = microtime(true);
$final = $stop - $start; $final = $stop - $start;
CLI::logging("<*> Updating Translations Process took $final seconds.\n"); CLI::logging("<*> Updating Translations Process took $final seconds.\n");
@@ -397,24 +407,36 @@ class workspaceTools
/** /**
* Upgrade this workspace translations from all avaliable languages. * 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); $this->initPropel(true);
//require_once ('classes/model/Language.php');
G::LoadThirdParty('pear/json', 'class.json'); G::LoadThirdParty('pear/json', 'class.json');
$language = new Language();
foreach (System::listPoFiles() as $poFile) { foreach (System::listPoFiles() as $poFile) {
$poName = basename($poFile); $poName = basename($poFile);
$names = explode(".", basename($poFile)); $names = explode(".", basename($poFile));
$extension = array_pop($names); $extension = array_pop($names);
$langid = array_pop($names); $langid = array_pop($names);
CLI::logging("Updating database translations with $poName\n");
Language::import($poFile, false, true, false); CLI::logging('Updating Database translations with ' . $poName . "\n");
if ($first) {
CLI::logging("Updating XML form translations with $poName\n"); if ($flagXml) {
Language::import($poFile, true, false, true); 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);
} }
} }