Skip to content

Commit

Permalink
Make own output from the child process so we can check on it
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcHagen committed Aug 28, 2024
1 parent 9bf6aee commit e1d6f70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions src/Process/ParallelProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ public function getOutput()
if (! $this->output) {
$processOutput = $this->process->getOutput();

$this->output = @unserialize(base64_decode($processOutput));
$childResult = @unserialize(base64_decode($processOutput));

if (! $this->output) {
if ($childResult === false || ! array_key_exists('output', $childResult)) {
$this->errorOutput = $processOutput;

return null;
}

$this->output = $childResult['output'];
}

return $this->output;
Expand All @@ -83,11 +87,13 @@ public function getErrorOutput()
if (! $this->errorOutput) {
$processOutput = $this->process->getErrorOutput();

$this->errorOutput = @unserialize(base64_decode($processOutput));
$childResult = @unserialize(base64_decode($processOutput));

if (! $this->errorOutput) {
if ($childResult === false || ! array_key_exists('output', $childResult)) {
$this->errorOutput = $processOutput;
}
} else {
$this->errorOutput = $childResult['output'];
}
}

return $this->errorOutput;
Expand Down
4 changes: 2 additions & 2 deletions src/Runtime/ChildRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

$output = call_user_func($task);

$serializedOutput = base64_encode(serialize($output));
$serializedOutput = base64_encode(serialize(['output' => $output]));

if (strlen($serializedOutput) > $outputLength) {
throw \Spatie\Async\Output\ParallelError::outputTooLarge($outputLength);
Expand All @@ -39,7 +39,7 @@

$output = new \Spatie\Async\Output\SerializableException($exception);

fwrite(STDERR, base64_encode(serialize($output)));
fwrite(STDERR, base64_encode(serialize(['output' => $output])));

exit(1);
}

0 comments on commit e1d6f70

Please sign in to comment.