if (!$tmph->fetch()) {
$tmph = $pdo->prepare("INSERT INTO ttrss_feedbrowser_cache
- (feed_url, site_url, title, subscribers)
- VALUES
+ (feed_url, site_url, title, subscribers)
+ VALUES
(?, ?, ?, ?)");
$tmph->execute([$feed_url, $site_url, $title, $subscribers]);
array_push($batch_owners, $tline["owner_uid"]);
$fstarted = microtime(true);
- RSSUtils::update_rss_feed($tline["id"], true, false);
+
+ try {
+ RSSUtils::update_rss_feed($tline["id"], true, false);
+ } catch (PDOException $e) {
+ Logger::get()->log_error(E_USER_NOTICE, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
+
+ try {
+ $pdo->rollback();
+ } catch (PDOException $e) {
+ // it doesn't matter if there wasn't actually anything to rollback, PDO Exception can be
+ // thrown outside of an active transaction during feed update
+ }
+ }
_debug_suppress(false);
_debug(sprintf(" %.4f (sec)", microtime(true) - $fstarted));
$pdo = Db::pdo();
- $sth = $pdo->prepare("SELECT owner_uid,feed_url,auth_pass,auth_login,auth_pass_encrypted
+ $sth = $pdo->prepare("SELECT owner_uid,feed_url,auth_pass,auth_login
FROM ttrss_feeds WHERE id = ?");
$sth->execute([$feed]);
if ($row = $sth->fetch()) {
$owner_uid = $row["owner_uid"];
-
- $auth_pass_encrypted = $row["auth_pass_encrypted"];
-
$auth_login = $row["auth_login"];
$auth_pass = $row["auth_pass"];
-
- if ($auth_pass_encrypted && function_exists("mcrypt_decrypt")) {
- require_once "crypt.php";
- $auth_pass = decrypt_string($auth_pass);
- }
-
$fetch_url = $row["feed_url"];
$pluginhost = new PluginHost();
$sth = $pdo->prepare("SELECT id,update_interval,auth_login,
feed_url,auth_pass,cache_images,
mark_unread_on_update, owner_uid,
- auth_pass_encrypted, feed_language,
- last_modified,
- ".SUBSTRING_FOR_DATE."(last_unconditional, 1, 19) AS last_unconditional
+ auth_pass_encrypted, feed_language,
+ last_modified,
+ ".SUBSTRING_FOR_DATE."(last_unconditional, 1, 19) AS last_unconditional
FROM ttrss_feeds WHERE id = ?");
$sth->execute([$feed]);
-
+
if ($row = $sth->fetch()) {
$owner_uid = $row["owner_uid"];
$mark_unread_on_update = $row["mark_unread_on_update"];
- $auth_pass_encrypted = $row["auth_pass_encrypted"];
$sth = $pdo->prepare("UPDATE ttrss_feeds SET last_update_started = NOW()
WHERE id = ?");
$auth_login = $row["auth_login"];
$auth_pass = $row["auth_pass"];
-
- if ($auth_pass_encrypted && function_exists("mcrypt_decrypt")) {
- require_once "crypt.php";
- $auth_pass = decrypt_string($auth_pass);
- }
-
$stored_last_modified = $row["last_modified"];
$last_unconditional = $row["last_unconditional"];
$cache_images = $row["cache_images"];
$fetch_url = $row["feed_url"];
+
$feed_language = mb_strtolower($row["feed_language"]);
if (!$feed_language) $feed_language = 'english';
$entry_link = rewrite_relative_url($site_url, $item->get_link());
+ $entry_language = mb_substr(trim($item->get_language()), 0, 2);
+
_debug("title $entry_title", $debug_enabled);
_debug("link $entry_link", $debug_enabled);
+ _debug("language $entry_language", $debug_enabled);
if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp);;
$base_entry_id = $row["id"];
$entry_stored_hash = $row["content_hash"];
$article_labels = Article::get_article_labels($base_entry_id, $owner_uid);
- $entry_language = $row["lang"];
$existing_tags = Article::get_article_tags($base_entry_id, $owner_uid);
$entry_tags = array_unique(array_merge($entry_tags, $existing_tags));
$base_entry_id = false;
$entry_stored_hash = "";
$article_labels = array();
- $entry_language = "";
}
$article = array("owner_uid" => $owner_uid, // read only
$usth = $pdo->prepare(
"INSERT INTO ttrss_entries
- (title,
+ (title,
guid,
link,
updated,
_debug("user record FOUND: RID: $entry_ref_id, IID: $entry_int_id", $debug_enabled);
} else {
-
+
_debug("user record not found, creating...", $debug_enabled);
if ($score >= -500 && !RSSUtils::find_article_filter($article_filters, 'catchup') && !$entry_force_catchup) {
num_comments = :num_comments,
plugin_data = :plugin_data,
author = :author,
- lang = :lang
+ lang = :lang
WHERE id = :id");
$params = [":title" => $entry_title,
}
$esth = $pdo->prepare("SELECT id FROM ttrss_enclosures
- WHERE content_url = ? AND post_id = ?");
+ WHERE content_url = ? AND content_type = ? AND post_id = ?");
$usth = $pdo->prepare("INSERT INTO ttrss_enclosures
(content_url, content_type, title, duration, post_id, width, height) VALUES
$enc_width = intval($enc[4]);
$enc_height = intval($enc[5]);
- $esth->execute([$enc_url, $entry_ref_id]);
+ $esth->execute([$enc_url, $enc_type, $entry_ref_id]);
if (!$esth->fetch()) {
$usth->execute([$enc_url, $enc_type, (string)$enc_title, $enc_dur, $entry_ref_id, $enc_width, $enc_height]);
if ($file_content && strlen($file_content) > MIN_CACHE_FILE_SIZE) {
file_put_contents($local_filename, $file_content);
}
- } else {
+ } else if (is_writable($local_filename)) {
touch($local_filename);
}
}
$local_filename = CACHE_DIR . "/images/" . sha1($src);
- if ($debug) _debug("cache_media: downloading: $src to $local_filename");
+ if ($debug) _debug("cache_media: checking $src");
if (!file_exists($local_filename)) {
+ if ($debug) _debug("cache_media: downloading: $src to $local_filename");
+
$file_content = fetch_file_contents($src);
if ($file_content && strlen($file_content) > MIN_CACHE_FILE_SIZE) {
file_put_contents($local_filename, $file_content);
}
- } else {
+ } else if (is_writable($local_filename)) {
touch($local_filename);
}
}
}
static function expire_cached_files($debug) {
- foreach (array("simplepie", "feeds", "images", "export", "upload") as $dir) {
+ foreach (array("feeds", "images", "export", "upload") as $dir) {
$cache_dir = CACHE_DIR . "/$dir";
// if ($debug) _debug("Expiring $cache_dir");