Neriderc / GVExport

Repository for GVExport module for Webtrees
GNU General Public License v2.0
16 stars 7 forks source link

Saved settings got lost after may be too many settings stored #441

Closed schuco closed 10 months ago

schuco commented 1 year ago

I used save settings extensively having maybe 30 settings. Storing another setting resulted in an error with a format of the message I had never seen before but unfortunately did not memorise. After a reset all my saved settings were gone. Fortunately most of these had been downloaded as json files. When I click on a link referring to a saved setting there is the error: E7: Invalid settings ID The saved settings for other trees/users have not been affected. If the error has been the result of storing too many settings, could there be a warning given in time?

Neriderc commented 1 year ago

This is not good! In theory, there should not be a limit that is reachable. 30 saved settings should easily fit. This is assuming you are logged in (logged out users would hit a limit and it's not very high). For logged in users, you should be able to get about 4GB of settings saved. That should be thousands of settings.

It's probably an issue with tracking the IDs. Do you have access to get fields from the database? It would be really helpful to know the value of the settings as well as the field keeping track of the IDs. If you have database access I can walk you through which fields to look at.

Otherwise without an error message it's hard to know what may have caused it. That E7 error happens when loading a token from the URL, but is not necessarily directly because of an invalid settings ID. It basically means that the token provided was valid, but the settings it points to (via settings ID) didn't load for some reason. Any PHP error in loading the settings would show this message.

If you can repeatedly get this message then I could get you to change the code to get a little more info in the message, which might help.

schuco commented 1 year ago

I might get help to get access to the DB on the server. But now that the old saved settings are no more accessible and new entries have been made, is there anything left in the DB to be seen and to detect the error? Unfortunately I don't even have an idea how the error happened. So at the moment I am not able to repeat the error situation.

Neriderc commented 1 year ago

To be honest, I am not sure. In fact, I am becoming surer that you will just find that the settings are gone and the sharing links are still there (but with no settings to load). I'm not sure it would be helpful in tracking down the issue.

I will spend some time thinking of ideas of how settings may have been wiped. I cannot think of a cause right now but I will try to look at how things are structured and see what issue there could have been. Really, I have no idea, but I will at least try to review how things work to see how it could be possible that all of the settings disappear.

Neriderc commented 1 year ago

There's nothing in the code that I can see this happening in.

Basically, the code only updates one setting at a time. If something fails, it should only affect one setting. There is no functionality to update more than one setting at a time.

The one exception is that if webtrees gave GVE an empty list when it tried to load existing settings in order to add more to it, this could cause the list to be overwritten with just the new settings and the old ones would be cleared. I find this unlikely, though, as if webtrees was in the habit of doing this then other modules would also see settings being lost.

So I don't have any explanation. Without a repeatable series of steps to trigger the problem, it's difficult to find a solution (this is true of all bugs).

I think we should keep this open for now. If others find the same issue, they can come and post here. If you have the same issue again, you can reply let me know (and it would be helpful to know any error message).

In the meantime, don't try to limit the number of saved settings. As I've mentioned, it should support thousands. If you get any errors that don't seem to be normal user errors ("login expired", "invalid starting individual", etc would be normal. "JSON error at position 2" would not be), it may help to report them, especially if you can identify a repeatable set of steps to trigger it.

Sorry this has happened! It must be frustrating, luckily you had most of them in saved files!

Neriderc commented 1 year ago

Has this issue ever come up again?

Neriderc commented 10 months ago

I'm going to close this as it sounds like it hasn't come up again. We can reopen it in future if it reoccurs.

schuco commented 10 months ago

👍