Browse Source

fix depending results after changing value of "entry->isRead" (#4331)

* fix depending results after changing value of "entry->isRead" inside of hook 'entry_before_insert'

if anybody use the hook 'entry_before_insert' and change the value of the property 'entry->isRead', the depending results are correct now.

In my case my config let all new entrys as "isRead=FALSE" as i will. A new extension which is in progress, can/should/must change the value of this property, but the depending results of this property are wrong before this fix.

* Update app/Controllers/feedController.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Clemens Neubauer 4 years ago
parent
commit
046598e743
1 changed files with 9 additions and 5 deletions
  1. 9 5
      app/Controllers/feedController.php

+ 9 - 5
app/Controllers/feedController.php

@@ -432,11 +432,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 						} else {	//This entry already exists but has been updated
 							//Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->url(false) .
 								//', old hash ' . $existingHash . ', new hash ' . $entry->hash());
-							$needFeedCacheRefresh = $mark_updated_article_unread;
 							$entry->_isRead($mark_updated_article_unread ? false : null);	//Change is_read according to policy.
-							if ($mark_updated_article_unread) {
-								$feed->incPendingUnread();	//Maybe
-							}
 
 							$entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
 							if ($entry === null) {
@@ -444,6 +440,11 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 								continue;
 							}
 
+							if (!$entry->isRead()) {
+								$needFeedCacheRefresh = true;
+								$feed->incPendingUnread();	//Maybe
+							}
+
 							// If the entry has changed, there is a good chance for the full content to have changed as well.
 							$entry->loadCompleteContent(true);
 
@@ -480,7 +481,10 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 							$entryDAO->beginTransaction();
 						}
 						$entryDAO->addEntry($entry->toArray());
-						$feed->incPendingUnread();
+
+						if (!$entry->isRead()) {
+							$feed->incPendingUnread();
+						}
 						$nb_new_articles++;
 					}
 				}