return sha1(implode(",", $pluginhost->get_plugin_names()) . $tmp);
}
+ // Strips utf8mb4 characters (i.e. emoji) for mysql
+ static function strip_utf8mb4($str) {
+ return preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $str);
+ }
+
static function update_feedbrowser_cache() {
$pdo = Db::pdo();
_debug("not using CURL due to open_basedir restrictions");
}
- if (time() - strtotime($last_unconditional) > MAX_CONDITIONAL_INTERVAL) {
- _debug("maximum allowed interval for conditional requests exceeded, forcing refetch");
+ if (time() - strtotime($last_unconditional) > MAX_CONDITIONAL_INTERVAL) {
+ _debug("maximum allowed interval for conditional requests exceeded, forcing refetch");
- $force_refetch = true;
- } else {
- _debug("stored last modified for conditional request: $stored_last_modified", $debug_enabled);
- }
+ $force_refetch = true;
+ } else {
+ _debug("stored last modified for conditional request: $stored_last_modified", $debug_enabled);
+ }
- _debug("fetching [$fetch_url] (force_refetch: $force_refetch)...", $debug_enabled);
+ _debug("fetching [$fetch_url] (force_refetch: $force_refetch)...", $debug_enabled);
$feed_data = fetch_file_contents([
"url" => $fetch_url,
$filters = load_filters($feed, $owner_uid);
if ($debug_enabled) {
- print_r($filters);
- }
+ print_r($filters);
+ }
_debug("" . count($filters) . " filters loaded.", $debug_enabled);
$entry_tags = array_unique($additional_tags);
- for ($i = 0; $i < count($entry_tags); $i++)
+ for ($i = 0; $i < count($entry_tags); $i++) {
$entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8');
+ // we don't support numeric tags, let's prefix them
+ if (is_numeric($entry_tags[$i])) $entry_tags[$i] = 't:' . $entry_tags[$i];
+ }
+
_debug("tags found: " . join(",", $entry_tags), $debug_enabled);
_debug("done collecting data.", $debug_enabled);
// Workaround: 4-byte unicode requires utf8mb4 in MySQL. See https://tt-rss.org/forum/viewtopic.php?f=1&t=3377&p=20077#p20077
if (DB_TYPE == "mysql") {
foreach ($article as $k => $v) {
-
// i guess we'll have to take the risk of 4byte unicode labels & tags here
if (is_string($article[$k])) {
- $article[$k] = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $v);
+ $article[$k] = RSSUtils::strip_utf8mb4($v);
}
}
}
$last_read_qpart = null;
} else {
$unread = 0;
- $last_read_qpart = 'NOW()';
+ $last_read_qpart = date("Y-m-d H:i"); // we can't use NOW() here because it gets quoted
}
if (RSSUtils::find_article_filter($article_filters, 'mark') || $score > 1000) {
$published = 0;
}
- $last_marked = ($marked == 'true') ? 'NOW()' : null;
- $last_published = ($published == 'true') ? 'NOW()' : null;
+ $last_marked = ($marked == 1) ? 'NOW()' : 'NULL';
+ $last_published = ($published == 1) ? 'NOW()' : 'NULL';
$sth = $pdo->prepare(
"INSERT INTO ttrss_user_entries
$e_item = array(
rewrite_relative_url($site_url, $e->link),
$e->type, $e->length, $e->title, $e->width, $e->height);
+
+ // Yet another episode of "mysql utf8_general_ci is gimped"
+ if (DB_TYPE == "mysql") {
+ for ($i = 0; $i < count($e_item); $i++) {
+ if (is_string($e_item[$i])) {
+ $e_item[$i] = RSSUtils::strip_utf8mb4($e_item[$i]);
+ }
+ }
+ }
+
array_push($enclosures, $e_item);
}
}