htmly
htmly copied to clipboard
Recovering unsaved "drafts"
I put "drafts" in quotes because it's really not a draft until you save it. :-) Here's what happened in my case.
- I was creating a new post and typed in a lot of text without saving anything (my bad).
- I tried to View the post, but my login had timed out.
- I logged back in to HTMLy and had nothing.
- 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. - 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.
How did you recover it from the cache?
I used CPanel's file explorer to examine the files in the cache and did a copy and paste.
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.
For now try increasing the value of session.gc_maxlifetime
in your php.ini
. The default value is 1440 seconds (24 minutes).
I tried that and it didn't seem to work but maybe I didn't start a new session. Trying again.
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?
This can probably be closed due to PR #757
Thanks!