diff --git a/.gitignore b/.gitignore index f64f1a3d8..2babd91e8 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ test_shared/ **/cache/ storage/ phpunit.xml +!/workflow/engine/plugins/.gitignore \ No newline at end of file diff --git a/config/deprecatedFiles.lst b/config/deprecatedFiles.lst index e3cf34aa4..17af863d0 100644 --- a/config/deprecatedFiles.lst +++ b/config/deprecatedFiles.lst @@ -82,6 +82,11 @@ workflow/engine/methods/setup/webServices.php workflow/engine/methods/setup/webServicesAjax.php workflow/engine/methods/setup/webServicesList.php workflow/engine/methods/users/data_usersList.php +workflow/engine/plugins/charts.php +workflow/engine/plugins/charts/class.charts.php +workflow/engine/plugins/charts/config/setup.conf +workflow/engine/plugins/charts/genericCharts.php +workflow/engine/plugins/charts/setupPage.xml workflow/engine/plugins/openFlash.php workflow/engine/plugins/openFlash/chart-data.php workflow/engine/plugins/openFlash/chart.php @@ -103,6 +108,8 @@ workflow/engine/plugins/pmosCommunity/open_flash_chart_object.php workflow/engine/plugins/pmosCommunity/public_html/open-flash-chart.swf workflow/engine/plugins/pmosCommunity/public_html/swfobject.js workflow/engine/plugins/pmosCommunity/setupPage.xml +workflow/engine/plugins/processTemplate.php +workflow/engine/plugins/processTemplate/class.processTemplate.php workflow/engine/skinEngine/base/images/updating/page_background.png workflow/engine/skinEngine/neoclassic/images/updating/page_background.png workflow/engine/src/ProcessMaker/Services/Api/Test2.php @@ -122,4 +129,4 @@ workflow/engine/xmlform/cases/cases_ReassignBy.xml workflow/engine/xmlform/users/users_List.xml workflow/engine/xmlform/users/users_Options.xml workflow/public_html/skins/JSForms.js -workflow/public_html/skins/ajax.js +workflow/public_html/skins/ajax.js \ No newline at end of file diff --git a/gulliver/system/class.codeScanner.php b/gulliver/system/class.codeScanner.php index b87dcb976..e4f7bfe99 100644 --- a/gulliver/system/class.codeScanner.php +++ b/gulliver/system/class.codeScanner.php @@ -87,7 +87,9 @@ class CodeScanner if (file_exists($fileDisabledCode)) { $arrayAux = array_filter(array_map("trim", file($fileDisabledCode, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES))); - $arrayAux = array_filter($arrayAux, create_function("\$line", "return !preg_match(\"/^;.*\$/\", \$line);")); + $arrayAux = array_filter($arrayAux, function ($line) { + return !preg_match("/^;.*\$/", $line); + }); $this->arrayDisabledCode = array_unique(array_merge($this->arrayDisabledCode, $arrayAux)); } diff --git a/gulliver/system/class.controller.php b/gulliver/system/class.controller.php index 65d91a003..30e0d1ca7 100644 --- a/gulliver/system/class.controller.php +++ b/gulliver/system/class.controller.php @@ -77,12 +77,13 @@ class Controller */ public function __get($name) { + $message = 'Undefined property via __get(): ' . $name . ' in '; if (array_key_exists($name, $this->__data__)) { return $this->__data__[$name]; } $trace = debug_backtrace(); - trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); + trigger_error($message . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; } @@ -177,8 +178,8 @@ class Controller $this->__request__ = new stdclass(); } if (is_array($data)) { - while ($var = each($data)) { - $this->__request__->{$var['key']} = $var['value']; + foreach ($data as $key => $value) { + $this->__request__->{$key} = $value; } } else { $this->__request__ = $data; diff --git a/gulliver/system/class.form.php b/gulliver/system/class.form.php index 96cfb7cbb..e7acf358f 100644 --- a/gulliver/system/class.form.php +++ b/gulliver/system/class.form.php @@ -360,7 +360,7 @@ class Form extends XmlForm //Execute just if a query was set, it should be not empty if (trim($query) == "") { - continue; //if it is empty string skip it + break; //if it is empty string skip it } //We do the query to the external connection and we've got the label @@ -438,7 +438,7 @@ class Form extends XmlForm // execute just if a query was set, it should be not empty if (trim( $query ) == '') { - continue; //if it is empty string skip it + break; //if it is empty string skip it } //we do the query to the external connection and we've got the label @@ -491,7 +491,7 @@ class Form extends XmlForm //Execute just if a query was set, it should be not empty if (trim( $query ) == "") { //if it is empty string skip it - continue; + break; } $rs = $stmt->executeQuery( ResultSet::FETCHMODE_NUM ); diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php index b153f05a7..0317f4359 100644 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -758,7 +758,7 @@ class headPublisher $sjson = $oServerConf->getProperty($keyState); if ($sjson !== "") { $json = G::json_decode($sjson); - if ((is_array($json) || is_object($json)) && sizeof($json)){ + if (is_iterable($json)) { foreach ($json as $key => $value) { $views[$key] = $value; } diff --git a/gulliver/system/class.httpProxyController.php b/gulliver/system/class.httpProxyController.php index 8f4bdc04f..92db8abb7 100644 --- a/gulliver/system/class.httpProxyController.php +++ b/gulliver/system/class.httpProxyController.php @@ -142,8 +142,8 @@ class HttpProxyController public function setHttpRequestData($data) { if (is_array($data)) { - while ($var = each($data)) { - $this->__request__->{$var['key']} = $var['value']; + foreach ($data as $key => $value) { + $this->__request__->{$key} = $value; } } else { $this->__request__ = $data; diff --git a/gulliver/system/class.menu.php b/gulliver/system/class.menu.php index a4af06841..ca27dbfb5 100644 --- a/gulliver/system/class.menu.php +++ b/gulliver/system/class.menu.php @@ -48,7 +48,7 @@ class Menu { public $Id = null; - public $Options = null; + public $Options = []; public $Labels = null; public $Icons = null; public $JS = null; diff --git a/gulliver/system/class.phpSqlParser.php b/gulliver/system/class.phpSqlParser.php index eaa43187b..17fa0ac4f 100644 --- a/gulliver/system/class.phpSqlParser.php +++ b/gulliver/system/class.phpSqlParser.php @@ -876,6 +876,8 @@ EOREGEX; } break; } + + $shouldItContinue = false; switch ($upper) { case 'AS': $token_count ++; @@ -886,7 +888,7 @@ EOREGEX; ++ $n; } - continue; + $shouldItContinue = true; break; case 'INDEX': if ($token_category == 'CREATE') { @@ -908,12 +910,12 @@ EOREGEX; case 'OUTER': # $expression .= $token; $token_count ++; - continue; + $shouldItContinue = true; break; case 'FOR': $token_count ++; $skip_next = true; - continue; + $shouldItContinue = true; break; case 'LEFT': case 'RIGHT': @@ -969,7 +971,8 @@ EOREGEX; break; default: if ($token === false || empty( $token ) || $token === "") { - continue; + $shouldItContinue = true; + break; } if ($token_count == 0) { @@ -982,6 +985,9 @@ EOREGEX; $token_count ++; break; } + if ($shouldItContinue === true) { + continue; + } ++ $i; } if (substr( trim( $table ), 0, 1 ) == '(') { diff --git a/tests/unit/workflow/engine/classes/DerivationTest.php b/tests/unit/workflow/engine/classes/DerivationTest.php index ca42ee585..da821037e 100644 --- a/tests/unit/workflow/engine/classes/DerivationTest.php +++ b/tests/unit/workflow/engine/classes/DerivationTest.php @@ -2,7 +2,17 @@ namespace Tests\unit\workflow\engine\classes; -use \Derivation; +use Cases; +use Derivation; +use G; +use Illuminate\Support\Facades\DB; +use ProcessMaker\Model\Application; +use ProcessMaker\Model\Delegation; +use ProcessMaker\Model\Process; +use ProcessMaker\Model\Route; +use ProcessMaker\Model\Task; +use ProcessMaker\Model\TaskUser; +use ProcessMaker\Model\User; use Tests\TestCase; class DerivationTest extends TestCase @@ -15,6 +25,41 @@ class DerivationTest extends TestCase { parent::setUp(); // TODO: Change the autogenerated stub + // Truncate the APP_SEQUENCE table + DB::table('APP_SEQUENCE')->truncate(); + + config(["system.workspace" => "test"]); + $workspace = config("system.workspace"); + + if (!file_exists(PATH_DB . $workspace)) { + G::mk_dir(PATH_DB . $workspace); + } + + if (!file_exists(PATH_DB . $workspace . PATH_SEP . "db.php")) { + $myfile = fopen(PATH_DB . $workspace . PATH_SEP . "db.php", "w"); + fwrite($myfile, "assertObjectHasAttribute('name', $res['var3_label']); $this->assertEquals($res['var3_label'], (object)['Street' => 'test', 'name' => 'Something']); } + + /** + * It tests the doDerivation method sending variables synchronously + * + * @covers Derivation::doDerivation() + * @test + */ + public function it_should_test_the_do_derivation_method_sending_variables_synchronously() + { + // Create the models + $user = factory(User::class)->create(); + $process = factory(Process::class)->create([ + 'PRO_CREATE_USER' => $user->USR_UID + ]); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID, + ]); + $application = factory(Application::class)->create(); + $appDelegation = factory(Delegation::class)->create(); + + // Create the parameters + $currentDelegation = [ + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $appDelegation->DEL_INDEX, + 'ROU_TYPE' => '' + ]; + $nextDel = [ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + 'DEL_PRIORITY' => $appDelegation->DEL_PRIORITY, + 'TAS_ASSIGN_TYPE' => $task->TAS_ASSIGN_TYPE, + 'TAS_ID' => $task->TAS_ID + ]; + $appFields = [ + 'APP_NUMBER' => $application->APP_NUMBER, + 'DEL_THREAD' => $appDelegation->DEL_THREAD, + 'PRO_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + 'APP_DATA' => [], + 'APP_TITLE' => $application->APP_TITLE, + 'APP_UID' => $application->APP_UID + ]; + $sp = [ + 'SP_VARIABLES_OUT' => 'a:1:{s:6:"@&var1";s:6:"@&var2";}', + 'SP_VARIABLES_IN' => 'a:1:{s:6:"@&var2";s:6:"@&var3";}', + 'SP_SYNCHRONOUS' => '1', + 'SP_TYPE' => '', + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + ]; + + // Create the Derivation object + $der = new Derivation(); + $der->case = new Cases; + + // Call the doDerivation method + $res = $der->doDerivation($currentDelegation, $nextDel, $appFields, $sp); + + // Assert the new delegation index is 1 + $this->assertEquals(1, $res); + } + + /** + * It tests the doDerivation method sending variables asynchronously + * + * @covers Derivation::doDerivation() + * @test + */ + public function it_should_test_the_do_derivation_method_sending_variables_asynchronously() + { + // Create the models + $user = factory(User::class)->create(); + $process = factory(Process::class)->create([ + 'PRO_CREATE_USER' => $user->USR_UID + ]); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_USER' => $user->USR_UID + ]); + factory(TaskUser::class)->create([ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + ]); + $application = factory(Application::class)->create(); + $appDelegation = factory(Delegation::class)->create([ + 'TAS_UID' => $task->TAS_UID + ]); + factory(Route::class)->create([ + 'TAS_UID' => $task->TAS_UID, + 'ROU_NEXT_TASK' => $task->TAS_UID, + 'PRO_UID' => $process->PRO_UID + ]); + + // Create the parameters + $currentDelegation = [ + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $appDelegation->DEL_INDEX, + 'ROU_TYPE' => '', + 'TAS_UID' => $task->TAS_UID + ]; + $nextDel = [ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + 'DEL_PRIORITY' => $appDelegation->DEL_PRIORITY, + 'TAS_ASSIGN_TYPE' => $task->TAS_ASSIGN_TYPE, + 'TAS_ID' => $task->TAS_ID + ]; + $appFields = [ + 'APP_NUMBER' => $application->APP_NUMBER, + 'DEL_THREAD' => $appDelegation->DEL_THREAD, + 'PRO_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + 'APP_DATA' => [], + 'APP_TITLE' => $application->APP_TITLE, + 'APP_UID' => $application->APP_UID + ]; + $sp = [ + 'SP_VARIABLES_OUT' => 'a:1:{s:6:"@&var1";s:6:"@&var2";}', + 'SP_VARIABLES_IN' => 'a:1:{s:6:"@&var2";s:6:"@&var3";}', + 'SP_SYNCHRONOUS' => '0', + 'SP_TYPE' => '', + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + ]; + + // Create the Derivation object + $der = new Derivation(); + $der->case = new Cases; + + // Call the doDerivation method + $res = $der->doDerivation($currentDelegation, $nextDel, $appFields, $sp); + + // Assert the new delegation index is 1 + $this->assertEquals(1, $res); + } } \ No newline at end of file diff --git a/thirdparty/pear/DB.php b/thirdparty/pear/DB.php index 1b93f0009..1f128b17a 100644 --- a/thirdparty/pear/DB.php +++ b/thirdparty/pear/DB.php @@ -610,7 +610,7 @@ class DB $parsed['dbsyntax'] = $str; } - if (!count($dsn)) { + if (!is_string($dsn)) { return $parsed; } diff --git a/thirdparty/phing/types/Path.php b/thirdparty/phing/types/Path.php index 2205d92e5..502b3a1e3 100644 --- a/thirdparty/phing/types/Path.php +++ b/thirdparty/phing/types/Path.php @@ -318,7 +318,7 @@ class Path extends DataType { try { $element .= self::resolveFile($project, $pathElement); } catch (BuildException $e) { - $this->project->log("Dropping path element " . $pathElement + self::$project->log("Dropping path element " . $pathElement . " as it is not valid relative to the project", PROJECT_MSG_VERBOSE); } diff --git a/thirdparty/phing/util/StringHelper.php b/thirdparty/phing/util/StringHelper.php index 3dd1833f4..f64fac670 100644 --- a/thirdparty/phing/util/StringHelper.php +++ b/thirdparty/phing/util/StringHelper.php @@ -106,7 +106,7 @@ class StringHelper { * @return int */ public static function hashCode($string) { - return $this->encryptCrc32($string); + return self::encryptCrc32($string); } /** diff --git a/thirdparty/tcpdf/tcpdf.php b/thirdparty/tcpdf/tcpdf.php index bb0a6face..0c1ff753d 100644 --- a/thirdparty/tcpdf/tcpdf.php +++ b/thirdparty/tcpdf/tcpdf.php @@ -8301,9 +8301,6 @@ class TCPDF { $version = PHP_VERSION; define('PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4})); } - if (PHP_VERSION_ID < 50300) { - @set_magic_quotes_runtime($mqr); - } } /** @@ -21418,7 +21415,7 @@ class TCPDF { // define self-closing tags $selfclosingtags = array('area','base','basefont','br','hr','input','img','link','meta'); // remove all unsupported tags (the line below lists all supported tags) - $html = strip_tags($html, '