External Libraries: Update the SimplePie library to version 1.5.7.
This version shows significant improvements in the compatibility of SimplePie with PHP 8.0, 8.1, and even contains an initial PHP 8.2 fix. The release also contains a number of other bug fixes. Release notes: https://github.com/simplepie/simplepie/releases/tag/1.5.7 For a full list of changes in this update, see the SimplePie GitHub: https://github.com/simplepie/simplepie/compare/1.5.6...1.5.7 Follow-up to [47733], [49176]. Props jrf, SergeyBiryukov. Fixes #54659. Built from https://develop.svn.wordpress.org/trunk@52393 git-svn-id: http://core.svn.wordpress.org/trunk@51985 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -459,6 +459,13 @@ class SimplePie
|
||||
*/
|
||||
public $error;
|
||||
|
||||
/**
|
||||
* @var int HTTP status code
|
||||
* @see SimplePie::status_code()
|
||||
* @access private
|
||||
*/
|
||||
public $status_code;
|
||||
|
||||
/**
|
||||
* @var object Instance of SimplePie_Sanitize (or other class)
|
||||
* @see SimplePie::set_sanitize_class()
|
||||
@@ -943,6 +950,39 @@ class SimplePie
|
||||
$this->cache_location = (string) $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the filename (i.e. hash, without path and without extension) of the file to cache a given URL.
|
||||
* @param string $url The URL of the feed to be cached.
|
||||
* @return string A filename (i.e. hash, without path and without extension).
|
||||
*/
|
||||
public function get_cache_filename($url)
|
||||
{
|
||||
// Append custom parameters to the URL to avoid cache pollution in case of multiple calls with different parameters.
|
||||
$url .= $this->force_feed ? '#force_feed' : '';
|
||||
$options = array();
|
||||
if ($this->timeout != 10)
|
||||
{
|
||||
$options[CURLOPT_TIMEOUT] = $this->timeout;
|
||||
}
|
||||
if ($this->useragent !== SIMPLEPIE_USERAGENT)
|
||||
{
|
||||
$options[CURLOPT_USERAGENT] = $this->useragent;
|
||||
}
|
||||
if (!empty($this->curl_options))
|
||||
{
|
||||
foreach ($this->curl_options as $k => $v)
|
||||
{
|
||||
$options[$k] = $v;
|
||||
}
|
||||
}
|
||||
if (!empty($options))
|
||||
{
|
||||
ksort($options);
|
||||
$url .= '#' . urlencode(var_export($options, true));
|
||||
}
|
||||
return call_user_func($this->cache_name_function, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether feed items should be sorted into reverse chronological order
|
||||
*
|
||||
@@ -1181,6 +1221,7 @@ class SimplePie
|
||||
$this->strip_attributes(false);
|
||||
$this->add_attributes(false);
|
||||
$this->set_image_handler(false);
|
||||
$this->set_https_domains(array());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1283,6 +1324,19 @@ class SimplePie
|
||||
$this->sanitize->set_url_replacements($element_attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of domains for which to force HTTPS.
|
||||
* @see SimplePie_Sanitize::set_https_domains()
|
||||
* @param array List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net').
|
||||
*/
|
||||
public function set_https_domains($domains = array())
|
||||
{
|
||||
if (is_array($domains))
|
||||
{
|
||||
$this->sanitize->set_https_domains($domains);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the handler to enable the display of cached images.
|
||||
*
|
||||
@@ -1408,8 +1462,8 @@ class SimplePie
|
||||
// Decide whether to enable caching
|
||||
if ($this->cache && $parsed_feed_url['scheme'] !== '')
|
||||
{
|
||||
$url = $this->feed_url . ($this->force_feed ? '#force_feed' : '');
|
||||
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $url), 'spc'));
|
||||
$filename = $this->get_cache_filename($this->feed_url);
|
||||
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, $filename, 'spc'));
|
||||
}
|
||||
|
||||
// Fetch the data via SimplePie_File into $this->raw_data
|
||||
@@ -1549,7 +1603,7 @@ class SimplePie
|
||||
* Fetch the data via SimplePie_File
|
||||
*
|
||||
* If the data is already cached, attempt to fetch it from there instead
|
||||
* @param SimplePie_Cache|false $cache Cache handler, or false to not load from the cache
|
||||
* @param SimplePie_Cache_Base|false $cache Cache handler, or false to not load from the cache
|
||||
* @return array|true Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type
|
||||
*/
|
||||
protected function fetch_data(&$cache)
|
||||
@@ -1612,6 +1666,7 @@ class SimplePie
|
||||
}
|
||||
|
||||
$file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options));
|
||||
$this->status_code = $file->status_code;
|
||||
|
||||
if ($file->success)
|
||||
{
|
||||
@@ -1666,6 +1721,8 @@ class SimplePie
|
||||
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options));
|
||||
}
|
||||
}
|
||||
$this->status_code = $file->status_code;
|
||||
|
||||
// If the file connection has an error, set SimplePie::error to that and quit
|
||||
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
|
||||
{
|
||||
@@ -1772,6 +1829,16 @@ class SimplePie
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last HTTP status code
|
||||
*
|
||||
* @return int Status code
|
||||
*/
|
||||
public function status_code()
|
||||
{
|
||||
return $this->status_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw XML
|
||||
*
|
||||
@@ -2615,13 +2682,19 @@ class SimplePie
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->data['headers']['link']) &&
|
||||
preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/',
|
||||
$this->data['headers']['link'], $match))
|
||||
if (isset($this->data['headers']['link']))
|
||||
{
|
||||
return array($match[1]);
|
||||
$link_headers = $this->data['headers']['link'];
|
||||
if (is_string($link_headers)) {
|
||||
$link_headers = array($link_headers);
|
||||
}
|
||||
$matches = preg_filter('/<([^>]+)>; rel='.preg_quote($rel).'/', '$1', $link_headers);
|
||||
if (!empty($matches)) {
|
||||
return $matches;
|
||||
}
|
||||
}
|
||||
else if (isset($this->data['links'][$rel]))
|
||||
|
||||
if (isset($this->data['links'][$rel]))
|
||||
{
|
||||
return $this->data['links'][$rel];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user