From: garvinhicking <garvinhicking>
Date: Sat, 10 Dec 2005 21:46:13 +0000 (+0000)
Subject: fix bug #1377095 - wrong entry count
X-Git-Tag: 1.0~238
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=90489000bb044f316eb32bca8aac327ab24bff84;p=s9y.git

fix bug #1377095 - wrong entry count
---

diff --git a/docs/NEWS b/docs/NEWS
index eb4339d..cb8bc92 100644
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,10 @@
 Version 1.0 ()
 ------------------------------------------------------------------------
 
+   * Fix Bug #1377095 - Not counting correct number of entries on the
+     /archives page. The page was counting entries belonging to more
+     then one categories multiple times. (garvinhicking)
+
    * Fix MoveableType importer to better import comments (garvinhicking)
 
    * Allow category sidebar plugin to hide the parent category, if
diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php
index 283e5ea..06acfa6 100644
--- a/include/functions_entries.inc.php
+++ b/include/functions_entries.inc.php
@@ -1357,9 +1357,13 @@ function serendipity_printArchives() {
                                                 AND timestamp >= $s
                                                 AND timestamp <= $e "
                                                     . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . time() : '')
-                                                    . (!empty($cat_sql) ? ' AND ' . $cat_sql : '')
-                                                    );
-            $entry_count = $entries[0][0];
+                                                    . (!empty($cat_sql) ? ' AND ' . $cat_sql : '') . "
+                                           GROUP BY ec.entryid", false, 'assoc');
+            if (is_array($entries)) {
+                $entry_count = count($entries);
+            } else {
+                $entry_count = 0;
+            }
 
             /* A silly hack to get the maximum amount of entries per month */
             if ($entry_count > $max) {