Skip to content

Commit dd2e605

Browse files
bug symfony#41621 [Process] Fix incorrect parameter type (bch36)
This PR was submitted for the 5.4 branch but it was squashed and merged into the 4.4 branch instead. Discussion ---------- [Process] Fix incorrect parameter type In the affected line of code, fclose() should ONLY be passed a parameter of type resource, but fopen() can return a value of type bool (if the fopen() fails). This results in a fatal error under PHP 8: Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given. | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Commits ------- d1579a2 [Process] Fix incorrect parameter type
2 parents c17ed9e + d1579a2 commit dd2e605

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Process/Pipes/WindowsPipes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct($input, bool $haveReadSupport)
7171
}
7272
$this->lockHandles[$pipe] = $h;
7373

74-
if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
74+
if (!($h = fopen($file, 'w')) || !fclose($h) || !$h = fopen($file, 'r')) {
7575
flock($this->lockHandles[$pipe], \LOCK_UN);
7676
fclose($this->lockHandles[$pipe]);
7777
unset($this->lockHandles[$pipe]);

0 commit comments

Comments
 (0)