Skip to content

Commit e7d6313

Browse files
committed
TL-46723 scssphp: Don't close a stream that failed to open
1 parent 9b2859f commit e7d6313

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: [ '8.1', '8.2' ]
16+
php: [ '8.2' ]
1717
extensions: [ '' ]
1818
os: [ubuntu-latest]
1919
include:

src/Logger/StreamLogger.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct($stream, $closeOnDestruct = false)
3737
*/
3838
public function __destruct()
3939
{
40-
if ($this->closeOnDestruct) {
40+
if ($this->closeOnDestruct && $this->stream) {
4141
fclose($this->stream);
4242
}
4343
}
@@ -47,6 +47,10 @@ public function __destruct()
4747
*/
4848
public function warn($message, $deprecation = false)
4949
{
50+
if (!$this->stream) {
51+
return;
52+
}
53+
5054
$prefix = ($deprecation ? 'DEPRECATION ' : '') . 'WARNING: ';
5155

5256
fwrite($this->stream, $prefix . $message . "\n\n");
@@ -57,6 +61,10 @@ public function warn($message, $deprecation = false)
5761
*/
5862
public function debug($message)
5963
{
64+
if (!$this->stream) {
65+
return;
66+
}
67+
6068
fwrite($this->stream, $message . "\n");
6169
}
6270
}

0 commit comments

Comments
 (0)