From b8f316dc288d759938aaae1e49d4bd2093dc99a2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 1 May 2013 17:56:21 +0400 Subject: [PATCH] change caching to save xml data, remove RDF init section --- classes/feedparser.php | 3 --- include/rssfuncs.php | 13 ++++++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/classes/feedparser.php b/classes/feedparser.php index fb6344cc0..ed284a043 100644 --- a/classes/feedparser.php +++ b/classes/feedparser.php @@ -63,9 +63,6 @@ class FeedParser { array_push($this->items, new FeedItem_Atom($article)); } - break; - case $this::FEED_RDF: - break; case $this::FEED_RSS: diff --git a/include/rssfuncs.php b/include/rssfuncs.php index ec0ca5a4f..21040e5a7 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -245,7 +245,7 @@ $date_feed_processed = date('Y-m-d H:i'); - $cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".feed"; + $cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".feed2"; // Ignore cache if new feed or manual update. $cache_age = ($no_cache || is_null($last_updated) || strpos($last_updated, '1970-01-01') === 0) ? 30 : get_feed_update_interval($feed) * 60; @@ -269,11 +269,10 @@ _debug("using local cache.", $debug_enabled); if ($cache_timestamp > $last_article_timestamp) { - @$rss_data = file_get_contents($cache_filename); + @$feed_data = file_get_contents($cache_filename); - if ($rss_data) { - $rss_hash = sha1($rss_data); - @$rss = unserialize($rss_data); + if ($feed_data) { + $rss_hash = sha1($feed_data); } } else if (!$force_refetch) { _debug("local cache valid and older than last_updated, nothing to do.", $debug_enabled); @@ -385,9 +384,9 @@ $rss_data = serialize($rss); $new_rss_hash = sha1($rss_data); - if ($new_rss_hash != $rss_hash) { + if ($new_rss_hash != $rss_hash && count($rss->get_items()) > 0 ) { _debug("saving $cache_filename", $debug_enabled); - //@file_put_contents($cache_filename, serialize($rss)); NOT YET + @file_put_contents($cache_filename, $rss_data); } }