Prevent duplicate closeCallback calls in case of GC ghosts

Sometimes PHP 7 GC decides to call stream_close again even after the
PHP request has ended, and even if fclose was called before already.
This commit is contained in:
Vincent Petry 2016-12-02 14:57:57 +01:00
commit 668abfee80
No known key found for this signature in database
GPG key ID: AF8F9EFC56562186

View file

@ -107,6 +107,8 @@ class CallbackWrapper extends Wrapper {
$result = parent::stream_close();
if (is_callable($this->closeCallback)) {
call_user_func($this->closeCallback);
// prevent further calls by potential PHP 7 GC ghosts
$this->closeCallback = null;
}
return $result;
}