NodeBB-Community / nodebb-plugin-custom-pages

Allows you to add as many new pages as you like to your NodeBB forum
BSD 2-Clause "Simplified" License
39 stars 24 forks source link

Cannot delete custom pages or change path #68

Closed ShlomoCode closed 1 year ago

ShlomoCode commented 1 year ago

nodebb version: 2.3.1 Plugin version: 1.1.3 nodejs version: v16.16.0


Desired behavior: When I click the X icon next to a custom page CleanShot 2022-10-23 at 01 46 38 The page will be removed from the ACP page, and when I click save changes it will actually be deleted. What actually happens: A confirmation message appears that the changes have been saved, but in practice the deleted page still exists and is accessible to users. When you refresh the ACP page it reappears. Trying to change the page path results in the same behavior. The description and the groups allowed to access the page, however, can be changed. But setting only administrators as authorized to access, brings the surfers to a login page, and I want a 404 page to appear, that the page doesn't exist at all.


In addition, when starting the server, a log appears that this plugin is not compatible with the Nodebb version. @barisusakli @julianlam

ShlomoCode commented 1 year ago

What I did in the meantime as a hack is to enter the Mongo database (I did it with a free graphics client called Robo 3T (nowadays it's called Studio 3T but I'm more comfortable with the old one) and edit the json of the data But it is possible to do it in any other way

db.getCollection('objects').find({"_key" : "plugins:custom-pages"})
barisusakli commented 1 year ago

Does it happen on nodebb-plugin-custom-pages@1.3.3 as well?

ShlomoCode commented 1 year ago

@barisusakli I checked it now, and yes, it also happens in version 1.3.3 of the plugin (in nodebb 2.5.8).

barisusakli commented 1 year ago

@ShlomoCode I will take a look

barisusakli commented 1 year ago

This was actually a bug in core, https://github.com/NodeBB/NodeBB/commit/fc49665fe58150fb0d7269ea0e348e29e29410ba We will make a patch release tomorrow for 2.x that should have this fix. When you tried to delete the custom page it was trying to reset the widgets on that template as well. But if there we no widgets it was crashing and preventing the deletion of the custom page as well.

2022-11-23T00:22:12.125Z [4567/6340] - error: admin.settings.saveCustomPages
TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at widgets.resetTemplate (C:\Users\Baris\Desktop\github\NodeBB\src\widgets\index.js:215:39)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async widgets.resetTemplates (C:\Users\Baris\Desktop\github\NodeBB\src\widgets\index.js:225:3)      
    at async resetWidgets (C:\Users\Baris\Desktop\github\nodebb-plugin-custom-pages\library.js:219:2)      
    at async SocketAdmin.settings.saveCustomPages (C:\Users\Baris\Desktop\github\nodebb-plugin-custom-pages\library.js:50:3)
    at async onMessage (C:\Users\Baris\Desktop\github\NodeBB\src\socket.io\index.js:160:19)
ShlomoCode commented 1 year ago

@barisusakli Thanks! Just today (a few hours ago) I downloaded the latest code and reinstalled, if I just take that commit you linked (https://github.com/NodeBB/NodeBB/commit/fc49665fe58150fb0d7269ea0e348e29e29410ba), that should fix it?

barisusakli commented 1 year ago

Yes if you apply the code I linked it should fix the issue.

ShlomoCode commented 1 year ago

@barisusakli I have tested and confirm that this patch has resolved the bug. Thank you!