Edit File by line
/home/zeestwma/redstone.../wp-inclu.../SimplePi.../src
File: Locator.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
[2] Fix | Delete
// SPDX-License-Identifier: BSD-3-Clause
[3] Fix | Delete
[4] Fix | Delete
declare(strict_types=1);
[5] Fix | Delete
[6] Fix | Delete
namespace SimplePie;
[7] Fix | Delete
[8] Fix | Delete
use DomDocument;
[9] Fix | Delete
use Psr\Http\Client\ClientInterface;
[10] Fix | Delete
use Psr\Http\Message\RequestFactoryInterface;
[11] Fix | Delete
use Psr\Http\Message\UriFactoryInterface;
[12] Fix | Delete
use SimplePie\HTTP\Client;
[13] Fix | Delete
use SimplePie\HTTP\ClientException;
[14] Fix | Delete
use SimplePie\HTTP\FileClient;
[15] Fix | Delete
use SimplePie\HTTP\Psr18Client;
[16] Fix | Delete
use SimplePie\HTTP\Response;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Used for feed auto-discovery
[20] Fix | Delete
*
[21] Fix | Delete
*
[22] Fix | Delete
* This class can be overloaded with {@see \SimplePie\SimplePie::set_locator_class()}
[23] Fix | Delete
*/
[24] Fix | Delete
class Locator implements RegistryAware
[25] Fix | Delete
{
[26] Fix | Delete
/** @var ?string */
[27] Fix | Delete
public $useragent = null;
[28] Fix | Delete
/** @var int */
[29] Fix | Delete
public $timeout = 10;
[30] Fix | Delete
/** @var File */
[31] Fix | Delete
public $file;
[32] Fix | Delete
/** @var string[] */
[33] Fix | Delete
public $local = [];
[34] Fix | Delete
/** @var string[] */
[35] Fix | Delete
public $elsewhere = [];
[36] Fix | Delete
/** @var array<mixed> */
[37] Fix | Delete
public $cached_entities = [];
[38] Fix | Delete
/** @var string */
[39] Fix | Delete
public $http_base;
[40] Fix | Delete
/** @var string */
[41] Fix | Delete
public $base;
[42] Fix | Delete
/** @var int */
[43] Fix | Delete
public $base_location = 0;
[44] Fix | Delete
/** @var int */
[45] Fix | Delete
public $checked_feeds = 0;
[46] Fix | Delete
/** @var int */
[47] Fix | Delete
public $max_checked_feeds = 10;
[48] Fix | Delete
/** @var bool */
[49] Fix | Delete
public $force_fsockopen = false;
[50] Fix | Delete
/** @var array<int, mixed> */
[51] Fix | Delete
public $curl_options = [];
[52] Fix | Delete
/** @var ?\DomDocument */
[53] Fix | Delete
public $dom;
[54] Fix | Delete
/** @var ?Registry */
[55] Fix | Delete
protected $registry;
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* @var Client|null
[59] Fix | Delete
*/
[60] Fix | Delete
private $http_client = null;
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* @param array<int, mixed> $curl_options
[64] Fix | Delete
*/
[65] Fix | Delete
public function __construct(File $file, int $timeout = 10, ?string $useragent = null, int $max_checked_feeds = 10, bool $force_fsockopen = false, array $curl_options = [])
[66] Fix | Delete
{
[67] Fix | Delete
$this->file = $file;
[68] Fix | Delete
$this->useragent = $useragent;
[69] Fix | Delete
$this->timeout = $timeout;
[70] Fix | Delete
$this->max_checked_feeds = $max_checked_feeds;
[71] Fix | Delete
$this->force_fsockopen = $force_fsockopen;
[72] Fix | Delete
$this->curl_options = $curl_options;
[73] Fix | Delete
[74] Fix | Delete
$body = $this->file->get_body_content();
[75] Fix | Delete
[76] Fix | Delete
if (class_exists('DOMDocument') && $body != '') {
[77] Fix | Delete
$this->dom = new \DOMDocument();
[78] Fix | Delete
[79] Fix | Delete
set_error_handler([Misc::class, 'silence_errors']);
[80] Fix | Delete
try {
[81] Fix | Delete
$this->dom->loadHTML($body);
[82] Fix | Delete
} catch (\Throwable $ex) {
[83] Fix | Delete
$this->dom = null;
[84] Fix | Delete
}
[85] Fix | Delete
restore_error_handler();
[86] Fix | Delete
} else {
[87] Fix | Delete
$this->dom = null;
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Set a PSR-18 client and PSR-17 factories
[93] Fix | Delete
*
[94] Fix | Delete
* Allows you to use your own HTTP client implementations.
[95] Fix | Delete
*/
[96] Fix | Delete
final public function set_http_client(
[97] Fix | Delete
ClientInterface $http_client,
[98] Fix | Delete
RequestFactoryInterface $request_factory,
[99] Fix | Delete
UriFactoryInterface $uri_factory
[100] Fix | Delete
): void {
[101] Fix | Delete
$this->http_client = new Psr18Client($http_client, $request_factory, $uri_factory);
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* @return void
[106] Fix | Delete
*/
[107] Fix | Delete
public function set_registry(\SimplePie\Registry $registry)
[108] Fix | Delete
{
[109] Fix | Delete
$this->registry = $registry;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* @param SimplePie::LOCATOR_* $type
[114] Fix | Delete
* @param array<Response>|null $working
[115] Fix | Delete
* @return Response|null
[116] Fix | Delete
*/
[117] Fix | Delete
public function find(int $type = \SimplePie\SimplePie::LOCATOR_ALL, ?array &$working = null)
[118] Fix | Delete
{
[119] Fix | Delete
assert($this->registry !== null);
[120] Fix | Delete
[121] Fix | Delete
if ($this->is_feed($this->file)) {
[122] Fix | Delete
return $this->file;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
if (Misc::is_remote_uri($this->file->get_final_requested_uri())) {
[126] Fix | Delete
$sniffer = $this->registry->create(Content\Type\Sniffer::class, [$this->file]);
[127] Fix | Delete
if ($sniffer->get_type() !== 'text/html') {
[128] Fix | Delete
return null;
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
if ($type & ~\SimplePie\SimplePie::LOCATOR_NONE) {
[133] Fix | Delete
$this->get_base();
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
if ($type & \SimplePie\SimplePie::LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) {
[137] Fix | Delete
return $working[0];
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
if ($type & (\SimplePie\SimplePie::LOCATOR_LOCAL_EXTENSION | \SimplePie\SimplePie::LOCATOR_LOCAL_BODY | \SimplePie\SimplePie::LOCATOR_REMOTE_EXTENSION | \SimplePie\SimplePie::LOCATOR_REMOTE_BODY) && $this->get_links()) {
[141] Fix | Delete
if ($type & \SimplePie\SimplePie::LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) {
[142] Fix | Delete
return $working[0];
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
if ($type & \SimplePie\SimplePie::LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) {
[146] Fix | Delete
return $working[0];
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
if ($type & \SimplePie\SimplePie::LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) {
[150] Fix | Delete
return $working[0];
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
if ($type & \SimplePie\SimplePie::LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) {
[154] Fix | Delete
return $working[0];
[155] Fix | Delete
}
[156] Fix | Delete
}
[157] Fix | Delete
return null;
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
/**
[161] Fix | Delete
* @return bool
[162] Fix | Delete
*/
[163] Fix | Delete
public function is_feed(Response $file, bool $check_html = false)
[164] Fix | Delete
{
[165] Fix | Delete
assert($this->registry !== null);
[166] Fix | Delete
[167] Fix | Delete
if (Misc::is_remote_uri($file->get_final_requested_uri())) {
[168] Fix | Delete
$sniffer = $this->registry->create(Content\Type\Sniffer::class, [$file]);
[169] Fix | Delete
$sniffed = $sniffer->get_type();
[170] Fix | Delete
$mime_types = ['application/rss+xml', 'application/rdf+xml',
[171] Fix | Delete
'text/rdf', 'application/atom+xml', 'text/xml',
[172] Fix | Delete
'application/xml', 'application/x-rss+xml'];
[173] Fix | Delete
if ($check_html) {
[174] Fix | Delete
$mime_types[] = 'text/html';
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
return in_array($sniffed, $mime_types);
[178] Fix | Delete
} elseif (is_file($file->get_final_requested_uri())) {
[179] Fix | Delete
return true;
[180] Fix | Delete
} else {
[181] Fix | Delete
return false;
[182] Fix | Delete
}
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* @return void
[187] Fix | Delete
*/
[188] Fix | Delete
public function get_base()
[189] Fix | Delete
{
[190] Fix | Delete
assert($this->registry !== null);
[191] Fix | Delete
[192] Fix | Delete
if ($this->dom === null) {
[193] Fix | Delete
throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
[194] Fix | Delete
}
[195] Fix | Delete
$this->http_base = $this->file->get_final_requested_uri();
[196] Fix | Delete
$this->base = $this->http_base;
[197] Fix | Delete
$elements = $this->dom->getElementsByTagName('base');
[198] Fix | Delete
foreach ($elements as $element) {
[199] Fix | Delete
if ($element->hasAttribute('href')) {
[200] Fix | Delete
$base = $this->registry->call(Misc::class, 'absolutize_url', [trim($element->getAttribute('href')), $this->http_base]);
[201] Fix | Delete
if ($base === false) {
[202] Fix | Delete
continue;
[203] Fix | Delete
}
[204] Fix | Delete
$this->base = $base;
[205] Fix | Delete
$this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0;
[206] Fix | Delete
break;
[207] Fix | Delete
}
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* @return array<Response>|null
[213] Fix | Delete
*/
[214] Fix | Delete
public function autodiscovery()
[215] Fix | Delete
{
[216] Fix | Delete
$done = [];
[217] Fix | Delete
$feeds = [];
[218] Fix | Delete
$feeds = array_merge($feeds, $this->search_elements_by_tag('link', $done, $feeds));
[219] Fix | Delete
$feeds = array_merge($feeds, $this->search_elements_by_tag('a', $done, $feeds));
[220] Fix | Delete
$feeds = array_merge($feeds, $this->search_elements_by_tag('area', $done, $feeds));
[221] Fix | Delete
[222] Fix | Delete
if (!empty($feeds)) {
[223] Fix | Delete
return array_values($feeds);
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
return null;
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
/**
[230] Fix | Delete
* @param string[] $done
[231] Fix | Delete
* @param array<string, Response> $feeds
[232] Fix | Delete
* @return array<string, Response>
[233] Fix | Delete
*/
[234] Fix | Delete
protected function search_elements_by_tag(string $name, array &$done, array $feeds)
[235] Fix | Delete
{
[236] Fix | Delete
assert($this->registry !== null);
[237] Fix | Delete
[238] Fix | Delete
if ($this->dom === null) {
[239] Fix | Delete
throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
$links = $this->dom->getElementsByTagName($name);
[243] Fix | Delete
foreach ($links as $link) {
[244] Fix | Delete
if ($this->checked_feeds === $this->max_checked_feeds) {
[245] Fix | Delete
break;
[246] Fix | Delete
}
[247] Fix | Delete
if ($link->hasAttribute('href') && $link->hasAttribute('rel')) {
[248] Fix | Delete
$rel = array_unique($this->registry->call(Misc::class, 'space_separated_tokens', [strtolower($link->getAttribute('rel'))]));
[249] Fix | Delete
$line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1;
[250] Fix | Delete
[251] Fix | Delete
if ($this->base_location < $line) {
[252] Fix | Delete
$href = $this->registry->call(Misc::class, 'absolutize_url', [trim($link->getAttribute('href')), $this->base]);
[253] Fix | Delete
} else {
[254] Fix | Delete
$href = $this->registry->call(Misc::class, 'absolutize_url', [trim($link->getAttribute('href')), $this->http_base]);
[255] Fix | Delete
}
[256] Fix | Delete
if ($href === false) {
[257] Fix | Delete
continue;
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call(Misc::class, 'parse_mime', [$link->getAttribute('type')])), ['text/html', 'application/rss+xml', 'application/atom+xml'])) && !isset($feeds[$href])) {
[261] Fix | Delete
$this->checked_feeds++;
[262] Fix | Delete
$headers = [
[263] Fix | Delete
'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
[264] Fix | Delete
];
[265] Fix | Delete
[266] Fix | Delete
try {
[267] Fix | Delete
$feed = $this->get_http_client()->request(Client::METHOD_GET, $href, $headers);
[268] Fix | Delete
[269] Fix | Delete
if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed, true)) {
[270] Fix | Delete
$feeds[$href] = $feed;
[271] Fix | Delete
}
[272] Fix | Delete
} catch (ClientException $th) {
[273] Fix | Delete
// Just mark it as done and continue.
[274] Fix | Delete
}
[275] Fix | Delete
}
[276] Fix | Delete
$done[] = $href;
[277] Fix | Delete
}
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
return $feeds;
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* @return true|null
[285] Fix | Delete
*/
[286] Fix | Delete
public function get_links()
[287] Fix | Delete
{
[288] Fix | Delete
assert($this->registry !== null);
[289] Fix | Delete
[290] Fix | Delete
if ($this->dom === null) {
[291] Fix | Delete
throw new \SimplePie\Exception('DOMDocument not found, unable to use locator');
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
$links = $this->dom->getElementsByTagName('a');
[295] Fix | Delete
foreach ($links as $link) {
[296] Fix | Delete
if ($link->hasAttribute('href')) {
[297] Fix | Delete
$href = trim($link->getAttribute('href'));
[298] Fix | Delete
$parsed = $this->registry->call(Misc::class, 'parse_url', [$href]);
[299] Fix | Delete
if ($parsed['scheme'] === '' || preg_match('/^(https?|feed)?$/i', $parsed['scheme'])) {
[300] Fix | Delete
if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo()) {
[301] Fix | Delete
$href = $this->registry->call(Misc::class, 'absolutize_url', [trim($link->getAttribute('href')), $this->base]);
[302] Fix | Delete
} else {
[303] Fix | Delete
$href = $this->registry->call(Misc::class, 'absolutize_url', [trim($link->getAttribute('href')), $this->http_base]);
[304] Fix | Delete
}
[305] Fix | Delete
if ($href === false) {
[306] Fix | Delete
continue;
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
$current = $this->registry->call(Misc::class, 'parse_url', [$this->file->get_final_requested_uri()]);
[310] Fix | Delete
[311] Fix | Delete
if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) {
[312] Fix | Delete
$this->local[] = $href;
[313] Fix | Delete
} else {
[314] Fix | Delete
$this->elsewhere[] = $href;
[315] Fix | Delete
}
[316] Fix | Delete
}
[317] Fix | Delete
}
[318] Fix | Delete
}
[319] Fix | Delete
$this->local = array_unique($this->local);
[320] Fix | Delete
$this->elsewhere = array_unique($this->elsewhere);
[321] Fix | Delete
if (!empty($this->local) || !empty($this->elsewhere)) {
[322] Fix | Delete
return true;
[323] Fix | Delete
}
[324] Fix | Delete
return null;
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
/**
[328] Fix | Delete
* Extracts first `link` element with given `rel` attribute inside the `head` element.
[329] Fix | Delete
*
[330] Fix | Delete
* @return string|null
[331] Fix | Delete
*/
[332] Fix | Delete
public function get_rel_link(string $rel)
[333] Fix | Delete
{
[334] Fix | Delete
assert($this->registry !== null);
[335] Fix | Delete
[336] Fix | Delete
if ($this->dom === null) {
[337] Fix | Delete
throw new \SimplePie\Exception('DOMDocument not found, unable to use '.
[338] Fix | Delete
'locator');
[339] Fix | Delete
}
[340] Fix | Delete
if (!class_exists('DOMXpath')) {
[341] Fix | Delete
throw new \SimplePie\Exception('DOMXpath not found, unable to use '.
[342] Fix | Delete
'get_rel_link');
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
$xpath = new \DOMXpath($this->dom);
[346] Fix | Delete
$query = '(//head)[1]/link[@rel and @href]';
[347] Fix | Delete
/** @var \DOMNodeList<\DOMElement> */
[348] Fix | Delete
$queryResult = $xpath->query($query);
[349] Fix | Delete
foreach ($queryResult as $link) {
[350] Fix | Delete
$href = trim($link->getAttribute('href'));
[351] Fix | Delete
$parsed = $this->registry->call(Misc::class, 'parse_url', [$href]);
[352] Fix | Delete
if ($parsed['scheme'] === '' ||
[353] Fix | Delete
preg_match('/^https?$/i', $parsed['scheme'])) {
[354] Fix | Delete
if (method_exists($link, 'getLineNo') &&
[355] Fix | Delete
$this->base_location < $link->getLineNo()) {
[356] Fix | Delete
$href = $this->registry->call(
[357] Fix | Delete
Misc::class,
[358] Fix | Delete
'absolutize_url',
[359] Fix | Delete
[trim($link->getAttribute('href')), $this->base]
[360] Fix | Delete
);
[361] Fix | Delete
} else {
[362] Fix | Delete
$href = $this->registry->call(
[363] Fix | Delete
Misc::class,
[364] Fix | Delete
'absolutize_url',
[365] Fix | Delete
[trim($link->getAttribute('href')), $this->http_base]
[366] Fix | Delete
);
[367] Fix | Delete
}
[368] Fix | Delete
if ($href === false) {
[369] Fix | Delete
return null;
[370] Fix | Delete
}
[371] Fix | Delete
$rel_values = explode(' ', strtolower($link->getAttribute('rel')));
[372] Fix | Delete
if (in_array($rel, $rel_values)) {
[373] Fix | Delete
return $href;
[374] Fix | Delete
}
[375] Fix | Delete
}
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
return null;
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
/**
[382] Fix | Delete
* @param string[] $array
[383] Fix | Delete
* @return array<Response>|null
[384] Fix | Delete
*/
[385] Fix | Delete
public function extension(array &$array)
[386] Fix | Delete
{
[387] Fix | Delete
foreach ($array as $key => $value) {
[388] Fix | Delete
if ($this->checked_feeds === $this->max_checked_feeds) {
[389] Fix | Delete
break;
[390] Fix | Delete
}
[391] Fix | Delete
$extension = strrchr($value, '.');
[392] Fix | Delete
if ($extension !== false && in_array(strtolower($extension), ['.rss', '.rdf', '.atom', '.xml'])) {
[393] Fix | Delete
$this->checked_feeds++;
[394] Fix | Delete
[395] Fix | Delete
$headers = [
[396] Fix | Delete
'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
[397] Fix | Delete
];
[398] Fix | Delete
[399] Fix | Delete
try {
[400] Fix | Delete
$feed = $this->get_http_client()->request(Client::METHOD_GET, $value, $headers);
[401] Fix | Delete
[402] Fix | Delete
if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed)) {
[403] Fix | Delete
return [$feed];
[404] Fix | Delete
}
[405] Fix | Delete
} catch (ClientException $th) {
[406] Fix | Delete
// Just unset and continue.
[407] Fix | Delete
}
[408] Fix | Delete
[409] Fix | Delete
unset($array[$key]);
[410] Fix | Delete
}
[411] Fix | Delete
}
[412] Fix | Delete
return null;
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
/**
[416] Fix | Delete
* @param string[] $array
[417] Fix | Delete
* @return array<Response>|null
[418] Fix | Delete
*/
[419] Fix | Delete
public function body(array &$array)
[420] Fix | Delete
{
[421] Fix | Delete
foreach ($array as $key => $value) {
[422] Fix | Delete
if ($this->checked_feeds === $this->max_checked_feeds) {
[423] Fix | Delete
break;
[424] Fix | Delete
}
[425] Fix | Delete
if (preg_match('/(feed|rss|rdf|atom|xml)/i', $value)) {
[426] Fix | Delete
$this->checked_feeds++;
[427] Fix | Delete
$headers = [
[428] Fix | Delete
'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
[429] Fix | Delete
];
[430] Fix | Delete
[431] Fix | Delete
try {
[432] Fix | Delete
$feed = $this->get_http_client()->request(Client::METHOD_GET, $value, $headers);
[433] Fix | Delete
[434] Fix | Delete
if ((!Misc::is_remote_uri($feed->get_final_requested_uri()) || ($feed->get_status_code() === 200 || $feed->get_status_code() > 206 && $feed->get_status_code() < 300)) && $this->is_feed($feed)) {
[435] Fix | Delete
return [$feed];
[436] Fix | Delete
}
[437] Fix | Delete
} catch (ClientException $th) {
[438] Fix | Delete
// Just unset and continue.
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
unset($array[$key]);
[442] Fix | Delete
}
[443] Fix | Delete
}
[444] Fix | Delete
return null;
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
/**
[448] Fix | Delete
* Get a HTTP client
[449] Fix | Delete
*/
[450] Fix | Delete
private function get_http_client(): Client
[451] Fix | Delete
{
[452] Fix | Delete
assert($this->registry !== null);
[453] Fix | Delete
[454] Fix | Delete
if ($this->http_client === null) {
[455] Fix | Delete
$options = [
[456] Fix | Delete
'timeout' => $this->timeout,
[457] Fix | Delete
'redirects' => 5,
[458] Fix | Delete
'force_fsockopen' => $this->force_fsockopen,
[459] Fix | Delete
'curl_options' => $this->curl_options,
[460] Fix | Delete
];
[461] Fix | Delete
[462] Fix | Delete
if ($this->useragent !== null) {
[463] Fix | Delete
$options['useragent'] = $this->useragent;
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
return new FileClient(
[467] Fix | Delete
$this->registry,
[468] Fix | Delete
$options
[469] Fix | Delete
);
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
return $this->http_client;
[473] Fix | Delete
}
[474] Fix | Delete
}
[475] Fix | Delete
[476] Fix | Delete
class_alias('SimplePie\Locator', 'SimplePie_Locator', false);
[477] Fix | Delete
[478] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function