]> git.wh0rd.org - tt-rss.git/blobdiff - classes/rssutils.php
fix previous to not crash if document first child is not a DOMElement or whatever
[tt-rss.git] / classes / rssutils.php
index f06cb085ef47497eb5d1ee632c96349a9e109640..af5fd057ce33278a0d1988a88a5dd0f9a116f93e 100755 (executable)
@@ -637,8 +637,11 @@ class RSSUtils {
 
                                $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);;
 
@@ -694,7 +697,6 @@ class RSSUtils {
                                        $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));
@@ -702,7 +704,6 @@ class RSSUtils {
                                        $base_entry_id = false;
                                        $entry_stored_hash = "";
                                        $article_labels = array();
-                                       $entry_language = "";
                                }
 
                                $article = array("owner_uid" => $owner_uid, // read only
@@ -767,7 +768,7 @@ class RSSUtils {
                                _debug("plugin data: $entry_plugin_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") {
+                               if (DB_TYPE == "mysql" && MYSQL_CHARSET != "UTF8MB4") {
                                        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])) {
@@ -989,6 +990,7 @@ class RSSUtils {
                                                        content = :content,
                                                        content_hash = :content_hash,
                                                        updated = :updated,
+                                                       date_updated = NOW(),
                                                        num_comments = :num_comments,
                                                        plugin_data = :plugin_data,
                                                        author = :author,
@@ -1007,7 +1009,7 @@ class RSSUtils {
 
                                        if (DB_TYPE == "pgsql") {
                                                $params[":ts_lang"] = $feed_language;
-                                               $params[":ts_content"] = mb_substr(strip_tags($entry_title . " " . $entry_content), 0, 1000000);
+                                               $params[":ts_content"] = mb_substr(strip_tags($entry_title . " " . $entry_content), 0, 900000);
                                        }
 
                                        $sth->execute($params);
@@ -1052,7 +1054,7 @@ class RSSUtils {
                                                        $e->type, $e->length, $e->title, $e->width, $e->height);
 
                                                // Yet another episode of "mysql utf8_general_ci is gimped"
-                                               if (DB_TYPE == "mysql") {
+                                               if (DB_TYPE == "mysql" && MYSQL_CHARSET != "UTF8MB4") {
                                                        for ($i = 0; $i < count($e_item); $i++) {
                                                                if (is_string($e_item[$i])) {
                                                                        $e_item[$i] = RSSUtils::strip_utf8mb4($e_item[$i]);