Permalink
Browse files

Merge branch 'master' of github.com:radgeek/feedwordpress

  • Loading branch information...
2 parents 0f9987d + ed69a41 commit 5a2b04b1e598330f14da3e3b67d2104d2b85ade2 Charles Johnson committed Dec 16, 2012
Showing with 35 additions and 2 deletions.
  1. +10 −1 feedwordpress.php
  2. +25 −1 feedwordpress_parser.class.php
View
@@ -601,6 +601,7 @@ function syndication_comments_feed_link ($link) {
// that value here.
$source = get_syndication_feed_object();
$replacement = NULL;
+
if ($source->setting('munge comments feed links', 'munge_comments_feed_links', 'yes') != 'no') :
$commentFeeds = get_post_custom_values('wfw:commentRSS');
if (
@@ -928,7 +929,14 @@ function subscription ($which) {
if (isset($this->feeds[$which])) :
$sub = $this->feeds[$which];
endif;
-
+
+ // If it's not in the in-memory cache already, try to load it from DB.
+ // This is necessary to fill requests for subscriptions that we don't
+ // cache in memory, e.g. for deactivated feeds.
+ if (is_null($sub)) :
+ $sub = get_bookmark($which);
+ endif;
+
// Load 'er up if you haven't already.
if (!is_null($sub) and !($sub InstanceOf SyndicatedLink)) :
$link = new SyndicatedLink($sub);
@@ -1505,6 +1513,7 @@ function syndicated_links ($args = array()) {
else :
$links = array();
endif;
+
return $links;
} // function FeedWordPress::syndicated_links()
@@ -1,5 +1,17 @@
<?php
class FeedWordPress_Parser extends SimplePie_Parser {
+ function reset_parser (&$xml) {
+ xml_parser_free($xml);
+
+ $xml = xml_parser_create_ns($this->encoding, $this->separator);
+ xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
+ xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_object($xml, $this);
+ xml_set_character_data_handler($xml, 'cdata');
+ xml_set_element_handler($xml, 'tag_open', 'tag_close');
+ xml_set_start_namespace_decl_handler($xml, 'start_xmlns');
+ }
+
function parse (&$data, $encoding) {
$data = apply_filters('feedwordpress_parser_parse', $data, $encoding, $this);
@@ -78,7 +90,19 @@ function parse (&$data, $encoding) {
xml_set_start_namespace_decl_handler($xml, 'start_xmlns');
// Parse!
- if (!xml_parse($xml, $data, true))
+ $parseResults = xml_parse($xml, $data, true);
+
+ $endOfJunk = strpos($data, '<?xml');
+ if (!$parseResults and $endOfJunk > 0) :
+ // There is some junk before the feed prolog. Try to get rid of it.
+ $newData = substr($data, $endOfJunk);
+ $newData = trim($newData);
+ $this->reset_parser($xml);
+
+ $parseResults = xml_parse($xml, $newData, true);
+ endif;
+
+ if (!$parseResults)
{
if (class_exists('DOMDocument')) :
libxml_use_internal_errors(true);

0 comments on commit 5a2b04b

Please sign in to comment.