From: Tim Düsterhus Date: Mon, 24 Aug 2020 08:46:36 +0000 (+0200) Subject: Fix Guzzle following redirects with a custom temporary sink X-Git-Tag: 5.3.0_Alpha_1~28 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ce163806c468763f6e3b04e4bf7318c6f8035737;p=GitHub%2FWoltLab%2FWCF.git Fix Guzzle following redirects with a custom temporary sink When following redirects Guzzle copies over the request options for the next iteration internally, including the bare `resource` that was passed to it. This bare resource will then be wrapped into the Stream wrapper. This stream wrapper explicitely calls `close()` for the underlying resource when it is being closed. The created Streams for the subrequests will be closed before the `send` function returns, thus ultimately closing the resource for the “parent” request. Fix this issue by passing a Stream, instead of a bare resource. This one will be passed along as-is. Fixes #3529. --- diff --git a/wcfsetup/install/files/lib/system/style/FontManager.class.php b/wcfsetup/install/files/lib/system/style/FontManager.class.php index bfbe2ff589..d9bbd95b79 100644 --- a/wcfsetup/install/files/lib/system/style/FontManager.class.php +++ b/wcfsetup/install/files/lib/system/style/FontManager.class.php @@ -88,7 +88,7 @@ class FontManager extends SingletonFactory { $response = $this->http->send(new Request('GET', $family.'/'.$filename), [ // https://github.com/guzzle/guzzle/issues/2735 - 'sink' => fopen("php://temp", "w+"), + 'sink' => \GuzzleHttp\Psr7\stream_for(fopen("php://temp", "w+")), ]); $file = new AtomicWriter($familyDirectory.'/'.$filename); diff --git a/wcfsetup/install/files/lib/util/HTTPRequest.class.php b/wcfsetup/install/files/lib/util/HTTPRequest.class.php index 808f39ce77..e0eb6a2224 100644 --- a/wcfsetup/install/files/lib/util/HTTPRequest.class.php +++ b/wcfsetup/install/files/lib/util/HTTPRequest.class.php @@ -192,7 +192,7 @@ final class HTTPRequest { try { $this->response = $client->send($request, [ // https://github.com/guzzle/guzzle/issues/2735 - 'sink' => fopen("php://temp", "w+"), + 'sink' => \GuzzleHttp\Psr7\stream_for(fopen("php://temp", "w+")), ]); } catch (TooManyRedirectsException $e) {