Merged in bugfix/PMCORE-3063 (pull request #7949)

PMCORE-3063

Approved-by: Paula Quispe
This commit is contained in:
Julio Cesar Laura Avendaño
2021-06-30 19:11:46 +00:00
2 changed files with 66 additions and 37 deletions

View File

@@ -433,7 +433,8 @@ class WebApplication
* The value of $executeSetupPlugin must always be true for a web environment. * The value of $executeSetupPlugin must always be true for a web environment.
* *
* @param string $workspace * @param string $workspace
* @param boolean $executeSetupPlugin * @param bool $executeSetupPlugin
* @param bool $setTimeZone
* @return bool * @return bool
* @throws Exception * @throws Exception
* *
@@ -441,7 +442,7 @@ class WebApplication
* @see workflow/engine/bin/cli.php * @see workflow/engine/bin/cli.php
* @see \App\Console\Commands\AddParametersTrait * @see \App\Console\Commands\AddParametersTrait
*/ */
public function loadEnvironment($workspace = "", $executeSetupPlugin = true) public function loadEnvironment($workspace = "", $executeSetupPlugin = true, $setTimeZone = true)
{ {
define("PATH_SEP", DIRECTORY_SEPARATOR); define("PATH_SEP", DIRECTORY_SEPARATOR);
@@ -511,8 +512,10 @@ class WebApplication
$arraySystemConfiguration = System::getSystemConfiguration('', '', $workspace); $arraySystemConfiguration = System::getSystemConfiguration('', '', $workspace);
if ($setTimeZone) {
//In community version the default value is 0 //In community version the default value is 0
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1; $_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1;
}
define('DEBUG_SQL_LOG', $arraySystemConfiguration['debug_sql']); define('DEBUG_SQL_LOG', $arraySystemConfiguration['debug_sql']);
define('DEBUG_TIME_LOG', $arraySystemConfiguration['debug_time']); define('DEBUG_TIME_LOG', $arraySystemConfiguration['debug_time']);
@@ -521,8 +524,10 @@ class WebApplication
define('MEMCACHED_SERVER', $arraySystemConfiguration['memcached_server']); define('MEMCACHED_SERVER', $arraySystemConfiguration['memcached_server']);
define('SYS_SKIN', $arraySystemConfiguration['default_skin']); define('SYS_SKIN', $arraySystemConfiguration['default_skin']);
define('DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION', $arraySystemConfiguration['disable_download_documents_session_validation']); define('DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION', $arraySystemConfiguration['disable_download_documents_session_validation']);
if ($setTimeZone) {
define('TIME_ZONE', define('TIME_ZONE',
(isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) ? 'UTC' : $arraySystemConfiguration['time_zone']); (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) ? 'UTC' : $arraySystemConfiguration['time_zone']);
}
// Change storage path // Change storage path
app()->useStoragePath(realpath(PATH_DATA)); app()->useStoragePath(realpath(PATH_DATA));
@@ -537,11 +542,11 @@ class WebApplication
ini_set('short_open_tag', 'On'); //?? ini_set('short_open_tag', 'On'); //??
ini_set('default_charset', 'UTF-8'); //?? ini_set('default_charset', 'UTF-8'); //??
ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']); ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']);
if ($setTimeZone) {
ini_set('date.timezone', TIME_ZONE); //Set Time Zone ini_set('date.timezone', TIME_ZONE); //Set Time Zone
date_default_timezone_set(TIME_ZONE); date_default_timezone_set(TIME_ZONE);
config(['app.timezone' => TIME_ZONE]); config(['app.timezone' => TIME_ZONE]);
}
// Define the language // Define the language
Bootstrap::setLanguage(); Bootstrap::setLanguage();

View File

@@ -1,20 +1,22 @@
<?php <?php
require_once(__DIR__ . '/../../../bootstrap/autoload.php'); // Auto loader
require_once __DIR__ . '/../../../bootstrap/autoload.php';
// Initialize core
$app = new Maveriks\WebApplication(); $app = new Maveriks\WebApplication();
$app->setRootDir(PROCESSMAKER_PATH); $app->setRootDir(PROCESSMAKER_PATH);
$app->loadEnvironment(); $app->loadEnvironment('', true, false);
// trap -V before pake // Trap -V before pake
if (in_array('-v', $argv) || in_array('-V', $argv) || in_array('--version', $argv)) { if (in_array('-v', $argv) || in_array('-V', $argv) || in_array('--version', $argv)) {
printf("ProcessMaker version %s\n", pakeColor::colorize(trim(file_get_contents(PATH_GULLIVER . 'VERSION')), 'INFO')); printf("ProcessMaker version %s\n",
pakeColor::colorize(trim(file_get_contents(PATH_GULLIVER . 'VERSION')), 'INFO'));
exit(0); exit(0);
} }
// register tasks // Register tasks
//TODO: include plugins $directories = [PATH_HOME . 'engine/bin/tasks'];
$directories = array(PATH_HOME . 'engine/bin/tasks');
$pluginsDirectories = glob(PATH_PLUGINS . "*"); $pluginsDirectories = glob(PATH_PLUGINS . "*");
foreach ($pluginsDirectories as $dir) { foreach ($pluginsDirectories as $dir) {
if (!is_dir($dir)) { if (!is_dir($dir)) {
@@ -24,13 +26,35 @@ $app->loadEnvironment();
$directories[] = "$dir/bin/tasks"; $directories[] = "$dir/bin/tasks";
} }
} }
foreach ($directories as $dir) { foreach ($directories as $dir) {
foreach (glob("$dir/*.php") as $filename) { foreach (glob("$dir/*.php") as $filename) {
include_once($filename); include_once $filename;
} }
} }
// Set time zone, if not defined
if (!defined('TIME_ZONE')) {
// Get workspace
$args = $argv;
$cliName = array_shift($args);
$taskName = array_shift($args);
$workspace = array_shift($args);
while ($workspace[0] == '-') {
$workspace = array_shift($args);
}
// Get time zone (global or by workspace)
$arraySystemConfiguration = System::getSystemConfiguration('', '', $workspace);
// Set time zone
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1;
define('TIME_ZONE',
(isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) ? 'UTC' : $arraySystemConfiguration['time_zone']);
ini_set('date.timezone', TIME_ZONE);
date_default_timezone_set(TIME_ZONE);
config(['app.timezone' => TIME_ZONE]);
}
// Run command
CLI::run(); CLI::run();
exit(0); exit(0);