Guest posts seem a little broken.
-
Ok, I've worked it out, it's because the UID is "undefined", thought I'd fixed all of these in this topic but apparently not.
Is there a quick way of changing all uids from undefined to 0? Or do I need to find the pid, then hset post uid :0 for each one?
-
If you want you can run a one time script to fix the uids, backup your database before running it and then add the following code here
router.get('/fixguestposts', function (req, res) { var async = require('async'), db = require('../database'); function fixOwner(pid, next) { posts.getPostField(pid, 'uid', function(err, uid) { if (err) { return next(err); } if (parseInt(uid, 10) >= 0) { return next(); } posts.setPostField(pid, 'uid', 0, next); }); } db.getSortedSetRange('posts:pid', 0, -1, function(err, pids) { if (err) { res.json(500, err.message); } async.eachLimit(pids, 10, fixOwner, function(err) { if (err) { res.json(500, err.message); } res.json(200, 'done'); }); }); });
Run the forum in dev mode and browse to
http://35hz.co.uk/debug/fixguestposts
It will go through every post and check theiruid
if its greater or equal to 0 it won't do anything, if not (ie undefined null) it will set it to 0.
Copyright © 2024 NodeBB | Contributors