Skip to content

Commit

Permalink
Check fopen() return type
Browse files Browse the repository at this point in the history
It might be false instead a resource when command line is "Standard input code".

The shutup operator supresses a warning.

This is the case for EXT:typo3_console command:

./bin/typo3 frontend:request
  • Loading branch information
Christoph Lehmann committed Mar 8, 2024
1 parent a777eef commit 03a494e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Classes/Writer/JsonWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ public function writeLog(LogRecord $record)
$data['request_id'] = $_SERVER['X-REQUEST-ID'] ?? $_SERVER['HTTP_X_REQUEST_ID'] ?? null;
}

$stderr = fopen('php://stderr', 'a');
fwrite($stderr, json_encode($data) . PHP_EOL);
fclose($stderr);
$stderr = @fopen('php://stderr', 'a');
if ($stderr) {
fwrite($stderr, json_encode($data) . PHP_EOL);
fclose($stderr);
}

return $this;
}
Expand Down

0 comments on commit 03a494e

Please sign in to comment.