Skip to content

Commit a143a77

Browse files
authored
[11.x] Fixes regression with queue:work Command (#53076)
`hasOption()` will always return true if it is define, this cause Laravel Framework 11.27.1 installation to always output using json. Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent d961279 commit a143a77

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Illuminate/Queue/Console/WorkCommand.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function handle()
115115
// connection being run for the queue operation currently being executed.
116116
$queue = $this->getQueue($connection);
117117

118-
if (! $this->hasOption('json') && Terminal::hasSttyAvailable()) {
118+
if (! $this->outputUsingJson() && Terminal::hasSttyAvailable()) {
119119
$this->components->info(
120120
sprintf('Processing jobs from the [%s] %s.', $queue, str('queue')->plural(explode(',', $queue)))
121121
);
@@ -201,7 +201,7 @@ protected function listenForEvents()
201201
*/
202202
protected function writeOutput(Job $job, $status, Throwable $exception = null)
203203
{
204-
$this->hasOption('json')
204+
$this->outputUsingJson()
205205
? $this->writeOutputAsJson($job, $status, $exception)
206206
: $this->writeOutputForCli($job, $status);
207207
}
@@ -346,4 +346,18 @@ protected function downForMaintenance()
346346
{
347347
return $this->option('force') ? false : $this->laravel->isDownForMaintenance();
348348
}
349+
350+
/**
351+
* Determine if the worker should output using JSON.
352+
*
353+
* @return bool
354+
*/
355+
protected function outputUsingJson()
356+
{
357+
if (! $this->hasOption('json')) {
358+
return false;
359+
}
360+
361+
return $this->option('json');
362+
}
349363
}

0 commit comments

Comments
 (0)