From: Tim Düsterhus Date: Mon, 8 Aug 2022 14:42:24 +0000 (+0200) Subject: Remove FileUtil::downloadFileFromHttp() X-Git-Tag: 6.0.0_Alpha_1~1053^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f131814ca15322fa4d5cddb58b1f15e00948b0df;p=GitHub%2FWoltLab%2FWCF.git Remove FileUtil::downloadFileFromHttp() This method is deprecated since roughly forever, has a super questionable API and even itself relies on the deprecated HTTPRequest API. Users really should migrate to Guzzle. Resolves #4373 --- diff --git a/wcfsetup/install/files/lib/util/FileUtil.class.php b/wcfsetup/install/files/lib/util/FileUtil.class.php index f70fc488ec..8331a7c98a 100644 --- a/wcfsetup/install/files/lib/util/FileUtil.class.php +++ b/wcfsetup/install/files/lib/util/FileUtil.class.php @@ -391,39 +391,6 @@ final class FileUtil return StringUtil::formatNumeric(\round($byte, $precision)) . ' ' . $symbol; } - /** - * Downloads a package archive from an http URL and returns the path to - * the downloaded file. - * - * @param string $httpUrl - * @param string $prefix - * @param array $options - * @param array $postParameters - * @param array $headers empty array or a not initialized variable - * @return string - * @deprecated This method currently only is a wrapper around \wcf\util\HTTPRequest. Please use - * HTTPRequest from now on, as this method may be removed in the future. - */ - public static function downloadFileFromHttp( - $httpUrl, - $prefix = 'package', - array $options = [], - array $postParameters = [], - &$headers = [] - ) { - $request = new HTTPRequest($httpUrl, $options, $postParameters); - $request->execute(); - $reply = $request->getReply(); - - $newFileName = self::getTemporaryFilename($prefix . '_'); - \file_put_contents($newFileName, $reply['body']); // the file to write. - - $tmp = $reply['headers']; // copy variable, to avoid problems with the reference - $headers = $tmp; - - return $newFileName; - } - /** * Determines whether a file is text or binary by checking the first few bytes in the file. * The exact number of bytes is system dependent, but it is typically several thousand.