summaryrefslogtreecommitdiff
path: root/classes/rssutils.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/rssutils.php')
-rwxr-xr-xclasses/rssutils.php58
1 files changed, 28 insertions, 30 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php
index 3954f76dc..857bc2948 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -187,11 +187,11 @@ class RSSUtils {
// -1 can be caused by a SIGCHLD handler which daemon master process installs (not every setup, apparently)
if ($exit_code != 0 && $exit_code != -1) {
- $esth = $pdo->prepare("SELECT last_error FROM ttrss_feeds WHERE id = ?");
- $esth->execute([$tline["id"]]);
+ $festh = $pdo->prepare("SELECT last_error FROM ttrss_feeds WHERE id = ?");
+ $festh->execute([$tline["id"]]);
- if ($erow = $esth->fetch()) {
- $error_message = $erow["last_error"];
+ if ($ferow = $festh->fetch()) {
+ $error_message = $ferow["last_error"];
} else {
$error_message = "N/A";
}
@@ -201,6 +201,13 @@ class RSSUtils {
Logger::get()->log(E_USER_NOTICE,
sprintf("Update process for feed %d (%s, owner UID: %d) failed with exit code: %d (%s).",
$tline["id"], clean($tline["title"]), $tline["owner_uid"], $exit_code, clean($error_message)));
+
+ $combined_error_message = sprintf("Update process failed with exit code: %d (%s)",
+ $exit_code, clean($error_message));
+
+ # mark failed feed as having an update error (unless it is already marked)
+ $fusth = $pdo->prepare("UPDATE ttrss_feeds SET last_error = ? WHERE id = ? AND last_error = ''");
+ $fusth->execute([$combined_error_message, $tline["id"]]);
}
} else {
@@ -857,7 +864,7 @@ class RSSUtils {
if (Debug::get_loglevel() >= Debug::$LOG_EXTENDED) {
Debug::log("matched filters: ", Debug::$LOG_VERBOSE);
- if (count($matched_filters != 0)) {
+ if (count($matched_filters) != 0) {
print_r($matched_filters);
}
@@ -1167,7 +1174,7 @@ class RSSUtils {
foreach ($article_filters as $f) {
if ($f["type"] == "tag") {
- $manual_tags = trim_array(explode(",", $f["param"]));
+ $manual_tags = array_map('trim', explode(",", mb_strtolower($f["param"])));
foreach ($manual_tags as $tag) {
array_push($entry_tags, $tag);
@@ -1177,28 +1184,19 @@ class RSSUtils {
// Skip boring tags
- $boring_tags = trim_array(explode(",", mb_strtolower(get_pref(
- 'BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
-
- $filtered_tags = array();
- $tags_to_cache = array();
-
- foreach ($entry_tags as $tag) {
- if (array_search($tag, $boring_tags) === false) {
- array_push($filtered_tags, $tag);
- }
- }
+ $boring_tags = array_map('trim',
+ explode(",", mb_strtolower(
+ get_pref('BLACKLISTED_TAGS', $owner_uid))));
- $filtered_tags = array_unique($filtered_tags);
+ $entry_tags = FeedItem_Common::normalize_categories(
+ array_unique(
+ array_diff($entry_tags, $boring_tags)));
- if (Debug::get_loglevel() >= Debug::$LOG_VERBOSE) {
- Debug::log("filtered tags: " . implode(", ", $filtered_tags), Debug::$LOG_VERBOSE);
-
- }
+ Debug::log("filtered tags: " . implode(", ", $entry_tags), Debug::$LOG_VERBOSE);
// Save article tags in the database
- if (count($filtered_tags) > 0) {
+ if (count($entry_tags) > 0) {
$tsth = $pdo->prepare("SELECT id FROM ttrss_tags
WHERE tag_name = ? AND post_int_id = ? AND
@@ -1208,25 +1206,25 @@ class RSSUtils {
(owner_uid,tag_name,post_int_id)
VALUES (?, ?, ?)");
- $filtered_tags = FeedItem_Common::normalize_categories($filtered_tags);
-
- foreach ($filtered_tags as $tag) {
+ foreach ($entry_tags as $tag) {
$tsth->execute([$tag, $entry_int_id, $owner_uid]);
if (!$tsth->fetch()) {
$usth->execute([$owner_uid, $tag, $entry_int_id]);
}
-
- array_push($tags_to_cache, $tag);
}
/* update the cache */
- $tags_str = join(",", $tags_to_cache);
$tsth = $pdo->prepare("UPDATE ttrss_user_entries
SET tag_cache = ? WHERE ref_id = ?
AND owner_uid = ?");
- $tsth->execute([$tags_str, $entry_ref_id, $owner_uid]);
+
+ $tsth->execute([
+ join(",", $entry_tags),
+ $entry_ref_id,
+ $owner_uid
+ ]);
}
Debug::log("article processed", Debug::$LOG_VERBOSE);