Fix calling ViewableArticle::getUnreadArticlesForCategory() with different ids
authorMatthias Schmidt <gravatronics@live.com>
Sat, 7 Dec 2019 16:23:05 +0000 (17:23 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 7 Dec 2019 16:23:05 +0000 (17:23 +0100)
wcfsetup/install/files/lib/data/article/ViewableArticle.class.php

index c523da874f23b2bcb37c63bd5295f64bd8bb079e..448bf072d830d3e14266bb565fa1bddc08cc098a 100644 (file)
@@ -299,6 +299,17 @@ class ViewableArticle extends DatabaseObjectDecorator {
                                self::$unreadArticlesByCategory[$articleCategoryID] = 0;
                        }
                }
+               else if (!isset(self::$unreadArticlesByCategory[$articleCategoryID])) {
+                       if (WCF::getUser()->userID) {
+                               self::$unreadArticlesByCategory[$articleCategoryID] = self::fetchUnreadArticlesForCategory($articleCategoryID);
+                               
+                               // update storage unreadEntries
+                               UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'unreadArticlesByCategory', serialize(self::$unreadArticlesByCategory));
+                       }
+                       else {
+                               self::$unreadArticlesByCategory[$articleCategoryID] = 0;
+                       }
+               }
                
                return self::$unreadArticlesByCategory[$articleCategoryID];
        }