Skip to content

Node.js based forum software built for the modern web

upgrade script fixes

Barış Soner Uşaklıba56810790a3
diff --git a/src/topics/tools.js b/src/topics/tools.js
index e0d33b53b2..7ff9d23348 100644
--- a/src/topics/tools.js
+++ b/src/topics/tools.js
@@ -250,6 +250,7 @@ module.exports = function (Topics) {
var topic;
var oldCid;
var cid = data.cid;
+
async.waterfall([
function (next) {
Topics.exists(tid, next);
@@ -262,6 +263,9 @@ module.exports = function (Topics) {
},
function (topicData, next) {
topic = topicData;
+ if (parseInt(cid, 10) === parseInt(topic.cid, 10)) {
+ return next(new Error('[[error:cant-move-topic-to-same-category]]'));
+ }
db.sortedSetsRemove([
'cid:' + topicData.cid + ':tids',
'cid:' + topicData.cid + ':tids:pinned',
diff --git a/src/upgrades/1.7.3/topic_votes.js b/src/upgrades/1.7.3/topic_votes.js
index 76a4d0900c..7e360286a9 100644
--- a/src/upgrades/1.7.3/topic_votes.js
+++ b/src/upgrades/1.7.3/topic_votes.js
@@ -16,7 +16,7 @@ module.exports = {
var topicData;
async.waterfall([
function (next) {
- db.getObjectFields('topic:' + tid, ['mainPid', 'cid'], next);
+ db.getObjectFields('topic:' + tid, ['mainPid', 'cid', 'pinned'], next);
},
function (_topicData, next) {
topicData = _topicData;
@@ -44,7 +44,11 @@ module.exports = {
db.sortedSetAdd('topics:votes', votes, tid, next);
},
function (next) {
- db.sortedSetAdd('cid:' + topicData.cid + ':tids:votes', votes, tid, next);
+ if (parseInt(topicData.pinned, 10) !== 1) {
+ db.sortedSetAdd('cid:' + topicData.cid + ':tids:votes', votes, tid, next);
+ } else {
+ next();
+ }
},
], function (err) {
next(err);
diff --git a/src/upgrades/1.8.0/fix_moved_topics_byvotes.js b/src/upgrades/1.8.0/fix_moved_topics_byvotes.js
index f59d6f154c..c5f6121b95 100644
--- a/src/upgrades/1.8.0/fix_moved_topics_byvotes.js
+++ b/src/upgrades/1.8.0/fix_moved_topics_byvotes.js
@@ -28,12 +28,12 @@ module.exports = {
var downvotes = parseInt(topicData.downvotes, 10) || 0;
var votes = upvotes - downvotes;
- async.parallel([
+ async.series([
function (next) {
db.sortedSetRemove('cid:' + topicData.oldCid + ':tids:votes', tid, next);
},
function (next) {
- if (!parseInt(topicData.pinned, 10)) {
+ if (parseInt(topicData.pinned, 10) !== 1) {
db.sortedSetAdd('cid:' + topicData.cid + ':tids:votes', votes, tid, next);
} else {
next();