Node.js based forum software built for the modern web
fix to getRecentReplies causing count = 0 to return unlimited
psychobunny1d69436b44f4
diff --git a/src/categories.js b/src/categories.jsindex b511ede803..29a4ce09f4 100644--- a/src/categories.js+++ b/src/categories.js@@ -217,6 +217,10 @@ var db = require('./database.js'),};Categories.getRecentReplies = function(cid, count, callback) {+ if(count === 0) {+ return callback(null, []);+ }+db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {if (err) {diff --git a/src/routes/api.js b/src/routes/api.jsindex 9555c4867f..85e74b71f2 100644--- a/src/routes/api.js+++ b/src/routes/api.js@@ -55,9 +55,9 @@ var path = require('path'),});function iterator(category, callback) {- categories.getRecentReplies(category.cid, category.numRecentTopics, function (err, posts) {+ categories.getRecentReplies(category.cid, parseInt(category.numRecentTopics, 10), function (err, posts) {category.posts = posts;- category.post_count = posts.length > 2 ? 2 : posts.length;+ category.post_count = posts.length > 2 ? 2 : posts.length; // this was a hack to make metro work back in the day, post_count should just = lengthcallback(null);});}