Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ProcessMaker/Console/Commands/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use ProcessMaker\Facades\MessageBrokerService;

class Consumer extends Command
Expand Down Expand Up @@ -40,7 +41,8 @@ public function handle()
try {
MessageBrokerService::worker();
} catch (Exception $e) {
$this->warn($e->getMessage());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
}
14 changes: 14 additions & 0 deletions ProcessMaker/Models/ProcessRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,4 +907,18 @@ public function getMedia(string $collectionName = 'default', $filters = []): Col
{
return \ProcessMaker\Models\Media::getFilesRequest($this);
}

public function getErrors()
{
if ($this->errors) {
return $this->errors;
}
// select tokens with errors
return $this->tokens()
->select('token_properties->error as message', 'created_at', 'element_name')
->where('status', '=', ActivityInterface::TOKEN_STATE_FAILING)
->limit(10)
->get()
->toArray();
}
}
2 changes: 1 addition & 1 deletion ProcessMaker/Models/ProcessRequestToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ public function logError(Throwable $error, FlowElementInterface $bpmnElement)

public function updateTokenProperties()
{
$allowed = ['conditionals', 'loopCharacteristics', 'data'];
$allowed = ['conditionals', 'loopCharacteristics', 'data', 'error'];
$this->token_properties = array_filter(
$this->getProperties(),
function ($key) use ($allowed) {
Expand Down
10 changes: 9 additions & 1 deletion ProcessMaker/Nayra/Managers/WorkflowManagerRabbitMq.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,25 @@ private function serializeState(ProcessRequest $instance)
$tokensRows = [];
$tokens = $request->tokens()->where('status', '!=', 'CLOSED')->where('status', '!=', 'TRIGGERED')->get();
foreach ($tokens as $token) {
$tokensRows[] = array_merge($token->token_properties ?: [], [
$tokenRow = array_merge($token->token_properties ?: [], [
'id' => $token->uuid,
'status' => $token->status,
'index' => $token->element_index,
'element_id' => $token->element_id,
'created_at' => $token->created_at->getTimestamp(),
]);
if ($token->subprocess_request_id) {
$subRequest = ProcessRequest::select(['process_version_id', 'uuid'])
->find($token->subprocess_request_id);
$tokenRow['subprocess_request_id'] = $subRequest->uuid;
$tokenRow['subprocess_request_version'] = $subRequest->process_version_id;
}
$tokensRows[] = $tokenRow;
}

return [
'id' => $request->uuid,
'process_version_id' => $request->process_version_id,
'callable_id' => $request->callable_id,
'collaboration_uuid' => $request->collaboration_uuid,
'data' => $request->data,
Expand Down
3 changes: 2 additions & 1 deletion ProcessMaker/Nayra/Repositories/Deserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use ProcessMaker\Nayra\Contracts\Bpmn\EventDefinitionInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;
use ProcessMaker\Nayra\Contracts\Storage\BpmnDocumentInterface;
use ProcessMaker\Repositories\BpmnDocument;
use ProcessMaker\Repositories\DefinitionsRepository;
use ProcessMaker\Repositories\ExecutionInstanceRepository;
Expand Down Expand Up @@ -56,7 +57,7 @@ private function findProcessDefinition($modelId): BpmnDocument
$version = ProcessVersion::find($modelId);
$model = $version->process;

$definition = new BpmnDocument($model);
$definition = app(BpmnDocumentInterface::class, ['process' => $model]);
$definition->setFactory($this->factory);
$definition->loadXML($version->bpmn);

Expand Down
6 changes: 5 additions & 1 deletion ProcessMaker/Nayra/Repositories/PersistenceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public function save(array $transaction)
case 'instance_updated':
$this->persistInstanceUpdated($transaction);
break;
case 'call_activity_activated':
$this->persistCallActivityActivated($transaction);
break;
case 'schedule_date':
$this->persistScheduleDate($transaction);
break;
Expand All @@ -139,7 +142,8 @@ public function save(array $transaction)
}
} catch (Exception $error) {
Log::error($error->getMessage());
if ($transaction['token']) {
Log::error($error->getTraceAsString());
if (!empty($transaction['token'])) {
$token = $this->deserializer->unserializeToken($transaction['token']);
$request = $token->getInstance();
if ($request && $request instanceof ProcessRequest) {
Expand Down
17 changes: 17 additions & 0 deletions ProcessMaker/Nayra/Repositories/PersistenceTokenTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

namespace ProcessMaker\Nayra\Repositories;

use ProcessMaker\Repositories\TokenRepository;

trait PersistenceTokenTrait
{
protected TokenRepository $tokenRepository;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is necessary? this property is defined in another class...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helps IDE to find the $tokenRepository type and definition


/**
* Persists instance and token data when a token arrives to an activity
*
Expand Down Expand Up @@ -208,4 +212,17 @@ public function persistEventBasedGatewayActivated(array $transaction)
$consumedTokens = $this->deserializer->unserializeTokensCollection($transaction['consumed_tokens']);
$this->tokenRepository->persistEventBasedGatewayActivated($gateway, $passedToken, $consumedTokens);
}

/**
* Persists a Call Activity Activated
*
* @param array $transaction
*/
public function persistCallActivityActivated(array $transaction)
{
$token = $this->deserializer->unserializeToken($transaction['token']);
$subprocessInstance = $this->deserializer->unserializeInstance($transaction['subprocess']);
$startId = $transaction['start_id'];
$this->tokenRepository->persistCallActivityActivated($token, $subprocessInstance, $startId);
}
}
3 changes: 2 additions & 1 deletion ProcessMaker/Repositories/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use ProcessMaker\Models\ProcessCollaboration;
use ProcessMaker\Models\ProcessRequest as Instance;
use ProcessMaker\Models\ProcessRequestToken as Token;
use ProcessMaker\Models\ProcessRequestToken;
use ProcessMaker\Models\User;
use ProcessMaker\Nayra\Bpmn\Collection;
use ProcessMaker\Nayra\Bpmn\Models\EndEvent;
Expand Down Expand Up @@ -201,7 +202,7 @@ private function assignTaskUser(ActivityInterface $activity, TokenInterface $tok
* Persists instance and token data when a token within an activity change to error state
*
* @param ActivityInterface $activity
* @param TokenInterface $token
* @param TokenInterface|ProcessRequestToken $token
*
* @return mixed
*/
Expand Down
2 changes: 1 addition & 1 deletion resources/js/requests/components/RequestErrors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<style lang="scss" scoped>
.error-body {
word-break: break-word;
overflow-x: scroll;
overflow-x: auto;
font-size: 87.5%;
max-width: 992px; // Not a fan of hard-coding this value, but it's equivalent to $screen-md-max
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/requests/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class="d-inline-flex pull-left align-items-center" :input-data="requestBy" displ
canViewPrint: @json($canPrintScreens),
status: 'ACTIVE',
userRequested: [],
errorLogs: @json(['data' => $request->errors]),
errorLogs: @json(['data' => $request->getErrors()]),
disabled: false,
retryDisabled: false,
packages: [],
Expand Down