Neriderc / GVExport

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

Can't set name of saved settings when logged out (cookie too big) #460

Closed Neriderc closed 8 months ago

Neriderc commented 8 months ago

In the latest pre-release version, setting a name when saving a saved setting will not correctly use this name if you are logged out.

This seems to be related to the cookie being too large to send data about settings to the server. It is only an issue for logged out users as for logged in users the server already has the setting information so a cookie is not used for this.

It seems it does not currently affect other settings, possibly because the additional details sent with the API request for saving a shared note may push it over the size limit. The latest stable version is not affected, this is a new bug in the pre-release version.

This likely requires a longer term change to how the data is transferred, but may be able to have a short term fix. I've created this issue to record the issue and track progress.

We should attempt to solve this before the 2.1.19 release.

Neriderc commented 8 months ago

Currently logged in users have their preferences saved in the database, this allows the page to load with the preferences set. However, logged out users don't have a database entry, so the settings are saved in cookies in the browser. Every page load the browser sends the cookies to the server, and then the server can load the settings into the page.

However, because the cookies are sent every page load (including for pages other than the GVExport one - all pages in webtrees or where the domain name is shared), the browser limits the size to a very small amount of data. With the number of settings we have, this is becoming a problem and is the cause of the above issue. We can store data in the browser outside of cookies, but that data is not accessible to the server as it is not sent with each page load.

I have removed the ability for logged out users to use the new functionality to have background colour based on linked shared notes. This has returned us to the previous state and allowed the functionality to work again. However, we need a long term solution.

I believe the best way to do this is to load some of the settings in dynamically after the page is loaded. I have previously tried loading all settings after the page loads, but it looks pretty bad having the page load one way, then updating the page to have the settings another way. Therefore I think having some key settings stored in cookies then the rest loaded dynamically is a better answer.

Many (most!) of the settings are not visible when the page loads, so these could be loaded dynamically.

This will be a lot of work, so I will create a new issue for it and won't let it hold up the next release. Currently the functionality is working again, but logged out users can't use the new shared note functionality. This is in line with my desire to only add features, and not remove functionality where possible.

I'll close this when merging in my changes, and create a separate issue for the long term work.