From 8a5d44a8c7909d572d2309e114d1e379d1e28fd9 Mon Sep 17 00:00:00 2001 From: ricardo Date: Mon, 29 Jun 2015 11:27:34 -0400 Subject: [PATCH 1/8] 0017676: Change warning message in the output of the "processmaker workspace-restore" command.SOLVED al realizar el comando ./processmaker workspace-restore daba un mensaje que no era lo suficientemente claro se soluciono haciendo el cambio del texto en el archivo class.wsTools.php y corrigiendo con backslash para el uso de variables --- workflow/engine/classes/class.wsTools.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index 1b10c32d3..0fd712208 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -1564,9 +1564,11 @@ class workspaceTools $version = explode('-', $version); $versionPresent = ( isset($version[0])) ? $version[0] : ''; CLI::logging(CLI::warning(" - Note.- If you try to execute a restore from a generated backup on a recent version of Processmaker - than version you are using currently to restore it, it may be occur errors on the restore process, - it shouldn't be restaured generated backups on later versions than version when the restore is executed") . "\n"); + Warning: A workspace from a newer version of ProcessMaker can NOT be restored in an older version of + ProcessMaker. For example, restoring from v.3.0 to v.2.5 will not work. However, it may be possible + to restore a workspace from an older version to an newer version of ProcessMaker, although error + messages may be displayed during the restore process. Make sure to run the \"processmaker cacheview-repair\" + and \"processmaker migrate-new-cases-lists\" commands after restoring a workspace.") . "\n"); foreach ($metaFiles as $metaFile) { $metadata = G::json_decode(file_get_contents($metaFile)); From 7d5a4394d495c05125508c4a9eb5320ddb60f707 Mon Sep 17 00:00:00 2001 From: ricardo Date: Mon, 29 Jun 2015 13:57:30 -0400 Subject: [PATCH 2/8] 0017680: "processmaker workspace-restore" tries to restore when no workspace is specified SOLVED al colocar el comando de restore sin un workspace daba un error poco entendible se soluciono agregando una condicion con la cual si al ingresar el comando sin especificar el nombre del workspace votara un mensaje diciendo que falta especificar el workspace --- workflow/engine/bin/tasks/cliWorkspaces.php | 81 +++++++++++---------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/workflow/engine/bin/tasks/cliWorkspaces.php b/workflow/engine/bin/tasks/cliWorkspaces.php index 689392806..8dc2477b1 100755 --- a/workflow/engine/bin/tasks/cliWorkspaces.php +++ b/workflow/engine/bin/tasks/cliWorkspaces.php @@ -505,47 +505,52 @@ function run_workspace_backup($args, $opts) { } function run_workspace_restore($args, $opts) { - $filename = $args[0]; + if (sizeof($args) > 0) { - G::verifyPath(PATH_DATA . 'upgrade', true); + $filename = $args[0]; - if (strpos($filename, "/") === false && strpos($filename, '\\') === false) { - $filename = PATH_DATA . "backups/$filename"; - if (!file_exists($filename) && substr_compare($filename, ".tar", -4, 4, true) != 0) - $filename .= ".tar"; - } - $info = array_key_exists("info", $opts); - $lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en'; - $port = array_key_exists("port", $opts) ? $opts['port'] : ''; - if ($info) { - workspaceTools::getBackupInfo($filename); + G::verifyPath(PATH_DATA . 'upgrade', true); + + if (strpos($filename, "/") === false && strpos($filename, '\\') === false) { + $filename = PATH_DATA . "backups/$filename"; + if (!file_exists($filename) && substr_compare($filename, ".tar", -4, 4, true) != 0) + $filename .= ".tar"; + } + $info = array_key_exists("info", $opts); + $lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en'; + $port = array_key_exists("port", $opts) ? $opts['port'] : ''; + if ($info) { + workspaceTools::getBackupInfo($filename); + } else { + CLI::logging("Restoring from $filename\n"); + $workspace = array_key_exists("workspace", $opts) ? $opts['workspace'] : NULL; + $overwrite = array_key_exists("overwrite", $opts); + $multiple = array_key_exists("multiple", $opts); + $dstWorkspace = isset($args[1]) ? $args[1] : null; + if(!empty($multiple)){ + if(!Bootstrap::isLinuxOs()){ + CLI::error("This is not a Linux enviroment, cannot use this multiple [-m] feature.\n"); + return; + } + multipleFilesBackup::letsRestore ($filename,$workspace,$dstWorkspace,$overwrite); + } + else{ + $anotherExtention = ".*"; //if there are files with and extra extention: e.g. .tar.number + $multiplefiles = glob($filename . $anotherExtention);// example: //shared/workflow_data/backups/myWorkspace.tar.* + if(count($multiplefiles) > 0) + { + CLI::error("Processmaker found these files: .\n"); + foreach($multiplefiles as $index => $value){ + CLI::logging($value . "\n"); + } + CLI::error("Please, you should use -m parameter to restore them.\n"); + return; + } + workspaceTools::restore($filename, $workspace, $dstWorkspace, $overwrite, $lang, $port ); + } + } } else { - CLI::logging("Restoring from $filename\n"); - $workspace = array_key_exists("workspace", $opts) ? $opts['workspace'] : NULL; - $overwrite = array_key_exists("overwrite", $opts); - $multiple = array_key_exists("multiple", $opts); - $dstWorkspace = isset($args[1]) ? $args[1] : null; - if(!empty($multiple)){ - if(!Bootstrap::isLinuxOs()){ - CLI::error("This is not a Linux enviroment, cannot use this multiple [-m] feature.\n"); - return; - } - multipleFilesBackup::letsRestore ($filename,$workspace,$dstWorkspace,$overwrite); - } - else{ - $anotherExtention = ".*"; //if there are files with and extra extention: e.g. .tar.number - $multiplefiles = glob($filename . $anotherExtention);// example: //shared/workflow_data/backups/myWorkspace.tar.* - if(count($multiplefiles) > 0) - { - CLI::error("Processmaker found these files: .\n"); - foreach($multiplefiles as $index => $value){ - CLI::logging($value . "\n"); - } - CLI::error("Please, you should use -m parameter to restore them.\n"); - return; - } - workspaceTools::restore($filename, $workspace, $dstWorkspace, $overwrite, $lang, $port ); - } + throw new Exception("No workspace specified for restore"); } } From 804a03502ad5646400b8cd45d07c3de7d5bf2109 Mon Sep 17 00:00:00 2001 From: "marcelo.cuiza" Date: Tue, 30 Jun 2015 11:28:53 -0400 Subject: [PATCH 3/8] PM-2903 0017516: Unable to add condition on basis of checkbox Causa: Al no tener un valor previo asignado a la variable de caso para la condicion del dynaform, no se cumple y por ende no se muestra el mismo. Solucion: se debe asignar un valor a la variable de caso en un trigger antes del dynaform. --- workflow/engine/methods/cases/cases_Open.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/workflow/engine/methods/cases/cases_Open.php b/workflow/engine/methods/cases/cases_Open.php index f279a9bf6..27e43ba7b 100755 --- a/workflow/engine/methods/cases/cases_Open.php +++ b/workflow/engine/methods/cases/cases_Open.php @@ -169,6 +169,14 @@ try { /* Redirect to next step */ unset( $_SESSION['bNoShowSteps'] ); + + /* Execute Before Triggers for first Task*/ + $oStep = new Step; + $oStep = $oStep->loadByProcessTaskPosition($_SESSION['PROCESS'], $_SESSION['TASK'], 1); + $triggerFields["APP_DATA"] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $oStep->getStepTypeObj(), $oStep->getStepUidObj(), 'BEFORE', $aFields['APP_DATA'] ); + $oCase->updateCase( $_SESSION['APPLICATION'], $triggerFields ); + /*end Execute Before Triggers for first Task*/ + $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); $sPage = $aNextStep['PAGE']; G::header( 'location: ' . $sPage ); From 552aadef47097ec8992cd285c0ca1965f0cbccf3 Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 30 Jun 2015 16:13:30 -0400 Subject: [PATCH 4/8] 0017667: The command "processmaker help OPTION" shows PHP warnings if the option doesn't exist SOLVED al ejecutar el comando processmaker help con una opcion que no existia daba un error que no era entendible para el usuario se soluciono agregando un array que jala todas las opciones y una condicion que al dar cualquier opcion que no este listada dira que no existe --- workflow/engine/classes/class.cli.php | 40 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/workflow/engine/classes/class.cli.php b/workflow/engine/classes/class.cli.php index 21b0c7077..b26865a09 100755 --- a/workflow/engine/classes/class.cli.php +++ b/workflow/engine/classes/class.cli.php @@ -150,17 +150,36 @@ class CLI $tasks = join( "\n", $tasks ); echo $tasks . "\n\n"; } else { - $valid_args = array (); - foreach (self::$tasks[$taskName]['args'] as $arg => $data) { - $arg = strtoupper( $arg ); - if ($data['multiple']) { - $arg = "$arg..."; - } - if ($data['optional']) { - $arg = "[$arg]"; - } - $valid_args[] = $arg; + $options = array(); + $tasks = array(); + ksort( self::$tasks ); + foreach (self::$tasks as $name => $data) { + $description = explode( "\n", $data['description'] ); + $options[] = "$name"; } + if (!in_array($taskName, $options)) { + echo "\nThe task does not exist \n"; + echo "Use one of the following tasks:\n"; + $tasks = array (); + ksort( self::$tasks ); + foreach (self::$tasks as $name => $data) { + $description = explode( "\n", $data['description'] ); + $tasks[] = " $name"; + } + $tasks = join( "\n", $tasks ); + echo $tasks . "\n\n"; + } else{ + $valid_args = array (); + foreach (self::$tasks[$taskName]['args'] as $arg => $data) { + $arg = strtoupper( $arg ); + if ($data['multiple']) { + $arg = "$arg..."; + } + if ($data['optional']) { + $arg = "[$arg]"; + } + $valid_args[] = $arg; + } $valid_args = join( " ", $valid_args ); $description = explode( "\n", self::$tasks[$taskName]['description'] ); $taskDescription = trim( array_shift( $description ) ); @@ -195,6 +214,7 @@ EOT; } echo $message . "\n"; } + } } /** From 3aff1c0ae23e2e47ccec7a1cb96c09fab78f1ac9 Mon Sep 17 00:00:00 2001 From: ricardo Date: Wed, 1 Jul 2015 09:16:33 -0400 Subject: [PATCH 5/8] 0017692: "temporing up" in output of "processmaker workspace-backup" is not English (or any other language) SOLVED al ejecutar el comando de backup daba un mensaje con una palabra que no existe en ingles se soluciono sacando esa palabra y colocando otra que se acomoda mejor --- .../classes/class.multipleFilesBackup.php | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/workflow/engine/classes/class.multipleFilesBackup.php b/workflow/engine/classes/class.multipleFilesBackup.php index fa955c7bc..dc8b5bcae 100644 --- a/workflow/engine/classes/class.multipleFilesBackup.php +++ b/workflow/engine/classes/class.multipleFilesBackup.php @@ -14,14 +14,14 @@ class multipleFilesBackup private $dir_to_compress = ""; private $filename = "backUpProcessMaker.tar"; private $fileSize = "1000"; - // 1 GB by default. + // 1 GB by default. private $sizeDescriptor = "m"; - //megabytes + //megabytes private $tempDirectories = array (); - /* Constructor - * @filename contains the path and filename of the comppress file(s). - * @size got the Max size of the compressed files, by default if the $size less to zero will mantains 1000 Mb as Max size. + /* Constructor + * @filename contains the path and filename of the comppress file(s). + * @size got the Max size of the compressed files, by default if the $size less to zero will mantains 1000 Mb as Max size. */ public function multipleFilesBackup ($filename, $size) { @@ -33,24 +33,24 @@ class multipleFilesBackup } } - /* Gets workspace information enough to make its backup. + /* Gets workspace information enough to make its backup. * @workspace contains the workspace to be add to the commpression process. */ public function addToBackup ($workspace) { - //verifing if workspace exists. + //verifing if workspace exists. if (! $workspace->workspaceExists()) { echo "Workspace {$workspace->name} not found\n"; return false; } - //create destination path + //create destination path if (! file_exists( PATH_DATA . "upgrade/" )) { mkdir( PATH_DATA . "upgrade/" ); } $tempDirectory = PATH_DATA . "upgrade/" . basename( tempnam( __FILE__, '' ) ); mkdir( $tempDirectory ); $metadata = $workspace->getMetadata(); - CLI::logging( "Temporing up database...\n" ); + CLI::logging( "Creating temporary files on database...\n" ); $metadata["databases"] = $workspace->exportDatabase( $tempDirectory ); $metadata["directories"] = array ("{$workspace->name}.files"); $metadata["version"] = 1; @@ -65,8 +65,8 @@ class multipleFilesBackup $this->tempDirectories[] = $tempDirectory; } - /* Add a directory containing Db files or info files to be commpressed - * @directory the name and path of the directory to be add to the commpression process. + /* Add a directory containing Db files or info files to be commpressed + * @directory the name and path of the directory to be add to the commpression process. */ private function addDirToBackup ($directory) { @@ -75,37 +75,37 @@ class multipleFilesBackup } } - // Commpress the DB and files into a single or several files with numerical series extentions + // Commpress the DB and files into a single or several files with numerical series extentions public function letsBackup () { - // creating command + // creating command $CommpressCommand = "tar czv "; $CommpressCommand .= $this->dir_to_compress; $CommpressCommand .= "| split -b "; $CommpressCommand .= $this->fileSize; $CommpressCommand .= "m -d - "; $CommpressCommand .= $this->filename . "."; - //executing command to create the files + //executing command to create the files echo exec( $CommpressCommand ); - //Remove leftovers dirs. + //Remove leftovers dirs. foreach ($this->tempDirectories as $tempDirectory) { CLI::logging( "Deleting: " . $tempDirectory . "\n" ); G::rm_dir( $tempDirectory ); } } - /* Restore from file(s) commpressed by letsBackup function, into a temporary directory - * @ filename got the name and path of the compressed file(s), if there are many files with file extention as a numerical series, the extention should be discriminated. - * @ srcWorkspace contains the workspace to be restored. - * @ dstWorkspace contains the workspace to be overwriting. - * @ overwrite got the option true if the workspace will be overwrite. + /* Restore from file(s) commpressed by letsBackup function, into a temporary directory + * @ filename got the name and path of the compressed file(s), if there are many files with file extention as a numerical series, the extention should be discriminated. + * @ srcWorkspace contains the workspace to be restored. + * @ dstWorkspace contains the workspace to be overwriting. + * @ overwrite got the option true if the workspace will be overwrite. */ static public function letsRestore ($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true) { - // Needed info: - // TEMPDIR /shared/workflow_data/upgrade/ - // BACKUPS /shared/workflow_data/backups/ - // Creating command cat myfiles_split.tgz_* | tar xz + // Needed info: + // TEMPDIR /shared/workflow_data/upgrade/ + // BACKUPS /shared/workflow_data/backups/ + // Creating command cat myfiles_split.tgz_* | tar xz $DecommpressCommand = "cat " . $filename . ".* "; $DecommpressCommand .= " | tar xzv"; @@ -116,13 +116,13 @@ class multipleFilesBackup } else { throw new Exception( "Could not create directory:" . $parentDirectory ); } - //Extract all backup files, including database scripts and workspace files + //Extract all backup files, including database scripts and workspace files CLI::logging( "Restoring into " . $tempDirectory . "\n" ); chdir( $tempDirectory ); echo exec( $DecommpressCommand ); CLI::logging( "\nUncompressed into: " . $tempDirectory . "\n" ); - //Search for metafiles in the new standard (the old standard would contain meta files. + //Search for metafiles in the new standard (the old standard would contain meta files. $metaFiles = glob( $tempDirectory . "/*.meta" ); if (empty( $metaFiles )) { $metaFiles = glob( $tempDirectory . "/*.txt" ); From 125477c0b186e94c1baaf5ef50e7679467a6d870 Mon Sep 17 00:00:00 2001 From: "marcelo.cuiza" Date: Fri, 3 Jul 2015 10:43:53 -0400 Subject: [PATCH 6/8] PM-3076 17657: Issue while searching using case id in - Process Supervisor -> Review Causa: al uid de la tarea de le concatena un caracter demas Solucion: se valido el manejo de uid corectos --- workflow/engine/classes/class.case.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 5d9983008..c651f551e 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -594,7 +594,11 @@ class Cases $aFields['CURRENT_USER'][]= $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname(); $aFields['TAS_UID'].= $value['TAS_UID'].'-'; } - $aFields['CURRENT_USER'] = implode(" - ", array_values($aFields['CURRENT_USER'])); + $aFields['CURRENT_USER'] = implode(" - ", array_values($aFields['CURRENT_USER'])); + $tasksArray = array_filter(explode("-",$aFields['TAS_UID'])); + if(count($tasksArray) == 1) { + $aFields['TAS_UID'] = $tasksArray[0]; + } } else { $oCurUser->load($aAppDel['USR_UID']); $aFields['CURRENT_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname(); From a28308550b750d1631a4fa5c15e81c6be603804b Mon Sep 17 00:00:00 2001 From: "marcelo.cuiza" Date: Fri, 3 Jul 2015 10:52:52 -0400 Subject: [PATCH 7/8] PM-2903 0017516: Unable to add condition on basis of checkbox Causa: Al no tener un valor previo asignado a la variable de caso para la condicion del dynaform, no se cumple y por ende no se muestra el mismo. Solucion: se debe asignar un valor a la variable de caso en un trigger antes del dynaform. --- workflow/engine/methods/cases/cases_Open.php | 1 + workflow/engine/methods/cases/cases_Step.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/workflow/engine/methods/cases/cases_Open.php b/workflow/engine/methods/cases/cases_Open.php index 27e43ba7b..c4a3bd4f4 100755 --- a/workflow/engine/methods/cases/cases_Open.php +++ b/workflow/engine/methods/cases/cases_Open.php @@ -175,6 +175,7 @@ try { $oStep = $oStep->loadByProcessTaskPosition($_SESSION['PROCESS'], $_SESSION['TASK'], 1); $triggerFields["APP_DATA"] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $oStep->getStepTypeObj(), $oStep->getStepUidObj(), 'BEFORE', $aFields['APP_DATA'] ); $oCase->updateCase( $_SESSION['APPLICATION'], $triggerFields ); + $_SESSION['beforeTriggersExecuted'] = true; /*end Execute Before Triggers for first Task*/ $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index 1e42bf69e..1c6cb6da0 100755 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -159,7 +159,11 @@ if ($flagExecuteBeforeTriggers) { if (! isset( $_SESSION['_NO_EXECUTE_TRIGGERS_'] )) { //Execute before triggers - Start - $Fields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $_GET['TYPE'], $_GET['UID'], 'BEFORE', $Fields['APP_DATA'] ); + if (!isset($_SESSION['beforeTriggersExecuted'])) { + $Fields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $_GET['TYPE'], $_GET['UID'], 'BEFORE', $Fields['APP_DATA'] ); + } else { + unset($_SESSION['beforeTriggersExecuted']); + } //Execute before triggers - End } else { unset( $_SESSION['_NO_EXECUTE_TRIGGERS_'] ); From 5215d733dca0788e7287752844a98d1a5b5a3c6f Mon Sep 17 00:00:00 2001 From: "marcelo.cuiza" Date: Mon, 6 Jul 2015 11:18:29 -0400 Subject: [PATCH 8/8] PM-2903 validacion --- workflow/engine/methods/cases/cases_Open.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/workflow/engine/methods/cases/cases_Open.php b/workflow/engine/methods/cases/cases_Open.php index c4a3bd4f4..3f3f19d5b 100755 --- a/workflow/engine/methods/cases/cases_Open.php +++ b/workflow/engine/methods/cases/cases_Open.php @@ -173,9 +173,11 @@ try { /* Execute Before Triggers for first Task*/ $oStep = new Step; $oStep = $oStep->loadByProcessTaskPosition($_SESSION['PROCESS'], $_SESSION['TASK'], 1); - $triggerFields["APP_DATA"] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $oStep->getStepTypeObj(), $oStep->getStepUidObj(), 'BEFORE', $aFields['APP_DATA'] ); - $oCase->updateCase( $_SESSION['APPLICATION'], $triggerFields ); - $_SESSION['beforeTriggersExecuted'] = true; + if($oStep) { + $triggerFields["APP_DATA"] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $oStep->getStepTypeObj(), $oStep->getStepUidObj(), 'BEFORE', $aFields['APP_DATA'] ); + $oCase->updateCase( $_SESSION['APPLICATION'], $triggerFields ); + $_SESSION['beforeTriggersExecuted'] = true; + } /*end Execute Before Triggers for first Task*/ $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );