Skip to content

Commit

Permalink
Allow setting job error_reporting level via config
Browse files Browse the repository at this point in the history
  • Loading branch information
otsch committed Aug 3, 2024
1 parent 823e2b6 commit 3ce4ca0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ public function __construct(
$this->logger = new EchoLogger();
}

public static function ppqCommand(string $command, ?string $logPath = null): SymfonyProcess
{
public static function ppqCommand(
string $command,
?string $logPath = null,
?string $iniConfigOption = null,
): SymfonyProcess {
if ($logPath) {
touch($logPath);
}

$command = 'php ' . self::ppqPath() . ' ' . $command . ' --config=' . Config::getPath();
$iniConfigOption = $iniConfigOption ? '-d ' . $iniConfigOption . ' ' : '';

$command = 'php ' . $iniConfigOption . self::ppqPath() . ' ' . $command . ' --config=' . Config::getPath();

if ($logPath) {
$command .= ' >> ' . $logPath . ' 2>&1';
Expand Down
6 changes: 5 additions & 1 deletion src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public function hasAvailableSlot(): bool
*/
public function startWaitingJob(QueueRecord $waitingJob): void
{
$process = Kernel::ppqCommand('run ' . $waitingJob->id, Logs::queueJobLogPath($waitingJob));
$process = Kernel::ppqCommand(
'run ' . $waitingJob->id,
Logs::queueJobLogPath($waitingJob),
Config::get('error_reporting') ? 'error_reporting=' . Config::get('error_reporting') : '',
);

$process->start();

Expand Down
2 changes: 2 additions & 0 deletions tests/_testdata/config/error-handler-ignore-warnings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
],
],

'error_reporting' => E_ALL,

'error_handler' => [
'class' => ErrorHandlerIgnoreWarnings::class,
'active' => true,
Expand Down
2 changes: 2 additions & 0 deletions tests/_testdata/config/error-handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
],
],

'error_reporting' => 'E_ALL',

'error_handler' => [
'class' => ErrorHandler::class,
'active' => true,
Expand Down

0 comments on commit 3ce4ca0

Please sign in to comment.