]> git.wh0rd.org Git - tt-rss.git/commitdiff
simplepie-related fixes
authorAndrew Dolgov <fox@bah.spb.su>
Thu, 23 Aug 2007 11:32:24 +0000 (12:32 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Thu, 23 Aug 2007 11:32:24 +0000 (12:32 +0100)
config.php-dist
functions.php

index bb98c4aab8f74acca8590c84c089e0cad8d3ef56..3e412aef9c787242af3e2b69c71b801996e278c8 100644 (file)
        // support HTTP Digest authentication, so you won't be able
        // to access, for example, Livejournal friend-only posts.       
 
-       define('SIMPLEPIE_CACHE_DIR', '/var/tmp/simplepie-ttrss-cache');
-       // Cache directory for SimplePie
-
        define('CONFIG_VERSION', 9);
        // Expected config version. Please update this option in config.php
        // if necessary (after migrating all new options from this file).
index 48857784e5ce7437078290116b557b2d866649a9..97b12ec463f88f38a81e3b49ea53471a1c30fb3f 100644 (file)
                }
 
                if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
-                       _debug("update_rss_feed: fetching...");
+                       _debug("update_rss_feed: fetching [$fetch_url]...");
                }
 
                if (!defined('DAEMON_EXTENDED_DEBUG') && !$_GET['xdebug']) {
                if (!ENABLE_SIMPLEPIE) {
                        $rss = fetch_rss($fetch_url);
                } else {
-                       if (!is_dir(SIMPLEPIE_CACHE_DIR)) {
-                               mkdir(SIMPLEPIE_CACHE_DIR);
-                       }
-
-                       $rss = new SimplePie($fetch_url, SIMPLEPIE_CACHE_DIR);
+                       $rss = new SimplePie();
+                       $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT);
+                       $rss->set_feed_url($fetch_url);
+                       $rss->set_output_encoding('UTF-8');
                        $rss->init();
-                       $rss->handle_content_type();
                }
 
 //             print_r($rss);
 
                $feed = db_escape_string($feed);
 
-               if ($rss) {
+               if (ENABLE_SIMPLEPIE) {
+                       $fetch_ok = !$rss->error();
+               } else {
+                       $fetch_ok = !!$rss;
+               }
+
+               if ($fetch_ok) {
 
                        if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
                                _debug("update_rss_feed: processing feed data...");
 //                     db_query($link, "COMMIT");
 
                } else {
+
                        if (ENABLE_SIMPLEPIE) {
-                               $error_msg = mb_substr(db_escape_string($rss->error()), 0, 250);
+                               $error_msg = mb_substr($rss->error(), 0, 250);
                        } else {
-                               $error_msg = mb_substr(db_escape_string(magpie_error()), 0, 250);
+                               $error_msg = mb_substr(magpie_error(), 0, 250);
+                       }
+
+                       if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
+                               _debug("update_rss_feed: error fetching feed: $error_msg");
                        }
+
+                       $error_msg = db_escape_string($error_msg);
+
                        db_query($link, 
                                "UPDATE ttrss_feeds SET last_error = '$error_msg', 
                                        last_updated = NOW() WHERE id = '$feed'");