]> git.wh0rd.org - tt-rss.git/blobdiff - classes/rssutils.php
move feeds cache directory to cache/feeds
[tt-rss.git] / classes / rssutils.php
index 696b8604cce4b88b4811af07bab363af99b62acb..c9e6bc0ea156462f4038465c42a61df5430154c8 100644 (file)
@@ -369,7 +369,7 @@ class RSSUtils {
 
                $date_feed_processed = date('Y-m-d H:i');
 
-               $cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".xml";
+               $cache_filename = CACHE_DIR . "/feeds/" . sha1($fetch_url) . ".xml";
 
                $pluginhost = new PluginHost();
                $pluginhost->set_debug($debug_enabled);
@@ -454,7 +454,7 @@ class RSSUtils {
                        }
 
                        // cache vanilla feed data for re-use
-                       if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/simplepie")) {
+                       if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/feeds")) {
                                $new_rss_hash = sha1($feed_data);
 
                                if ($new_rss_hash != $rss_hash) {
@@ -879,14 +879,14 @@ class RSSUtils {
                                                        $entry_guid_hashed,
                                                        $entry_link,
                                                        $entry_timestamp_fmt,
-                                                       $entry_content,
+                                                       "$entry_content",
                                                        $entry_current_hash,
                                                        $date_feed_processed,
                                                        $entry_comments,
                                                        (int)$num_comments,
                                                        $entry_plugin_data,
-                                                       $entry_language,
-                                                       $entry_author]);
+                                                       "$entry_language",
+                                                       "$entry_author"]);
 
                                }
 
@@ -973,29 +973,39 @@ class RSSUtils {
                                        _debug("resulting RID: $entry_ref_id, IID: $entry_int_id", $debug_enabled);
 
                                        if (DB_TYPE == "pgsql") {
-                                               $tsvector_combined = mb_substr($entry_title . ' ' . strip_tags(str_replace('<', ' <', $entry_content)),
+                                               $tsvector_combined = mb_substr($entry_title . ' ' .
+                                                       preg_replace('/[<\?\:]/', ' ', strip_tags($entry_content)),
                                                        0, 1000000);
 
-                                               $tsvector_qpart = "tsvector_combined = to_tsvector('$feed_language', ".$pdo->quote($tsvector_combined)."),";
+                                               $tsvector_qpart = "tsvector_combined = to_tsvector(".$pdo->quote($feed_language).", ".$pdo->quote($tsvector_combined)."),";
 
                                        } else {
                                                $tsvector_qpart = "";
                                        }
 
+                                       //_debug($tsvector_qpart);
+
                                        $sth = $pdo->prepare("UPDATE ttrss_entries
-                                               SET title = ?,
-                                                       content = ?,
-                                                       content_hash = ?,
-                                                       updated = ?,
+                                               SET title = :title,
                                                        $tsvector_qpart
-                                                       num_comments = ?,
-                                                       plugin_data = ?,
-                                                       author = ?,
-                                                       lang = ?
-                                               WHERE id = ?");
-
-                                       $sth->execute([$entry_title, $entry_content, $entry_current_hash, $entry_timestamp_fmt,
-                                               (int)$num_comments, $entry_plugin_data, $entry_author, $entry_language, $ref_id]);
+                                                       content = :content,
+                                                       content_hash = :content_hash,
+                                                       updated = :updated,
+                                                       num_comments = :num_comments,
+                                                       plugin_data = :plugin_data,
+                                                       author = :author,
+                                                       lang = :lang                                                                                                            
+                                               WHERE id = :id");
+
+                                       $sth->execute([":title" => $entry_title,
+                                               ":content" => "$entry_content",
+                                               ":content_hash" => $entry_current_hash,
+                                               ":updated" => $entry_timestamp_fmt,
+                                               ":num_comments" => (int)$num_comments,
+                                               ":plugin_data" => $entry_plugin_data,
+                                               ":author" => "$entry_author",
+                                               ":lang" => $entry_language,
+                                               ":id" => $ref_id]);
 
                                        // update aux data
                                        $sth = $pdo->prepare("UPDATE ttrss_user_entries
@@ -1278,7 +1288,7 @@ class RSSUtils {
        }
 
        static function expire_cached_files($debug) {
-               foreach (array("simplepie", "images", "export", "upload") as $dir) {
+               foreach (array("simplepie", "feeds", "images", "export", "upload") as $dir) {
                        $cache_dir = CACHE_DIR . "/$dir";
 
 //                     if ($debug) _debug("Expiring $cache_dir");