]> git.wh0rd.org Git - tt-rss.git/commitdiff
daemon: cache parser object while processing a batch of feeds withsame url on first...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 25 Oct 2013 10:42:43 +0000 (14:42 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 25 Oct 2013 10:42:43 +0000 (14:42 +0400)
include/rssfuncs.php

index 13d6baeab99bea508de3cde15697724ad058a338..bfbec0919275c29c4fc722766e27c84ddf4a4364 100644 (file)
                        ORDER BY ttrss_feeds.id $query_limit");
 
                        if (db_num_rows($tmp_result) > 0) {
+                               $rss = false;
+
                                while ($tline = db_fetch_assoc($tmp_result)) {
                                        if($debug) _debug(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]);
-                                       update_rss_feed($tline["id"], true);
+                                       $rss = update_rss_feed($tline["id"], true, false, $rss);
                                        _debug_suppress(false);
                                        ++$nf;
                                }
        } // function update_daemon_common
 
        // ignore_daemon is not used
-       function update_rss_feed($feed, $ignore_daemon = false, $no_cache = false) {
+       function update_rss_feed($feed, $ignore_daemon = false, $no_cache = false, $rss = false) {
 
                $debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
 
                $pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
                $pluginhost->load_data();
 
-               $rss = false;
-               $rss_hash = false;
+               if ($rss && is_object($rss) && get_class($rss) == "FeedParser") {
+                       _debug("using previously initialized parser object");
+               } else {
+                       $rss_hash = false;
 
-               $force_refetch = isset($_REQUEST["force_refetch"]);
+                       $force_refetch = isset($_REQUEST["force_refetch"]);
 
-               if (file_exists($cache_filename) &&
-                       is_readable($cache_filename) &&
-                       !$auth_login && !$auth_pass &&
-                       filemtime($cache_filename) > time() - 30) {
+                       if (file_exists($cache_filename) &&
+                               is_readable($cache_filename) &&
+                               !$auth_login && !$auth_pass &&
+                               filemtime($cache_filename) > time() - 30) {
 
-                       _debug("using local cache.", $debug_enabled);
+                               _debug("using local cache.", $debug_enabled);
 
-                       @$feed_data = file_get_contents($cache_filename);
+                               @$feed_data = file_get_contents($cache_filename);
 
-                       if ($feed_data) {
-                               $rss_hash = sha1($feed_data);
-                       }
+                               if ($feed_data) {
+                                       $rss_hash = sha1($feed_data);
+                               }
 
-               } else {
-                       _debug("local cache will not be used for this feed", $debug_enabled);
+                       } else {
+                               _debug("local cache will not be used for this feed", $debug_enabled);
+                       }
                }
 
                if (!$rss) {
 
                        db_query(
                                "UPDATE ttrss_feeds SET last_error = '$error_msg',
-                                       last_updated = NOW() WHERE id = '$feed'");
-               }
+                               last_updated = NOW() WHERE id = '$feed'");
 
-               unset($rss);
+                       unset($rss);
+               }
 
                _debug("done", $debug_enabled);
+
+               return $rss;
        }
 
        function cache_images($html, $site_url, $debug) {