Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(admin/job): avoid that JSON messages are hidden (overwrite) #1100

Merged
merged 2 commits into from
Dec 9, 2024
Merged
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
6 changes: 6 additions & 0 deletions EMS/core-bundle/src/Command/JobOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
namespace EMS\CoreBundle\Command;

use EMS\CoreBundle\Repository\JobRepository;
use EMS\Helpers\Standard\Json;
use Symfony\Component\Console\Output\Output;

class JobOutput extends Output
{
private const JOB_VERBOSITY = self::VERBOSITY_NORMAL;
private bool $newLine = true;

public function __construct(private readonly JobRepository $jobRepository, private readonly int $jobId)
{
Expand All @@ -34,6 +36,10 @@ public function progress(int $progress): void

public function doWrite(string $message, bool $newline): void
{
if (!$newline && !$this->newLine && Json::isJson($message)) {
$newline = true;
}
$this->newLine = $newline;
$job = $this->jobRepository->findById($this->jobId);
$job->setStatus($message);
$job->setOutput(self::concatenateAnsiString($job->getOutput() ?? '', $this->getFormatter()->format($message) ?? '').($newline ? PHP_EOL : ''));
Expand Down
Loading