summaryrefslogtreecommitdiff
path: root/app/Models/Feed.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-10-28 09:49:10 +0100
committerGravatar GitHub <noreply@github.com> 2018-10-28 09:49:10 +0100
commite04804d0f67dd43fd3f072b9a127768ee7b7b56c (patch)
treea49023ed25aab7fb1c1aafe749f7d462de0027b2 /app/Models/Feed.php
parent44bd07e506ade204151c276fdc05994d51efdd7a (diff)
parent4234dfe0d72b61fe931d2c76a1d8a335ce65a209 (diff)
Merge pull request #2049 from FreshRSS/dev1.12.0
FreshRSS 1.12.0
Diffstat (limited to 'app/Models/Feed.php')
-rw-r--r--app/Models/Feed.php34
1 files changed, 27 insertions, 7 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index ed381a867..e1dd2990d 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -286,6 +286,10 @@ class FreshRSS_Feed extends Minz_Model {
if (!$loadDetails) { //Only activates auto-discovery when adding a new feed
$feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
}
+ if ($this->attributes('clear_cache')) {
+ // Do not use `$simplePie->enable_cache(false);` as it would prevent caching in multiuser context
+ $this->clearCache();
+ }
Minz_ExtensionManager::callHook('simplepie_before_init', $feed, $this);
$mtime = $feed->init();
@@ -345,13 +349,21 @@ class FreshRSS_Feed extends Minz_Model {
$link = $item->get_permalink();
$date = @strtotime($item->get_date());
- // gestion des tags (catégorie == tag)
- $tags_tmp = $item->get_categories();
+ //Tag processing (tag == category)
+ $categories = $item->get_categories();
$tags = array();
- if ($tags_tmp !== null) {
- foreach ($tags_tmp as $tag) {
- $tags[] = html_only_entity_decode($tag->get_label());
+ if (is_array($categories)) {
+ foreach ($categories as $category) {
+ $text = html_only_entity_decode($category->get_label());
+ //Some feeds use a single category with comma-separated tags
+ $labels = explode(',', $text);
+ if (is_array($labels)) {
+ foreach ($labels as $label) {
+ $tags[] = trim($label);
+ }
+ }
}
+ $tags = array_unique($tags);
}
$content = html_only_entity_decode($item->get_content());
@@ -412,7 +424,7 @@ class FreshRSS_Feed extends Minz_Model {
$author_names = '';
if (is_array($authors)) {
foreach ($authors as $author) {
- $author_names .= html_only_entity_decode(strip_tags($author->name == '' ? $author->email : $author->name)) . ', ';
+ $author_names .= html_only_entity_decode(strip_tags($author->name == '' ? $author->email : $author->name)) . '; ';
}
}
$author_names = substr($author_names, 0, -2);
@@ -457,8 +469,16 @@ class FreshRSS_Feed extends Minz_Model {
$this->entries = $entries;
}
+ protected function cacheFilename() {
+ return CACHE_PATH . '/' . md5($this->url) . '.spc';
+ }
+
+ public function clearCache() {
+ return @unlink($this->cacheFilename());
+ }
+
public function cacheModifiedTime() {
- return @filemtime(CACHE_PATH . '/' . md5($this->url) . '.spc');
+ return @filemtime($this->cacheFilename());
}
public function lock() {