Merge branch 'master' into next
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / page / AbstractArticlePage.class.php
index f12f8d898cb42866e9b4cb63b93bf2ca1f7fd01b..ea5675d33924d8c65e85f96fe70c5c4cf82ac518 100644 (file)
@@ -1,8 +1,10 @@
 <?php
+declare(strict_types=1);
 namespace wcf\page;
 use wcf\data\article\category\ArticleCategory;
 use wcf\data\article\content\ViewableArticleContent;
 use wcf\data\article\AccessibleArticleList;
+use wcf\data\article\ArticleAction;
 use wcf\data\article\ArticleEditor;
 use wcf\data\article\ViewableArticle;
 use wcf\data\tag\Tag;
@@ -18,7 +20,7 @@ use wcf\system\WCF;
  * Abstract implementation of the article page.
  *
  * @author     Marcel Werk
- * @copyright  2001-2017 WoltLab GmbH
+ * @copyright  2001-2018 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    WoltLabSuite\Core\Page
  * @since      3.0
@@ -76,6 +78,12 @@ abstract class AbstractArticlePage extends AbstractPage {
                if ($this->articleContent === null) {
                        throw new IllegalLinkException();
                }
+               
+               // check if the language has been disabled
+               if ($this->articleContent->languageID && LanguageFactory::getInstance()->getLanguage($this->articleContent->languageID) === null) {
+                       throw new IllegalLinkException();
+               }
+               
                $this->article = ViewableArticle::getArticle($this->articleContent->articleID, false);
                $this->category = $this->article->getCategory();
                
@@ -108,6 +116,14 @@ abstract class AbstractArticlePage extends AbstractPage {
                        'views' => 1
                ]);
                
+               // update article visit
+               if (ARTICLE_ENABLE_VISIT_TRACKING && $this->article->isNew()) {
+                       $articleAction = new ArticleAction([$this->article->getDecoratedObject()], 'markAsRead', [
+                               'viewableArticle' => $this->article
+                       ]);
+                       $articleAction->executeAction();
+               }
+               
                // get tags
                if (MODULE_TAGGING && WCF::getSession()->getPermission('user.tag.canViewTag')) {
                        $this->tags = TagEngine::getInstance()->getObjectTags(