diff --git a/app/Console/Commands/RestartCommand.php b/app/Console/Commands/RestartCommand.php index e76915779..032a2b15f 100644 --- a/app/Console/Commands/RestartCommand.php +++ b/app/Console/Commands/RestartCommand.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Queue\Console\RestartCommand as BaseRestartCommand; class RestartCommand extends BaseRestartCommand @@ -17,4 +18,15 @@ class RestartCommand extends BaseRestartCommand * This contains the necessary code to add parameters. */ use AddParametersTrait; + + /** + * Create a new queue restart command. + * + * @param Cache $cache + * @return void + */ + public function __construct(Cache $cache) + { + parent::__construct($cache); + } } diff --git a/app/Console/Commands/ScheduleRunCommand.php b/app/Console/Commands/ScheduleRunCommand.php index c0d2a0354..344923024 100755 --- a/app/Console/Commands/ScheduleRunCommand.php +++ b/app/Console/Commands/ScheduleRunCommand.php @@ -4,20 +4,23 @@ namespace App\Console\Commands; use Bootstrap; use Illuminate\Support\Carbon; +use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand; +use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Contracts\Debug\ExceptionHandler; use Maveriks\WebApplication; use ProcessMaker\Model\TaskScheduler; class ScheduleRunCommand extends BaseCommand { use AddParametersTrait; + /** * Create a new command instance. - * - * @param \Illuminate\Console\Scheduling\Schedule $schedule + * * @return void */ - public function __construct(\Illuminate\Console\Scheduling\Schedule $schedule) + public function __construct() { $this->startedAt = Carbon::now(); $this->signature = "schedule:run"; @@ -27,18 +30,22 @@ class ScheduleRunCommand extends BaseCommand {--processmakerPath=./ : ProcessMaker path.} "; $this->description .= ' (ProcessMaker has extended this command)'; - parent::__construct($schedule); + parent::__construct(); } + /** * Execute the console command. - * + * + * @param Schedule $schedule + * @param Dispatcher $dispatcher + * @param ExceptionHandler $handler * @return void */ - public function handle() + public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHandler $handler) { $that = $this; $workspace = $this->option('workspace'); - $user = $this->option('user'); + $user = $this->option('user'); if (!empty($workspace)) { $webApplication = new WebApplication(); $webApplication->setRootDir($this->option('processmakerPath')); @@ -52,7 +59,7 @@ class ScheduleRunCommand extends BaseCommand $timezone = isset($p->timezone) && $p->timezone != "" ? $p->timezone : date_default_timezone_get(); $body = $p->body; if (!$win) { - $body = str_replace(" -c"," " . $user . " -c", $p->body); + $body = str_replace(" -c", " " . $user . " -c", $p->body); } //for init date and finish date parameters @@ -116,6 +123,6 @@ class ScheduleRunCommand extends BaseCommand } } }); - parent::handle(); + parent::handle($schedule, $dispatcher, $handler); } -} \ No newline at end of file +} diff --git a/app/Console/Commands/WorkCommand.php b/app/Console/Commands/WorkCommand.php index bd59bc4bf..92426dad8 100644 --- a/app/Console/Commands/WorkCommand.php +++ b/app/Console/Commands/WorkCommand.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Support\Facades\File; use Illuminate\Queue\Console\WorkCommand as BaseWorkCommand; use Illuminate\Queue\Events\JobProcessing; @@ -9,7 +10,6 @@ use Illuminate\Queue\Worker; class WorkCommand extends BaseWorkCommand { - use AddParametersTrait; /** @@ -19,7 +19,7 @@ class WorkCommand extends BaseWorkCommand * * @return void */ - public function __construct(Worker $worker) + public function __construct(Worker $worker, Cache $cache) { $this->signature .= ' {--workspace=workflow : ProcessMaker Indicates the workspace to be processed.} @@ -28,7 +28,7 @@ class WorkCommand extends BaseWorkCommand $this->description .= ' (ProcessMaker has extended this command)'; - parent::__construct($worker); + parent::__construct($worker, $cache); } /** @@ -62,14 +62,14 @@ class WorkCommand extends BaseWorkCommand require_once $file; } //load the classes of the plugins when is required dynamically. - $closure = function($className) { + $closure = function ($className) { if (class_exists($className)) { return; } if (!defined('PATH_PLUGINS')) { return; } - $searchFiles = function($path) use(&$searchFiles, $className) { + $searchFiles = function ($path) use (&$searchFiles, $className) { $directories = File::directories($path); foreach ($directories as $directory) { $omittedDirectories = [ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2daad662c..6e9fc777d 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,8 +2,9 @@ namespace App\Providers; -use App\Helpers\Workspace; +use App\Console\Commands\WorkCommand; use App\Log\LogManager; +use Illuminate\Queue\Worker; use Illuminate\Support\Facades\App; use Illuminate\Support\ServiceProvider; @@ -17,8 +18,11 @@ class AppServiceProvider extends ServiceProvider */ public function register() { - App::bind('workspace', function() { - return new Workspace(); + $this->app->bind(WorkCommand::class, function ($app) { + $isDownForMaintenance = function () { + return $this->app->isDownForMaintenance(); + }; + return new WorkCommand(App::make(Worker::class, ['isDownForMaintenance' => $isDownForMaintenance]), $app['cache.store']); }); $this->app->singleton('log', function ($app) { diff --git a/config/app.php b/config/app.php index f527c258e..956946042 100644 --- a/config/app.php +++ b/config/app.php @@ -31,7 +31,6 @@ return [ ], 'aliases' => [ 'Crypt' => Illuminate\Support\Facades\Crypt::class, - 'ScriptVariables' => Eusebiu\JavaScript\Facades\ScriptVariables::class, 'View' => Illuminate\Support\Facades\View::class ], ]; diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index 05653aee3..12d20025a 100644 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -5616,23 +5616,28 @@ class G } } + $pathSep = getConstant('PATH_SEP'); + $pathSkinEngine = getConstant('PATH_SKIN_ENGINE'); + $pathSkins = getConstant('PATH_SKINS'); + $pathCustomSkins = getConstant('PATH_CUSTOM_SKINS'); + $arrayAux = explode("?", $strAux); $fileTemplate = $arrayAux[0]; - if (file_exists(PATH_SKIN_ENGINE . "base" . PATH_SEP . $fileTemplate)) { - $path = PATH_SKIN_ENGINE . "base" . PATH_SEP; + if (file_exists($pathSkinEngine . "base" . $pathSep . $fileTemplate)) { + $path = $pathSkinEngine . "base" . $pathSep; } - if (file_exists(PATH_SKIN_ENGINE . $skin . PATH_SEP . $fileTemplate)) { - $path = PATH_SKIN_ENGINE . $skin . PATH_SEP; + if (file_exists($pathSkinEngine . $skin . $pathSep . $fileTemplate)) { + $path = $pathSkinEngine . $skin . $pathSep; } - if (file_exists(PATH_SKINS . $skin . PATH_SEP . $fileTemplate)) { - $path = PATH_SKINS . $skin . PATH_SEP; + if (file_exists($pathSkins . $skin . $pathSep . $fileTemplate)) { + $path = $pathSkins . $skin . $pathSep; } - if (file_exists(PATH_CUSTOM_SKINS . $skin . PATH_SEP . $fileTemplate)) { - $path = PATH_CUSTOM_SKINS . $skin . PATH_SEP; + if (file_exists($pathCustomSkins . $skin . $pathSep . $fileTemplate)) { + $path = $pathCustomSkins . $skin . $pathSep; } } } diff --git a/thirdparty/pake/pakeException.class.php b/thirdparty/pake/pakeException.class.php index 86b72ec1a..fee471abe 100644 --- a/thirdparty/pake/pakeException.class.php +++ b/thirdparty/pake/pakeException.class.php @@ -19,73 +19,69 @@ */ class pakeException extends Exception { - public static function strlen($string) - { - return function_exists('mb_strlen') ? mb_strlen($string) : strlen($string); - } - - function render($e) - { - $title = ' ['.get_class($e).'] '; - $len = self::strlen($title); - $lines = array(); - foreach (explode("\n", $e->getMessage()) as $line) + public static function strlen($string) { - $lines[] = ' '.$line.' '; - $len = max(self::strlen($line) + 4, $len); - } - $messages = array( - str_repeat(' ', $len), - $title.str_repeat(' ', $len - self::strlen($title)), - ); - - foreach ($lines as $line) - { - $messages[] = $line.str_repeat(' ', $len - self::strlen($line)); + return function_exists('mb_strlen') ? mb_strlen($string) : strlen($string); } - $messages[] = str_repeat(' ', $len); - - fwrite(STDERR, "\n"); - foreach ($messages as $message) + function render($e) { - fwrite(STDERR, pakeColor::colorize($message, 'ERROR', STDERR)."\n"); - } - fwrite(STDERR, "\n"); + $title = ' [' . get_class($e) . '] '; + $len = self::strlen($title); + $lines = array(); + foreach (explode("\n", $e->getMessage()) as $line) { + $lines[] = ' ' . $line . ' '; + $len = max(self::strlen($line) + 4, $len); + } + $messages = array( + str_repeat(' ', $len), + $title . str_repeat(' ', $len - self::strlen($title)), + ); - $pake = pakeApp::get_instance(); + foreach ($lines as $line) { + $messages[] = $line . str_repeat(' ', $len - self::strlen($line)); + } - if ($pake->get_trace()) - { - fwrite(STDERR, "exception trace:\n"); + $messages[] = str_repeat(' ', $len); - $trace = $this->trace($e); - for ($i = 0, $count = count($trace); $i < $count; $i++) - { - $class = (isset($trace[$i]['class']) ? $trace[$i]['class'] : ''); - $type = (isset($trace[$i]['type']) ? $trace[$i]['type'] : ''); - $function = $trace[$i]['function']; - $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; - $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; + $stderr = getConstant('STDERR', fopen('php://stderr', 'wb')); + fwrite($stderr, "\n"); + foreach ($messages as $message) { + fwrite($stderr, pakeColor::colorize($message, 'ERROR', $stderr) . "\n"); + } + fwrite($stderr, "\n"); - fwrite(STDERR, sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, pakeColor::colorize($file, 'INFO', STDERR), pakeColor::colorize($line, 'INFO', STDERR))); - } + $pake = pakeApp::get_instance(); + + if ($pake->get_trace()) { + fwrite($stderr, "exception trace:\n"); + + $trace = $this->trace($e); + for ($i = 0, $count = count($trace); $i < $count; $i++) { + $class = (isset($trace[$i]['class']) ? $trace[$i]['class'] : ''); + $type = (isset($trace[$i]['type']) ? $trace[$i]['type'] : ''); + $function = $trace[$i]['function']; + $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; + $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; + + fwrite($stderr, sprintf(" %s%s%s at %s:%s\n", $class, $type, $function, pakeColor::colorize($file, 'INFO', $stderr), pakeColor::colorize($line, 'INFO', $stderr))); + } + } + + fwrite($stderr, "\n"); } - fwrite(STDERR, "\n"); - } + function trace($exception) + { + // exception related properties + $trace = $exception->getTrace(); + array_unshift($trace, array( + 'function' => '', + 'file' => ($exception->getFile() != null) ? $exception->getFile() : 'n/a', + 'line' => ($exception->getLine() != null) ? $exception->getLine() : 'n/a', + 'args' => array(), + )); - function trace($exception) - { - // exception related properties - $trace = $exception->getTrace(); - array_unshift($trace, array( - 'function' => '', - 'file' => ($exception->getFile() != null) ? $exception->getFile() : 'n/a', - 'line' => ($exception->getLine() != null) ? $exception->getLine() : 'n/a', - 'args' => array(), - )); - - return $trace; - } + return $trace; + } } diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index b77cd358d..03201a56e 100644 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -1073,6 +1073,9 @@ try { } } + if (!isset($aFields['PROCESS']['DISABLED'])) { + $aFields['PROCESS']['DISABLED'] = ''; + } $G_PUBLISH->AddContent('smarty', $tplFile, '', '', $aFields); break; case 'EXTERNAL': diff --git a/workflow/engine/skinEngine/neoclassic/error404.php b/workflow/engine/skinEngine/neoclassic/error404.php index be807018a..cef425548 100644 --- a/workflow/engine/skinEngine/neoclassic/error404.php +++ b/workflow/engine/skinEngine/neoclassic/error404.php @@ -1,12 +1,14 @@ - diff --git a/workflow/engine/src/ProcessMaker/Util/helpers.php b/workflow/engine/src/ProcessMaker/Util/helpers.php index 4f0db0051..5e810fe2d 100644 --- a/workflow/engine/src/ProcessMaker/Util/helpers.php +++ b/workflow/engine/src/ProcessMaker/Util/helpers.php @@ -727,3 +727,14 @@ function calculateDate($iniDate, $timeUnit, $time) return $datetime->format('Y-m-d H:i:s'); } + +/** + * Get the constant value. + * @param string $name + * @param mixed $default + * @return mixed + */ +function getConstant(string $name, $default = '') +{ + return defined($name) === true ? constant($name) : $default; +}