summaryrefslogtreecommitdiff
path: root/app/Controllers/feedController.php
diff options
context:
space:
mode:
authorGravatar Seokseong Jeon <sjeon87+github@gmail.com> 2017-05-05 01:43:34 +0900
committerGravatar GitHub <noreply@github.com> 2017-05-05 01:43:34 +0900
commitcb897980cd930ec73762118ca8e38ec0050ff5e3 (patch)
tree37ae732b80e856987739a6409c06cf6da66c95d0 /app/Controllers/feedController.php
parent09787cfd7a68e994f248c0cad0ebe5ae68b7aaf3 (diff)
parent53f00571e554f6eeea4fea19d9ddc5eca2ce2997 (diff)
Merge branch 'dev' into cli-act-num-articles
Diffstat (limited to 'app/Controllers/feedController.php')
-rwxr-xr-xapp/Controllers/feedController.php36
1 files changed, 32 insertions, 4 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index eec3b92bc..b8679d86d 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -226,7 +226,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
}
- public static function actualizeFeed($feed_id, $feed_url, $force, $simplePiePush = null, $isNewFeed = false) {
+ public static function actualizeFeed($feed_id, $feed_url, $force, $simplePiePush = null, $isNewFeed = false, $noCommit = false) {
@set_time_limit(300);
$feedDAO = FreshRSS_Factory::createFeedDao();
@@ -309,6 +309,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// -2 means we take the default value from configuration
$feed_history = FreshRSS_Context::$user_conf->keep_history_default;
}
+ $needFeedCacheRefresh = false;
// We want chronological order and SimplePie uses reverse order.
$entries = array_reverse($feed->entries());
@@ -334,6 +335,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
//Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() .
//', old hash ' . $existingHash . ', new hash ' . $entry->hash());
//TODO: Make an updated/is_read policy by feed, in addition to the global one.
+ $needFeedCacheRefresh = FreshRSS_Context::$user_conf->mark_updated_article_unread;
$entry->_isRead(FreshRSS_Context::$user_conf->mark_updated_article_unread ? false : null); //Change is_read according to policy.
if (!$entryDAO->inTransaction()) {
$entryDAO->beginTransaction();
@@ -390,12 +392,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$date_min,
max($feed_history, count($entries) + 10));
if ($nb > 0) {
+ $needFeedCacheRefresh = true;
Minz_Log::debug($nb . ' old entries cleaned in feed [' .
$feed->url() . ']');
}
}
- $feedDAO->updateLastUpdate($feed->id(), false, $entryDAO->inTransaction(), $mtime);
+ $feedDAO->updateLastUpdate($feed->id(), false, $mtime);
+ if ($needFeedCacheRefresh) {
+ $feedDAO->updateCachedValue($feed->id());
+ }
if ($entryDAO->inTransaction()) {
$entryDAO->commit();
}
@@ -436,6 +442,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
break;
}
}
+ if (!$noCommit) {
+ if (!$entryDAO->inTransaction()) {
+ $entryDAO->beginTransaction();
+ }
+ $entryDAO->commitNewEntries();
+ $feedDAO->updateCachedValues();
+ if ($entryDAO->inTransaction()) {
+ $entryDAO->commit();
+ }
+ }
return array($updated_feeds, reset($feeds), $nb_new_articles);
}
@@ -446,6 +462,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
* - id (default: false): Feed ID
* - url (default: false): Feed URL
* - force (default: false)
+ * - noCommit (default: 0): Set to 1 to prevent committing the new articles to the main database
* If id and url are not specified, all the feeds are actualized. But if force is
* false, process stops at 10 feeds to avoid time execution problem.
*/
@@ -454,8 +471,19 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$id = Minz_Request::param('id');
$url = Minz_Request::param('url');
$force = Minz_Request::param('force');
-
- list($updated_feeds, $feed) = self::actualizeFeed($id, $url, $force);
+ $noCommit = Minz_Request::fetchPOST('noCommit', 0) == 1;
+
+ if ($id == -1 && !$noCommit) { //Special request only to commit & refresh DB cache
+ $updated_feeds = 0;
+ $entryDAO = FreshRSS_Factory::createEntryDao();
+ $feedDAO = FreshRSS_Factory::createFeedDao();
+ $entryDAO->beginTransaction();
+ $entryDAO->commitNewEntries();
+ $feedDAO->updateCachedValues();
+ $entryDAO->commit();
+ } else {
+ list($updated_feeds, $feed) = self::actualizeFeed($id, $url, $force, null, false, $noCommit);
+ }
if (Minz_Request::param('ajax')) {
// Most of the time, ajax request is for only one feed. But since