all_discovered_feeds.diff

Now uses isset() to avoid making an unnecessary request - Ryan McCue, 2009-06-08 23:57

Download (3.3 KB)

 
simplepie.inc (working copy)
650 650
	var $max_checked_feeds = 10;
651 651

  
652 652
	/**
653
	 * @var array All the feeds found during the autodiscovery process
654
	 * @see SimplePie::get_all_discovered_feeds()
655
	 * @access private
656
	 */
657
	var $all_discovered_feeds = array();
658

  
659
	/**
653 660
	 * @var string Web-accessible path to the handler_favicon.php file.
654 661
	 * @see SimplePie::set_favicon_handler()
655 662
	 * @access private
......
1658 1665
					{
1659 1666
						// We need to unset this so that if SimplePie::set_file() has been called that object is untouched
1660 1667
						unset($file);
1661
						if ($file = $locate->find($this->autodiscovery))
1668
						if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))
1662 1669
						{
1663 1670
							if ($cache)
1664 1671
							{
......
2641 2648
		}
2642 2649
	}
2643 2650

  
2651
	function get_all_discovered_feeds()
2652
	{
2653
		return $this->all_discovered_feeds;
2654
	}
2655

  
2644 2656
	function get_description()
2645 2657
	{
2646 2658
		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
......
14093 14105
		$this->content_type_sniffer_class = $content_type_sniffer_class;
14094 14106
	}
14095 14107

  
14096
	function find($type = SIMPLEPIE_LOCATOR_ALL)
14108
	function find($type = SIMPLEPIE_LOCATOR_ALL, array &$working)
14097 14109
	{
14098 14110
		if ($this->is_feed($this->file))
14099 14111
		{
......
14116 14128

  
14117 14129
		if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
14118 14130
		{
14119
			return $working;
14131
			return $working[0];
14120 14132
		}
14121 14133

  
14122 14134
		if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
......
14189 14201
	{
14190 14202
		$links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body));
14191 14203
		$done = array();
14204
		$feeds = array();
14192 14205
		foreach ($links as $link)
14193 14206
		{
14194 14207
			if ($this->checked_feeds === $this->max_checked_feeds)
......
14208 14221
					$href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
14209 14222
				}
14210 14223

  
14211
				if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))))
14224
				if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href]))
14212 14225
				{
14213 14226
					$this->checked_feeds++;
14214 14227
					$feed =& new $this->file_class($href, $this->timeout, 5, null, $this->useragent);
14215 14228
					if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
14216 14229
					{
14217
						return $feed;
14230
						$feeds[$href] = $feed;
14218 14231
					}
14219 14232
				}
14220 14233
				$done[] = $href;
14221 14234
			}
14222 14235
		}
14223
		return null;
14236

  
14237
		if (!empty($feeds))
14238
		{
14239
			return array_values($feeds);
14240
		}
14241
		else {
14242
			return null;
14243
		}
14224 14244
	}
14225 14245

  
14226 14246
	function get_links()