bug #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
-------

d1579a2922 [Process] Fix incorrect parameter type
This commit is contained in:
Nicolas Grekas 2021-06-09 16:59:17 +02:00
commit dd2e6059b5

View File

@ -71,7 +71,7 @@ class WindowsPipes extends AbstractPipes
}
$this->lockHandles[$pipe] = $h;
if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
if (!($h = fopen($file, 'w')) || !fclose($h) || !$h = fopen($file, 'r')) {
flock($this->lockHandles[$pipe], \LOCK_UN);
fclose($this->lockHandles[$pipe]);
unset($this->lockHandles[$pipe]);