[nodebb-plugin-category-sections] Update for compatibility with latest NodeBB
-
So, I came across https://github.com/NodeBB/nodebb-plugin-category-sections but have tried to use it and encountered the forum crashing after saving category sections via the ACP. It happens when you try to view the forums, or the ACP section.
I've fix the issue, but I haven't been able to figure out what's going wrong. The error that occurs is: "Unexpected token o" which causes the board to shutdown.
If anyone has any ideas and could lend a hand, it would be greatly appreciated!
-
@crashdoom JSON.parse produces that error.
I see it's used in this line
nodebb-plugin-category-sections/library.js at master · NodeBB/nodebb-plugin-category-sections
This plugin allows you to organize the categories on your homepage into individual sections. - nodebb-plugin-category-sections/library.js at master · NodeBB/nodebb-plugin-category-sections
GitHub (github.com)
Not sure if you need that line. Try removing that line.
-
@pichalite From what I can tell, it's storing the data in Redis as "[object Object],[object Object]". If I remove the JSON.parse, I get this error:
30/12 10:41 [8088] - error: TypeError: sections.forEach is not a function at C:\Users\crashdoom\Documents\NodeBB\node_modules\nodebb-plugin-category-sections\library.js:80:13 at try_callback (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:592:9) at RedisClient.return_reply (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:685:13) at ReplyParser.<anonymous> (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:321:14) at emitOne (events.js:77:13) at ReplyParser.emit (events.js:169:7) at ReplyParser.send_reply (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\lib\parser\javascript.js:300:10) at ReplyParser.execute (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\lib\parser\javascript.js:203:22) at RedisClient.on_data (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:547:27) at Socket.<anonymous> (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:102:14) TypeError: sections.forEach is not a function at C:\Users\crashdoom\Documents\NodeBB\node_modules\nodebb-plugin-category-sections\library.js:80:13 at try_callback (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:592:9) at RedisClient.return_reply (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:685:13) at ReplyParser.<anonymous> (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:321:14) at emitOne (events.js:77:13) at ReplyParser.emit (events.js:169:7) at ReplyParser.send_reply (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\lib\parser\javascript.js:300:10) at ReplyParser.execute (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\lib\parser\javascript.js:203:22) at RedisClient.on_data (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:547:27) at Socket.<anonymous> (C:\Users\crashdoom\Documents\NodeBB\node_modules\redis\index.js:102:14)
I presume that the fact that [object Object] is present in the Redis database is causing the error, but I'm unsure where the data from the ACP is serialized and stored.
-
@crashdoom What's your NodeBB version? I cannot even get the plugin to save the sections in the ACP
-
@pichalite I'm using the latest NodeBB v0.9.3.
I have managed to find a fix by another user: https://github.com/neutrino84/nodebb-plugin-category-sections/commit/ce3ba115a3e6f49912f9a79be415409c73b377a2
This seems to work without issue.