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
// 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).

View File

@ -431,7 +431,7 @@
}
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']) {
@ -441,13 +441,11 @@
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);
@ -460,7 +458,13 @@
$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...");
@ -1069,11 +1073,19 @@
// 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'");