diff --git a/workflow/engine/bin/tasks/cliWorkspaces.php b/workflow/engine/bin/tasks/cliWorkspaces.php index 1fa5580d2..46637a332 100644 --- a/workflow/engine/bin/tasks/cliWorkspaces.php +++ b/workflow/engine/bin/tasks/cliWorkspaces.php @@ -1,5 +1,6 @@ getMessage() . PHP_EOL . PHP_EOL); } } + +/** + * Convert Web Entries v1.0 to v2.0 for BPMN processes in order to deprecate the old version. + * + * @param array $args + */ +function convert_old_web_entries($args) +{ + try { + if (!empty($args)) { + // Print initial message + $start = microtime(true); + CLI::logging("> Converting Web Entries v1.0 to v2.0 for BPMN processes...\n"); + + // Set workspace constants and initialize DB connection + Bootstrap::setConstantsRelatedWs($args[0]); + Propel::init(PATH_CONFIG . 'databases.php'); + + // Convert Web Entries + WebEntry::convertFromV1ToV2(); + + // Print last message + $stop = microtime(true); + CLI::logging("<*> Converting Web Entries v1.0 to v2.0 for BPMN processes data took " . ($stop - $start) . " seconds.\n"); + } else { + // If a workspace is not specified, get all available workspaces in the server + $workspaces = get_workspaces_from_args($args); + + // Execute the command for each workspace + foreach ($workspaces as $workspace) { + passthru(PHP_BINARY . ' processmaker convert-old-web-entries ' . $workspace->name); + } + } + } catch (Exception $e) { + // Display the error message + CLI::logging($e->getMessage() . PHP_EOL . PHP_EOL); + } +} diff --git a/workflow/engine/classes/WorkspaceTools.php b/workflow/engine/classes/WorkspaceTools.php index 9e1abb024..3d4940213 100644 --- a/workflow/engine/classes/WorkspaceTools.php +++ b/workflow/engine/classes/WorkspaceTools.php @@ -7,6 +7,7 @@ use ProcessMaker\BusinessModel\Process as BmProcess; /*----------------------------------********---------------------------------*/ use ProcessMaker\ChangeLog\ChangeLog; /*----------------------------------********---------------------------------*/ +use ProcessMaker\BusinessModel\WebEntry; use ProcessMaker\Core\Installer; use ProcessMaker\Core\ProcessesManager; use ProcessMaker\Core\System; @@ -364,6 +365,13 @@ class WorkspaceTools $start = microtime(true); $this->updateTriggers(true, $lang); CLI::logging("* End updating MySQL triggers...(" . (microtime(true) - $start) . " seconds)\n"); + + CLI::logging("* Start Converting Web Entries v1.0 to v2.0 for BPMN processes...\n"); + $start = microtime(true); + Bootstrap::setConstantsRelatedWs($workspace); + Propel::init(PATH_CONFIG . 'databases.php'); + WebEntry::convertFromV1ToV2(); + CLI::logging("* End converting Web Entries v1.0 to v2.0 for BPMN processes...(" . (microtime(true) - $start) . " seconds)\n"); } /** @@ -2209,6 +2217,13 @@ class WorkspaceTools $start = microtime(true); $workspace->updateTriggers(true, $lang); CLI::logging("* End updating MySQL triggers...(" . (microtime(true) - $start) . " seconds)\n"); + + CLI::logging("* Start Converting Web Entries v1.0 to v2.0 for BPMN processes...\n"); + $start = microtime(true); + Bootstrap::setConstantsRelatedWs($workspace); + Propel::init(PATH_CONFIG . 'databases.php'); + WebEntry::convertFromV1ToV2(); + CLI::logging("* End converting Web Entries v1.0 to v2.0 for BPMN processes...(" . (microtime(true) - $start) . " seconds)\n"); } CLI::logging("> Start To Verify License Enterprise...\n"); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php index 8dc69e36d..c9b8b7ef2 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php @@ -1168,5 +1168,26 @@ class WebEntry return $appNumber; } } -} + /** + * Convert Web Entries v1.0 to v2.0 + */ + public static function convertFromV1ToV2() + { + // Build query + $sql = "UPDATE + `WEB_ENTRY` + LEFT JOIN + `BPMN_PROCESS` + ON + (`WEB_ENTRY`.`PRO_UID` = `BPMN_PROCESS`.`PRJ_UID`) + SET + `WEB_ENTRY`.`DYN_UID` = '', `WEB_ENTRY`.`WE_TYPE` = 'MULTIPLE' + WHERE + `WE_TYPE` = 'SINGLE' AND `WE_AUTHENTICATION` = 'ANONYMOUS' AND + `WE_CALLBACK` = 'PROCESSMAKER' AND `BPMN_PROCESS`.`PRJ_UID` IS NOT NULL"; + + // Execute query + DB::connection('workflow')->statement($sql); + } +}