wp-includes/SimplePie/src/File.php:89$urlstring$timeoutintoptional10$redirectsintoptional5$headers?arrayoptionalnull$useragentSimplePie\?stringoptionalnull$force_fsockopenbooloptionalfalse$curl_optionsarrayoptional[] public function __construct(string $url, int $timeout = 10, int $redirects = 5, ?array $headers = null, ?string $useragent = null, bool $force_fsockopen = false, array $curl_options = []) { if (function_exists('idn_to_ascii')) { $parsed = \SimplePie\Misc::parse_url($url); if ($parsed['authority'] !== '' && !ctype_print($parsed['authority'])) { $authority = (string) \idn_to_ascii($parsed['authority'], \IDNA_NONTRANSITIONAL_TO_ASCII, \INTL_IDNA_VARIANT_UTS46); $url = \SimplePie\Misc::compress_parse_url($parsed['scheme'], $authority, $parsed['path'], $parsed['query'], null); } } $this->url = $url; if ($this->permanentUrlMutable) { $this->permanent_url = $url; } $this->useragent = $useragent; if (preg_match('/^http(s)?:\/\//i', $url)) { if ($useragent === null) { $useragent = (string) ini_get('user_agent'); $this->useragent = $useragent; } if (!is_array($headers)) { $headers = []; } if (!$force_fsockopen && function_exists('curl_exec')) { $this->method = \SimplePie\SimplePie::FILE_SOURCE_REMOTE | \SimplePie\SimplePie::FILE_SOURCE_CURL; $fp = curl_init(); $headers2 = []; foreach ($headers as $key => $value) { $headers2[] = "$key: $value"; } if (isset($curl_options[CURLOPT_HTTPHEADER])) { if (is_array($curl_options[CURLOPT_HTTPHEADER])) { $headers2 = array_merge($headers2, $curl_options[CURLOPT_HTTPHEADER]); } unset($curl_options[CURLOPT_HTTPHEADER]); } if (version_compare(\SimplePie\Misc::get_curl_version(), '7.10.5', '>=')) { curl_setopt($fp, CURLOPT_ENCODING, ''); } curl_setopt($fp, CURLOPT_URL, $url); curl_setopt($fp, CURLOPT_HEADER, 1); curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); curl_setopt($fp, CURLOPT_FAILONERROR, 1); curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($fp, CURLOPT_REFERER, \SimplePie\Misc::url_remove_credentials($url)); curl_setopt($fp, CURLOPT_USERAGENT, $useragent); curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); foreach ($curl_options as $curl_param => $curl_value) { curl_setopt($fp, $curl_param, $curl_value); } $responseHeaders = curl_exec($fp); if (curl_errno($fp) === CURLE_WRITE_ERROR || curl_errno($fp) === CURLE_BAD_CONTENT_ENCODING) { curl_setopt($fp, CURLOPT_ENCODING, 'none'); $responseHeaders = curl_exec($fp); } $this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE); if (curl_errno($fp)) { $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); $this->success = false; } else { // Use the updated url provided by curl_getinfo after any redirects. if ($info = curl_getinfo($fp)) { $this->url = $info['url']; } // For PHPStan: We already checked that error did not occur. assert(is_array($info) && $info['redirect_count'] >= 0); if (\PHP_VERSION_ID < 80000) { curl_close($fp); } $responseHeaders = \SimplePie\HTTP\Parser::prepareHeaders((string) $responseHeaders, $info['redirect_count'] + 1); $parser = new \SimplePie\HTTP\Parser($responseHeaders, true); if ($parser->parse()) { $this->set_headers($parser->headers); $this->body = $parser->body; $this->status_code = $parser->status_code; if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && ($locationHeader = $this->get_header_line('location')) !== '' && $this->redirects < $redirects) { $this->redirects++; $location = \SimplePie\Misc::absolutize_url($locationHeader, $url); if ($location === false) {16 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$file added.verified against source$mimeType added.verified against source$url removed.verified against source$timeout removed.verified against source$redirects removed.verified against source$headers removed.verified against source$useragent removed.verified against source$force_fsockopen removed.verified against source$curl_options removed.verified against source$url retyped from untyped to string.verified against source$timeout retyped from untyped to int.verified against source$redirects retyped from untyped to int.verified against source$headers retyped from untyped to ?array.verified against source$useragent retyped from untyped to SimplePie\?string.verified against source$force_fsockopen retyped from untyped to bool.verified against source$curl_options retyped from untyped to array.verified against sourcesrc/wp-includes/SimplePie/src/File.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.