simplepie-related fixes

This commit is contained in:
Andrew Dolgov 2007-08-23 12:32:24 +01:00
parent 34c00a37f8
commit ca872b9dfa
2 changed files with 22 additions and 13 deletions

View File

@ -158,9 +158,6 @@
// support HTTP Digest authentication, so you won't be able // support HTTP Digest authentication, so you won't be able
// to access, for example, Livejournal friend-only posts. // 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); define('CONFIG_VERSION', 9);
// Expected config version. Please update this option in config.php // Expected config version. Please update this option in config.php
// if necessary (after migrating all new options from this file). // if necessary (after migrating all new options from this file).

View File

@ -431,7 +431,7 @@
} }
if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) { 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 (!defined('DAEMON_EXTENDED_DEBUG') && !$_GET['xdebug']) {
@ -441,13 +441,11 @@
if (!ENABLE_SIMPLEPIE) { if (!ENABLE_SIMPLEPIE) {
$rss = fetch_rss($fetch_url); $rss = fetch_rss($fetch_url);
} else { } else {
if (!is_dir(SIMPLEPIE_CACHE_DIR)) { $rss = new SimplePie();
mkdir(SIMPLEPIE_CACHE_DIR); $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT);
} $rss->set_feed_url($fetch_url);
$rss->set_output_encoding('UTF-8');
$rss = new SimplePie($fetch_url, SIMPLEPIE_CACHE_DIR);
$rss->init(); $rss->init();
$rss->handle_content_type();
} }
// print_r($rss); // print_r($rss);
@ -460,7 +458,13 @@
$feed = db_escape_string($feed); $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']) { if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
_debug("update_rss_feed: processing feed data..."); _debug("update_rss_feed: processing feed data...");
@ -1069,11 +1073,19 @@
// db_query($link, "COMMIT"); // db_query($link, "COMMIT");
} else { } else {
if (ENABLE_SIMPLEPIE) { if (ENABLE_SIMPLEPIE) {
$error_msg = mb_substr(db_escape_string($rss->error()), 0, 250); $error_msg = mb_substr($rss->error(), 0, 250);
} else { } 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, db_query($link,
"UPDATE ttrss_feeds SET last_error = '$error_msg', "UPDATE ttrss_feeds SET last_error = '$error_msg',
last_updated = NOW() WHERE id = '$feed'"); last_updated = NOW() WHERE id = '$feed'");