Changeset 52393 for trunk/src/wp-includes/class-simplepie.php
- Timestamp:
- 12/20/2021 07:31:37 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-simplepie.php
r49176 r52393 461 461 462 462 /** 463 * @var int HTTP status code 464 * @see SimplePie::status_code() 465 * @access private 466 */ 467 public $status_code; 468 469 /** 463 470 * @var object Instance of SimplePie_Sanitize (or other class) 464 471 * @see SimplePie::set_sanitize_class() … … 945 952 946 953 /** 954 * Return the filename (i.e. hash, without path and without extension) of the file to cache a given URL. 955 * @param string $url The URL of the feed to be cached. 956 * @return string A filename (i.e. hash, without path and without extension). 957 */ 958 public function get_cache_filename($url) 959 { 960 // Append custom parameters to the URL to avoid cache pollution in case of multiple calls with different parameters. 961 $url .= $this->force_feed ? '#force_feed' : ''; 962 $options = array(); 963 if ($this->timeout != 10) 964 { 965 $options[CURLOPT_TIMEOUT] = $this->timeout; 966 } 967 if ($this->useragent !== SIMPLEPIE_USERAGENT) 968 { 969 $options[CURLOPT_USERAGENT] = $this->useragent; 970 } 971 if (!empty($this->curl_options)) 972 { 973 foreach ($this->curl_options as $k => $v) 974 { 975 $options[$k] = $v; 976 } 977 } 978 if (!empty($options)) 979 { 980 ksort($options); 981 $url .= '#' . urlencode(var_export($options, true)); 982 } 983 return call_user_func($this->cache_name_function, $url); 984 } 985 986 /** 947 987 * Set whether feed items should be sorted into reverse chronological order 948 988 * … … 1182 1222 $this->add_attributes(false); 1183 1223 $this->set_image_handler(false); 1224 $this->set_https_domains(array()); 1184 1225 } 1185 1226 } … … 1285 1326 1286 1327 /** 1328 * Set the list of domains for which to force HTTPS. 1329 * @see SimplePie_Sanitize::set_https_domains() 1330 * @param array List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net'). 1331 */ 1332 public function set_https_domains($domains = array()) 1333 { 1334 if (is_array($domains)) 1335 { 1336 $this->sanitize->set_https_domains($domains); 1337 } 1338 } 1339 1340 /** 1287 1341 * Set the handler to enable the display of cached images. 1288 1342 * … … 1409 1463 if ($this->cache && $parsed_feed_url['scheme'] !== '') 1410 1464 { 1411 $ url = $this->feed_url . ($this->force_feed ? '#force_feed' : '');1412 $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $url), 'spc'));1465 $filename = $this->get_cache_filename($this->feed_url); 1466 $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, $filename, 'spc')); 1413 1467 } 1414 1468 … … 1550 1604 * 1551 1605 * If the data is already cached, attempt to fetch it from there instead 1552 * @param SimplePie_Cache |false $cache Cache handler, or false to not load from the cache1606 * @param SimplePie_Cache_Base|false $cache Cache handler, or false to not load from the cache 1553 1607 * @return array|true Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type 1554 1608 */ … … 1613 1667 1614 1668 $file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options)); 1669 $this->status_code = $file->status_code; 1615 1670 1616 1671 if ($file->success) … … 1667 1722 } 1668 1723 } 1724 $this->status_code = $file->status_code; 1725 1669 1726 // If the file connection has an error, set SimplePie::error to that and quit 1670 1727 if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) … … 1774 1831 1775 1832 /** 1833 * Get the last HTTP status code 1834 * 1835 * @return int Status code 1836 */ 1837 public function status_code() 1838 { 1839 return $this->status_code; 1840 } 1841 1842 /** 1776 1843 * Get the raw XML 1777 1844 * … … 2616 2683 } 2617 2684 2618 if (isset($this->data['headers']['link']) && 2619 preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/', 2620 $this->data['headers']['link'], $match)) 2621 { 2622 return array($match[1]); 2623 } 2624 else if (isset($this->data['links'][$rel])) 2685 if (isset($this->data['headers']['link'])) 2686 { 2687 $link_headers = $this->data['headers']['link']; 2688 if (is_string($link_headers)) { 2689 $link_headers = array($link_headers); 2690 } 2691 $matches = preg_filter('/<([^>]+)>; rel='.preg_quote($rel).'/', '$1', $link_headers); 2692 if (!empty($matches)) { 2693 return $matches; 2694 } 2695 } 2696 2697 if (isset($this->data['links'][$rel])) 2625 2698 { 2626 2699 return $this->data['links'][$rel];
Note: See TracChangeset
for help on using the changeset viewer.