inherit
218778
0
Mar 26, 2021 23:09:44 GMT -8
rektangle
23
February 2015
rektangle
|
Post by rektangle on Mar 25, 2020 6:54:11 GMT -8
I've been working on a plugin to try my hand at this whole thing, but while a few hours ago it was working, it is suddenly refusing to set my Superkey. Link to forum hereThis pb.plugin.key(battle_index_nkbs).set({object_id: 1, value:2}) Is returning Uncaught TypeError: Cannot read property '1' of null proboards.combined_1024.js:1 at Object.set_new (proboards.combined_1024.js:1) at Object.set (proboards.combined_1024.js:1) at <anonymous>:1:36 Is this a Proboards bug? Or did I Screw up at some point?
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 25, 2020 7:26:52 GMT -8
I've been working on a plugin to try my hand at this whole thing, but while a few hours ago it was working, it is suddenly refusing to set my Superkey. Link to forum hereThis pb.plugin.key(battle_index_nkbs).set({object_id: 1, value:2}) Is returning Uncaught TypeError: Cannot read property '1' of null proboards.combined_1024.js:1 at Object.set_new (proboards.combined_1024.js:1) at Object.set (proboards.combined_1024.js:1) at <anonymous>:1:36 Is this a Proboards bug? Or did I Screw up at some point? I do not see that coding anywhere so it must not be visible to guests but judging from the coding I do see the .key("blah") function is designed to return null if the passed in parameter is not found in the key database and that battle_index_nkbs is supposed to be a string not a variable thus should be enclosed in quotes as in the code below (the one that I can see) var enemystats = pb.plugin.key("enemy_stats_kbs"); var playerstats = pb.plugin.key("player_stats_kbs"); var battleindex = pb.plugin.key("battle_index_nkbs");
ETA:Should also add that as a guest I get a different error since I do not have group_ids in the return pb.data("user") object //Nos aseguramos que el miembro que ve el perfil es el usuario que es dueño del perfil o administrador var user_groups = (pb.data("user").group_ids) var is_admin = user_groups.includes(1); const name = pb.data("route").name;
|
|
inherit
218778
0
Mar 26, 2021 23:09:44 GMT -8
rektangle
23
February 2015
rektangle
|
Post by rektangle on Mar 25, 2020 15:17:49 GMT -8
I do not see that coding anywhere so it must not be visible to guests but judging from the coding I do see the .key("blah") function is designed to return null if the passed in parameter is not found in the key database and that battle_index_nkbs is supposed to be a string not a variable thus should be enclosed in quotes as in the code below (the one that I can see. [...] Should also add that as a guest I get a different error since I do not have group_ids in the return pb.data("user") object It's not, by design. It's a very long code for a system I'm trying to make work on the side while learning to code (self taught). Adding the quotes was something I forgot to do here, not on the code. Everywhere else, the key is called with the variables you mentioned, and those actually do include the quotes. The whole thing was working pretty well a few hours ago too, I am not sure what happened that made it not-work anymore, but I tried restoring the code to a previous version and the problem persists. The same line works for all other keys it's just the superkey (Forum) that isn't working. Edit: I've uploaded an abridged version of the code here.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 25, 2020 17:13:15 GMT -8
Super forum keys do not use object_id to categorize your data (you have to do the work yourself) so that piece of data will be ignored, if that is something important then you will need to incorporate it into the value you set. I was able to reproduce that error on a separate forum after seeing that your battle_index_nkbs super forum key was currently set to a value of null. Clearing the key and guarding against setting a value of null in the coding should alleviate the problem (Proboards will trap undefined but not null)
|
|
inherit
218778
0
Mar 26, 2021 23:09:44 GMT -8
rektangle
23
February 2015
rektangle
|
Post by rektangle on Mar 25, 2020 17:53:42 GMT -8
Super forum keys do not use object_id to categorize your data (you have to do the work yourself) so that piece of data will be ignored, if that is something important then you will need to incorporate it into the value you set. I was able to reproduce that error on a separate forum after seeing that your battle_index_nkbs super forum key was currently set to a value of null. Clearing the key and guarding against setting a value of null in the coding should alleviate the problem (Proboards will trap undefined but not null) I don't understand why it was working before then ._. it's been working for as long as I've been working on it with that same coding, it just stopped working today. Let me see if I understand then: I should manually work the categorization of my super forum key data as if writing a JSON? As I said, I'm self taught (only ever took a course on beginner's C programming, i'm more familiar with front-end stuff like HTML and CSS), so I'm not really sure what you mean by "guarding against setting a value of null". I would appreciate if you could tell me how to do that, or where to look further into it.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 25, 2020 18:33:52 GMT -8
If it stopped working today then at some point today the key value got set to a value of null. The subsystem (the part written by PB) that handles the reading and writing of keys does not guard against a null value being in that super forum key set_new: function (n) { v != proboards.plugin.key_type.SUPER_FORUM && void 0 === n.object_id && (n.object_id = proboards.plugin.keys.page_object_id(v)); function e(e, t) { return !(t < ("object" == typeof e ? JSON.stringify(e).length : e.length)) } function t(e) { "function" == typeof n.error ? n.error(e) : proboards.error(e.message + "<br /><br /><i>Error Code: " + e.code + "</i><br /><i>Key: " + g + "</i><br /><i>Object Id: " + n.object_id + "</i>"), "function" == typeof n.complete && n.complete(e) } var i = void 0, a = {}, r = /^-?(\d+)$/, o = /boolean|number|string/, s = proboards.plugin.keys.data[g][n.object_id], l = proboards.plugin.keys.permissions[g][n.object_id], c = proboards.data("plugin_max_key_length"), d = { message: "Plugin key length exceeded.<br>(Limit: " + c + " bytes)", code: proboards.plugin.status.ERROR_KEY_LENGTH }, u = { message: "You must supply a value to this function.", code: proboards.plugin.status.ERROR_KEY_INVALID_DATA }, p = { message: "You do not have permission to write to this key.", code: proboards.plugin.status.ERROR_KEY_PERMISSION }; That highlighted line is basically reading the key and trying to grab the object_id unnecessarily specified on the call but with a forum key value that is at the moment equal to null you then get the error message: "Cannot read property '1' of null" (since an object_id was unnecessarily specified as 1). If a value such as "Chris" was instead the current value in the key then "Chris"[1] would yield "h" (no error, although probably not what was intended) so it would appear to work. If the object_id was left undefined on the call then proboards.plugin.keys.data[g][n.object_id] would effectively become proboards.plugin.keys.data[g] and no error. Guarding against setting null simply means checking the value against null before sending it off.
|
|
inherit
218778
0
Mar 26, 2021 23:09:44 GMT -8
rektangle
23
February 2015
rektangle
|
Post by rektangle on Mar 25, 2020 18:59:16 GMT -8
How do I un-set it to null though? It doesn't seem to let me set anything else on the key anymore, so I'm on a bit of a loss here.
Also, you said Super Forum Keys don't use Object ID, correct? then how come my code worked? I find it hilariously amusing that I've been using it all this time like this.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 25, 2020 19:10:42 GMT -8
In admin panel > plugins you should see three tabs: manage, build and keys
You can clear or delete any key for your forum on that key tab
I assumed you had originally set it as a super user key then decided to change but you say it has always been a super forum key then the explanation I gave above with taking the index of a string means that string is treated as if it was an array would appear to "work" albeit GIGO
|
|
inherit
218778
0
Mar 26, 2021 23:09:44 GMT -8
rektangle
23
February 2015
rektangle
|
Post by rektangle on Mar 25, 2020 19:17:13 GMT -8
Well, this has been informative. I will try to add a way of guarding against null to avoid this in the future, thank you, clearing the key did solve it.
Also, thank you for the time and patience, as I said, I am a very noob coder, so I appreciate it.
|
|