Do not increase article view counter for unpublished articles
authorMarcel Werk <burntime@woltlab.com>
Tue, 26 Oct 2021 14:09:20 +0000 (16:09 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 26 Oct 2021 14:09:20 +0000 (16:09 +0200)
Closes #4374

wcfsetup/install/files/lib/page/AbstractArticlePage.class.php

index 1c5645e5c3f3bf9eaacf4ed3768517071e605b5f..c14c1bc1139e215838f09c033497b447e65d0295 100644 (file)
@@ -120,10 +120,12 @@ abstract class AbstractArticlePage extends AbstractPage
         parent::readData();
 
         // update view count
-        $articleEditor = new ArticleEditor($this->article->getDecoratedObject());
-        $articleEditor->updateCounters([
-            'views' => 1,
-        ]);
+        if ($this->article->isPublished()) {
+            $articleEditor = new ArticleEditor($this->article->getDecoratedObject());
+            $articleEditor->updateCounters([
+                'views' => 1,
+            ]);
+        }
 
         // update article visit
         if (ARTICLE_ENABLE_VISIT_TRACKING && $this->article->isNew()) {