Ticket #11585: 11585.diff
File 11585.diff, 3.6 KB (added by , 12 years ago) |
---|
-
wp-includes/class-simplepie.php
1541 1541 $this->data = array(); 1542 1542 } 1543 1543 } 1544 1544 1545 // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. 1545 1546 if (!isset($file)) 1546 1547 { … … 1553 1554 $headers = array( 1554 1555 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', 1555 1556 ); 1557 1556 1558 $file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen)); 1557 1559 } 1558 1560 } … … 1560 1562 if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) 1561 1563 { 1562 1564 $this->error = $file->error; 1565 $this->cache_results( $cache, $this->feed_url ); 1563 1566 return !empty($this->data); 1564 1567 } 1565 1568 … … 1578 1581 { 1579 1582 $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed."; 1580 1583 $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); 1584 $this->cache_results( $cache, $this->feed_url ); 1581 1585 return false; 1582 1586 } 1583 1587 } … … 1586 1590 // This is usually because DOMDocument doesn't exist 1587 1591 $this->error = $e->getMessage(); 1588 1592 $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, $e->getFile(), $e->getLine())); 1593 $this->cache_results( $cache, $this->feed_url ); 1589 1594 return false; 1590 1595 } 1591 if ($cache) 1592 { 1593 $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); 1594 if (!$cache->save($this)) 1595 { 1596 trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); 1597 } 1598 $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc')); 1599 } 1596 1597 $this->cache_results( $cache, $file->url ); 1600 1598 $this->feed_url = $file->url; 1601 1599 } 1602 1600 $locate = null; … … 1611 1609 return array($headers, $sniffed); 1612 1610 } 1613 1611 1612 1614 1613 /** 1614 * Cache the results of the feed request. 1615 * 1616 * @param SimplePie_Cache|false $cache Cache handler, or false to not load from the cache 1617 * @param string $feedurl 1618 */ 1619 public function cache_results( &$cache, $feedurl ) 1620 { 1621 if ($cache) 1622 { 1623 $this->data = array('url' => $this->feed_url, 'build' => SIMPLEPIE_BUILD); 1624 1625 // A weird little hack to ensure that we cache errors. 1626 if (empty($this->error)) 1627 { 1628 $this->data['feed_url'] = $feedurl; 1629 } 1630 1631 if (!$cache->save($this)) 1632 { 1633 trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); 1634 } 1635 1636 $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $feedurl), 'spc')); 1637 } 1638 } 1639 1640 /** 1615 1641 * Get the error message for the occured error 1616 1642 * 1617 1643 * @return string|array Error message, or array of messages for multifeeds