diff --git a/bootstrap/classaliasmap.php b/bootstrap/classaliasmap.php index 62e24f3f0..734997540 100644 --- a/bootstrap/classaliasmap.php +++ b/bootstrap/classaliasmap.php @@ -80,7 +80,6 @@ return array( 'ToolBar' => ToolBar::class, 'Tree' => PmTree::class, 'triggerLibrary' => TriggerLibrary::class, - 'Upgrade' => Upgrade::class, 'workspaceTools' => WorkspaceTools::class, 'wsBase' => WsBase::class, 'wsResponse' => WsResponse::class, diff --git a/workflow/engine/bin/tasks/cliUpgrade.php b/workflow/engine/bin/tasks/cliUpgrade.php index a1d181dcf..d09d3adff 100644 --- a/workflow/engine/bin/tasks/cliUpgrade.php +++ b/workflow/engine/bin/tasks/cliUpgrade.php @@ -5,14 +5,16 @@ use ProcessMaker\Core\System; 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('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('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::taskRun("run_upgrade"); /*----------------------------------********---------------------------------*/ + CLI::taskName('unify-database'); CLI::taskDescription( << $workspace) { - $oneWorkspace = $workspace->name; + // Initializing variables + $globalStartTime = microtime(true); + $numberOfWorkspaces = count($workspaces); + $countWorkspace = 1; + + if ($printHF) { + // Set upgrade flag + if (count($workspaces) === 1) { + // For the specific workspace send in the command + 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 - $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"); - $flag = G::isPMUnderUpdating(0); - 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"); + + foreach ($workspaces as $workspace) { + if ($mainThread) { + CLI::logging("FOLDERS AND FILES OF THE SYSTEM\n"); + // Upgrade actions for global files + CLI::logging("* Start cleaning compiled folder...\n"); + $start = microtime(true); + if (defined('PATH_C')) { + G::rm_dir(PATH_C); + G::mk_dir(PATH_C, 0777); } - } - if (!empty($checksum['diff'])) { - CLI::logging(CLI::error("The following files have modifications:")."\n"); - foreach ($checksum['diff'] as $diff) { - CLI::logging(" $diff\n"); + CLI::logging("* End cleaning compiled folder...(Completed on " . (microtime(true) - $start) . " seconds)\n"); + + CLI::logging("* Start to remove deprecated files...\n"); + $start = microtime(true); + $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); + } + } } - } - 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); - } + CLI::logging("* End to backup patch files...(Completed on " . (microtime(true) - $start) . " seconds)\n"); - $count = count($workspaces); - $first = true; - $errors = false; - $countWorkspace = 0; - $buildCacheView = array_key_exists('buildACV', $args); - $flagUpdateXml = !array_key_exists('noxml', $args); - $optionMigrateHistoryData = [ - /*----------------------------------********---------------------------------*/ - 'keepDynContent' => array_key_exists('keep_dyn_content', $args) - /*----------------------------------********---------------------------------*/ - ]; + CLI::logging("* Start to backup log files...\n"); + $start = microtime(true); + $workspace->backupLogFiles(); + CLI::logging("* End to backup log files... (Completed on " . (microtime(true) - $start) . " seconds)\n"); - foreach ($workspaces as $index => $workspace) { - if (empty(config("system.workspace"))) { - define("SYS_SYS", $workspace->name); - config(["system.workspace" => $workspace->name]); + // The previous actions should be executed only the first time + $mainThread = false; } + 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")) { - define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP); - } + // Build parameters + $arrayOptTranslation = [ + 'updateXml' => $updateXmlForms, + 'updateMafe' => $updateMafe + ]; + $optionMigrateHistoryData = [ + 'keepDynContent' => $keepDynContent + ]; - if (!defined('DB_ADAPTER')) { - define('DB_ADAPTER', 'mysql'); - } - - 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); + // Upgrade database and files from a specific workspace + $workspace->upgrade($workspace->name, true, SYS_LANG, $arrayOptTranslation, $optionMigrateHistoryData); $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; + } else { + // Build arguments + $args = '--child'; + $args .= $updateXmlForms ? '' : ' --no-xml'; + $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. - CLI::logging("\nCheck/Fix serialized instance in serverConf.singleton file\n\n"); - $serverConf = ServerConf::getSingleton(); - $serverConf->updateClassNameInFile(); + if ($printHF) { + // Print information when finish the upgrade process + CLI::logging('UPGRADE FINISHED (Completed on ' . (microtime(true) - $globalStartTime) . + ' seconds), ProcessMaker ' . System::getVersion() . ' installed)' . "\n\n"); - // SAVE Upgrades/Patches - $arrayPatch = glob(PATH_TRUNK . 'patch-*'); - - 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'); + // Delete upgrade flag + G::isPMUnderUpdating(0); } - - //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) { diff --git a/workflow/engine/bin/tasks/cliWorkspaces.php b/workflow/engine/bin/tasks/cliWorkspaces.php index 13df97e38..518d9d5a5 100644 --- a/workflow/engine/bin/tasks/cliWorkspaces.php +++ b/workflow/engine/bin/tasks/cliWorkspaces.php @@ -106,26 +106,6 @@ EOT CLI::taskArg('workspace', true, true); CLI::taskRun("run_plugins_database_upgrade"); -CLI::taskName('workspace-upgrade'); -CLI::taskDescription(<<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 * 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) { print_r('Regenerating content in: ' . pakeColor::colorize($workspace->name, 'INFO') . "\n"); CLI::logging("-> Regenerating content \n"); - $workspace->migrateContentRun($workspace->name, $lang); + $workspace->migrateContentRun($lang); } $stop = microtime(true); CLI::logging("<*> Optimizing content data Process took " . ($stop - $start) . " seconds.\n"); diff --git a/workflow/engine/classes/Upgrade.php b/workflow/engine/classes/Upgrade.php deleted file mode 100644 index 67fa51dcf..000000000 --- a/workflow/engine/classes/Upgrade.php +++ /dev/null @@ -1,128 +0,0 @@ -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; - } - -} diff --git a/workflow/engine/classes/WorkspaceTools.php b/workflow/engine/classes/WorkspaceTools.php index 62a3713a5..cdd9e075e 100644 --- a/workflow/engine/classes/WorkspaceTools.php +++ b/workflow/engine/classes/WorkspaceTools.php @@ -218,160 +218,115 @@ class WorkspaceTools /** * Upgrade this workspace to the latest system version * - * @param bool $buildCacheView - * @param string $workSpace + * @param string $workspace * @param bool $onedb * @param string $lang * @param array $arrayOptTranslation + * @param array $optionMigrateHistoryData * * @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)) { $arrayOptTranslation = ['updateXml' => true, 'updateMafe' => true]; } + CLI::logging("* Start updating database schema...\n"); $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); - $stop = microtime(true); - CLI::logging("<*> Database Upgrade Process took " . ($stop - $start) . " seconds.\n"); + CLI::logging("* End updating database schema...(Completed on " . (microtime(true) - $start) . " seconds)\n"); + CLI::logging("* Start updating translations...\n"); $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']); - $stop = microtime(true); - $final = $stop - $start; - CLI::logging("<*> Updating Translations Process took $final seconds.\n"); + CLI::logging("* End updating translations...(Completed on " . (microtime(true) - $start) . " 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); - CLI::logging("> Updating Content...\n"); - $this->upgradeContent($workSpace); - $stop = microtime(true); - $final = $stop - $start; - CLI::logging("<*> Updating Content Process took $final seconds.\n"); + CLI::logging("* Start to migrate texts/values from 'CONTENT' table to the corresponding object tables...\n"); + $this->migrateContent($lang); + CLI::logging("* End to migrate texts/values from 'CONTENT' table to the corresponding object tables... (Completed on " . + (microtime(true) - $start) . " seconds)\n"); + CLI::logging("* Start updating rows in Web Entry table for classic processes...\n"); $start = microtime(true); - CLI::logging("> Check Mafe Requirements...\n"); - $this->checkMafeRequirements($workSpace, $lang); - $stop = microtime(true); - $final = $stop - $start; - CLI::logging("<*> Check Mafe Requirements Process took $final seconds.\n"); + $this->updatingWebEntryClassicModel(true); + CLI::logging("* End updating rows in Web Entry table for classic processes...(Completed on " . + (microtime(true) - $start) . " seconds)\n"); + CLI::logging("* Start to update Files Manager...\n"); $start = microtime(true); - CLI::logging("> Updating Triggers...\n"); - $this->updateTriggers(true, $lang); - $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"); + $this->processFilesUpgrade($workspace); + CLI::logging("* End to update Files Manager... (Completed on " . (microtime(true) - $start) . " seconds)\n"); /*----------------------------------********---------------------------------*/ + CLI::logging("* Start migrating to new list tables...\n"); $start = microtime(true); - CLI::logging("> Migrate new lists...\n"); - $this->migrateList($workSpace, false, $lang); - $stop = microtime(true); - $final = $stop - $start; - CLI::logging("<*> Migrate new lists Process took $final seconds.\n"); + $this->migrateList(true, $lang); + CLI::logging("* End migrating to new list tables...(Completed on " . (microtime(true) - $start) . " seconds)\n"); /*----------------------------------********---------------------------------*/ + CLI::logging("* Start migrating and populating plugin singleton data...\n"); $start = microtime(true); - CLI::logging("> Updating Files Manager...\n"); - $this->processFilesUpgrade(); - $stop = microtime(true); - CLI::logging("<*> Updating Files Manager took " . ($stop - $start) . " seconds.\n"); + $this->migrateSingleton($workspace); + CLI::logging("* End migrating and populating plugin singleton data...(Completed on " . + (microtime(true) - $start) . " seconds)\n"); + CLI::logging("* Start cleaning expired tokens...\n"); $start = microtime(true); - CLI::logging("> Clean access and refresh tokens...\n"); - $this->cleanTokens($workSpace); - $stop = microtime(true); - CLI::logging("<*> Clean access and refresh tokens took " . ($stop - $start) . " seconds.\n"); + $this->cleanTokens(); + CLI::logging("* End cleaning expired tokens...(Completed on " . (microtime(true) - $start) . " seconds)\n"); + CLI::logging("* Start to check Intermediate Email Event...\n"); $start = microtime(true); - CLI::logging("> Optimizing Self-Service data...\n"); - $this->migrateSelfServiceRecordsRun($workSpace); - $stop = microtime(true); - CLI::logging("<*> Migrating Self-Service records Process took " . ($stop - $start) . " seconds.\n"); + $this->checkIntermediateEmailEvent(); + CLI::logging("* End to check Intermediate Email Event... (Completed on " . (microtime(true) - $start) . " seconds)\n"); + CLI::logging("* Start cleaning DYN_CONTENT in APP_HISTORY...\n"); $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; - //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); - $stop = microtime(true); - CLI::logging("<*> Clearing History of Use from APP_HISTORY table took " . ($stop - $start) . " seconds.\n"); + CLI::logging("* End cleaning DYN_CONTENT in APP_HISTORY...(Completed on " . (microtime(true) - $start) . " seconds)\n"); /*----------------------------------********---------------------------------*/ + CLI::logging("* Start migrating history data...\n"); $start = microtime(true); - CLI::logging("> Migrating history data...\n"); - $this->migrateAppHistoryToAppDataChangeLog(false); - $stop = microtime(true); - CLI::logging("<*> Migrating history data took " . ($stop - $start) . " seconds.\n"); + $this->migrateAppHistoryToAppDataChangeLog(true); + CLI::logging("* End migrating history data...(Completed on " . (microtime(true) - $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); - CLI::logging("> Optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP....\n"); $this->upgradeSelfServiceData(); - $stop = microtime(true); - CLI::logging("<*> Optimizing Self-Service data in table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP took " . ($stop - $start) . " seconds.\n"); + CLI::logging("* End adding new fields and populating values in tables related to feature self service by value...(Completed on " . + (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"); } + /** + * Update the email events with the current email server + */ public function checkIntermediateEmailEvent() { $oEmailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); @@ -629,9 +587,11 @@ class WorkspaceTools } /** - * Upgrade this workspace Content. + * Upgrade this workspace Content + * * @param string $workspace * @param boolean $executeRegenerateContent + * * @return void */ 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 $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 - * @return array bool upgradeSchema for more information + * @param bool $onedb Was installed in one DB or not + * @param bool $checkOnly Only check if the upgrade is needed if true + * + * @return bool upgradeSchema */ public function upgradeDatabase($onedb = false, $checkOnly = false) { @@ -2173,6 +2135,9 @@ class WorkspaceTools return $result; } + /** + * Backup the log files + */ public function backupLogFiles() { $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) { $this->initPropel(true); @@ -2265,9 +2236,8 @@ class WorkspaceTools return true; } - public function verifyFilesOldEnterprise($workspace) + public function verifyFilesOldEnterprise() { - $this->initPropel(true); $pathBackup = PATH_DATA . 'backups'; if (!file_exists($pathBackup)) { G::mk_dir($pathBackup, 0777); @@ -2381,12 +2351,12 @@ class WorkspaceTools /** * Migrate all cases to New list * - * @param string $workSpace Workspace * @param bool $flagReinsert Flag that specifies the re-insertion + * @param string $lang * * @return void */ - public function migrateList($workSpace, $flagReinsert = false, $lang = 'en') + public function migrateList($flagReinsert = false, $lang = 'en') { $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 */ - public function processFilesUpgrade() + public function processFilesUpgrade($workspace) { try { 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")) { - 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); @@ -3559,8 +3531,12 @@ class WorkspaceTools 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')) { 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 = $this->migrateContentRun($workspace, $lang, $blackList); + $blackList = $this->migrateContentRun($lang, $blackList); $data["CFG_UID"] = 'MIGRATED_CONTENT'; $data["OBJ_UID"] = 'content'; $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 */ - 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')) { define('MEMCACHED_ENABLED', false); @@ -3662,7 +3639,10 @@ class WorkspaceTools return $blackList; } - public function cleanTokens($workspace, $lang = SYS_LANG) + /** + * Clean the expired access and refresh tokens + */ + public function cleanTokens() { $this->initPropel(true); $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 $this->initPropel(true); @@ -3797,7 +3780,10 @@ class WorkspaceTools 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 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 * is done to verify the execution of php files generated when the WebEntry * 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 do not go through again. @@ -4160,8 +4147,9 @@ class WorkspaceTools /** * Updating triggers - * @param $flagRecreate - * @param $lang + * + * @param bool $flagRecreate + * @param string $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 */ 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 = [ PATH_DATA . 'framework' => 0770, PATH_DATA . 'framework' . DIRECTORY_SEPARATOR . 'cache' => 0770, diff --git a/workflow/engine/classes/model/AddonsManager.php b/workflow/engine/classes/model/AddonsManager.php index 06d16fedb..10691d3ac 100644 --- a/workflow/engine/classes/model/AddonsManager.php +++ b/workflow/engine/classes/model/AddonsManager.php @@ -385,13 +385,7 @@ class AddonsManager extends BaseAddonsManager $this->setState(); } else { - if ($this->getAddonType() == "core") { - $upgrade = new Upgrade($this); - - $upgrade->install(); - } else { - throw new Exception("Addon type {$this->getAddonType()} not supported."); - } + throw new Exception("Addon type {$this->getAddonType()} not supported."); } } diff --git a/workflow/engine/src/ProcessMaker/Core/System.php b/workflow/engine/src/ProcessMaker/Core/System.php index 36e3061ed..15e957e7d 100644 --- a/workflow/engine/src/ProcessMaker/Core/System.php +++ b/workflow/engine/src/ProcessMaker/Core/System.php @@ -243,39 +243,6 @@ class System 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 *