Closed athalius closed 10 years ago
This is basically the same as I did, only I did the check in the amrcsql.webdb.storeWebsite
function.
First, I did the check in the amrcsql.webdb.updateWebsite
function, because it was the first one I saw at a glance at the code, but the problem didn't go away. After editing storeWebsite
, I haven't had any problems. But I agree, it's a dirty fix, and I'd rather find out what's causing the "undefined" errors in the first place.
I have a feeling that a stray mistake on https://ssl10.ovh.net/~allmanga/community/latest_v2/websites.json would cause this issue, because there is no sanity check on the live storeWebsite function (and updateWebsite) (so inserting a set of undefined is a valid option).
Though of course I am sure of how long data in the "amrcsql.webdb.db" stays alive, which could make my entire assumption wrong. (a quick debugger statement on every function on that class seems to indicate that getWebsites is called before the insert logic happens)
If my assumption is correct in that amrcsql.web.db stays alive for ages then we need a change to either purge the database of invalid records generated (the forums show a few people having this issue), or just a sanity check like I have done.
Is res.rows.item(i).idext
really a string and not an object? Granted I know nothing of MangaElt and amrcsql files.
I've actually changed it now from checking for idext, because even though that probably should never be undefined, its not gonna crash the logic, only the websites key should. ( and that is a string, as evinced by JSON.parse(res.rows.item(i).websites)
)
I'm not really 100% sure what the exact value types are, but we are working with a key value store, thus the only way objects could be stored is via JSON.parse, it would have to be something like an int, bool, or string.
I will be merging for now, though I would want to fix the reason why it gets an undefined
value.
This is a hacky workaround to the "unexepected "u" value" error users are getting ( sql is returning a record with an undefined value set).
If someone cares to implement a fix for the sql itself,go ahead, but casually trying to delete by value "undefined" was failing for me, and this was a 5 min fix (localstorage usage ignorance fail!)