htmly icon indicating copy to clipboard operation
htmly copied to clipboard

Recovering unsaved "drafts"

Open CharliePoole opened this issue 10 months ago • 5 comments

I put "drafts" in quotes because it's really not a draft until you save it. :-) Here's what happened in my case.

  1. I was creating a new post and typed in a lot of text without saving anything (my bad).
  2. I tried to View the post, but my login had timed out.
  3. I logged back in to HTMLy and had nothing.
  4. I went to the server and found the cached html for my work in file #add#content~type=image.cache. I presume it was saved there when I clicked on View.
  5. I verified that there was no draft saved - since I had not saved it.

My immediate problem was solved by cutting and pasting the text from the cached html. I'll try to avoid this in the future and I know what to do if it happens again. However, it seems it could be made easier.

In my case, the problem arose because my login timed out. It would be great if that didn't happen but, of course, sometimes a user simply abandons a post without ever submitting anything and that has to be allowed for. In addition, the problem may arise for other reasons, such as a network outage.

So I think the better way is to make it easier to recover from a lost post.

Catch-22 is that the cache is not used for display when someone is creating content, because they are logged on. I suggest that an exception be made IFF there is no saved draft AND a cache entry exists for the particular content type being added.

In that situation, the user could be told something like "No draft exists but a partial copy has been saved in the cache. Do you want to use it?" A positive response would cause all the fields to be populated from the cache, essentially automating what I have had to do with my lost post.

As either an alternative or an addition, we could consider some kind of automatic saving of the draft.

CharliePoole avatar Apr 11 '24 14:04 CharliePoole

How did you recover it from the cache?

AutomationMan808 avatar Apr 11 '24 15:04 AutomationMan808

I used CPanel's file explorer to examine the files in the cache and did a copy and paste.

CharliePoole avatar Apr 11 '24 15:04 CharliePoole

Just happened again, this time when I clicked Save as Draft and it discovered my session had expired. Can I control that timeout, or is it hard-coded?

BTW, I had not run into this before because I've been writing offline till now. Today I started to write a new post directly in HTMLy, but it doesn't seem workable unless I can keep my session alive.

CharliePoole avatar Apr 11 '24 19:04 CharliePoole

For now try increasing the value of session.gc_maxlifetime in your php.ini. The default value is 1440 seconds (24 minutes).

danpros avatar Apr 11 '24 23:04 danpros

I tried that and it didn't seem to work but maybe I didn't start a new session. Trying again.

CharliePoole avatar Apr 12 '24 00:04 CharliePoole

I was looking into a solution for this for shared hosting where users don't have a lot of control over the PHP settings and I ended up adding a feature that automatically saves the post as a draft every 60 seconds. I am still working out the specifics and making it look pretty, but so far testing has been pretty successful. Would something like this be a solution to this issue?

image

KuJoe avatar May 17 '24 21:05 KuJoe

This can probably be closed due to PR #757

KuJoe avatar Jun 02 '24 06:06 KuJoe

Thanks!

danpros avatar Jun 02 '24 06:06 danpros