sheadawson / silverstripe-shortcodable

Provides a GUI for CMS users to insert Shortcodes into the HTMLEditorField + an API for developers to define Shortcodable DataObjects and Views.
MIT License
48 stars 36 forks source link

Old content getting saved? #52

Open jonom opened 7 years ago

jonom commented 7 years ago

I have a weird issue going on, might have nothing to do with this module, but it seems to only affect HTMLEditorFields and began when I shipped an update that installed this module, so may be a correlation.

Basically, every now and then when you save a page in the CMS, the Content is replaced with Content from a previously viewed page. I can't work out steps to reproduce it reliably, it just seems to happen randomly. Doesn't seem to make a difference whether you have edited the Content or not, instead of saving what is visible in the Content HTMLEditorField when you hit save, some other page's Content gets saved and loaded back in after the pane refreshes.

Raising the issue here just in case you know of how this could come about? Maybe some variable or cache that's persisting some how?

I wondered if it is related to #45 somehow?

sheadawson commented 7 years ago

Ha. I had a client tell me that happened to them and I thought they were crazy. No idea how it would be happening but would be good to get it figured out

camexapps commented 7 years ago

Yep, same here... the workaround for them was to introduce the 'fix' of (#45) :

ed.save();

Which is see was removed in the b8b6986e01044970a68100d4dd80bd579c056203 commit, but apparently was causing/introducing some issues?

Personally, I have had no issues with the 'fix' addition. As I understand it was converting/parsing the Shortcodes wrong?

jonom commented 7 years ago

45 might have fixed some small issues but it introduced a big breaking one (#49). Maybe ed.save() is needed but but timing of shortcode conversion needs to change to ensure it happens afterward? Not sure. I tried to look in to it but got lost.

jjjjjjjjjjjjjjjjjjjj commented 7 years ago

This is happening to one of our clients as well, seemingly at random. Sometimes the content gets replaced with another page's content, and sometimes all the content is removed. Do we have any new leads on this? Where would be a good place to start debugging this?

jules0x commented 7 years ago

The fix @MrJamesEllis pushed does not fix #52 or #49 for me. Once the content from another page has overwritten the content on the current page, I can even toggle between previous and 'current' content by repeatedly clicking the Save button without making any changes.

mediabeastnz commented 7 years ago

I'm having this issue as well. I can't seem to figure out why it's random and not on every submit.

tomstgeorge commented 7 years ago

I have a client reporting this issue as well... this is a pretty serious bug. Any ideas on where to look to try to fix it?

sheadawson commented 7 years ago

@tomstgeorge I think the best clues are in this thread, sorry I don't have time to help with this at the moment

faloude commented 7 years ago

I think I've sorted the issue. I was using a HTMLEditorField::create('content'). Notice that the the field name is set in the constructor but the field label isn't.

It was a longshot to think this would be causing the issue, but I simply added the label field and the bug seems to be vanished.

Edit: Unfortunately I was wrong. Content is still being deleted / overwritten, disastrous bug.