upgrade script fixes

v1.18.x
Barış Soner Uşaklı 7 years ago
parent 9c59abefbf
commit ba56810790

@ -250,6 +250,7 @@ module.exports = function (Topics) {
var topic; var topic;
var oldCid; var oldCid;
var cid = data.cid; var cid = data.cid;
async.waterfall([ async.waterfall([
function (next) { function (next) {
Topics.exists(tid, next); Topics.exists(tid, next);
@ -262,6 +263,9 @@ module.exports = function (Topics) {
}, },
function (topicData, next) { function (topicData, next) {
topic = topicData; topic = topicData;
if (parseInt(cid, 10) === parseInt(topic.cid, 10)) {
return next(new Error('[[error:cant-move-topic-to-same-category]]'));
}
db.sortedSetsRemove([ db.sortedSetsRemove([
'cid:' + topicData.cid + ':tids', 'cid:' + topicData.cid + ':tids',
'cid:' + topicData.cid + ':tids:pinned', 'cid:' + topicData.cid + ':tids:pinned',

@ -16,7 +16,7 @@ module.exports = {
var topicData; var topicData;
async.waterfall([ async.waterfall([
function (next) { function (next) {
db.getObjectFields('topic:' + tid, ['mainPid', 'cid'], next); db.getObjectFields('topic:' + tid, ['mainPid', 'cid', 'pinned'], next);
}, },
function (_topicData, next) { function (_topicData, next) {
topicData = _topicData; topicData = _topicData;
@ -44,7 +44,11 @@ module.exports = {
db.sortedSetAdd('topics:votes', votes, tid, next); db.sortedSetAdd('topics:votes', votes, tid, next);
}, },
function (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) { ], function (err) {
next(err); next(err);

@ -28,12 +28,12 @@ module.exports = {
var downvotes = parseInt(topicData.downvotes, 10) || 0; var downvotes = parseInt(topicData.downvotes, 10) || 0;
var votes = upvotes - downvotes; var votes = upvotes - downvotes;
async.parallel([ async.series([
function (next) { function (next) {
db.sortedSetRemove('cid:' + topicData.oldCid + ':tids:votes', tid, next); db.sortedSetRemove('cid:' + topicData.oldCid + ':tids:votes', tid, next);
}, },
function (next) { function (next) {
if (!parseInt(topicData.pinned, 10)) { if (parseInt(topicData.pinned, 10) !== 1) {
db.sortedSetAdd('cid:' + topicData.cid + ':tids:votes', votes, tid, next); db.sortedSetAdd('cid:' + topicData.cid + ':tids:votes', votes, tid, next);
} else { } else {
next(); next();

Loading…
Cancel
Save