Ansel fields empty after creating drafts, breaking the entry preview feature
#166 opened by stefan
Description
The new Craft entry draft system is not working with Ansel, which breaks the entry preview feature. To reproduce the bug:
- Create an entry with an Ansel field and add an image to the field.
- Save the entry.
- Edit the entry, and click "Save as a draft" to create a new draft OR click "Preview" to automatically create a new draft.
- Leave the edit page but DO NOT click "update entry" to save the draft.
- Edit the entry. The Ansel field in the current version is now empty.
- Select "Draft 1" from the drop-down. The Ansel field contains the image.
If you delete the draft from the drop-down, the field contents is lost. The big problem is that Craft automatically creates a new draft when you use the entry preview, so this bug breaks that feature.
Replies
- stefan
Replied 12/1/2019 10:27 AM, Edited 12/27/2019 5:52 AM
Very curious about any updates on this issue, since it essentially prevents updating Craft beyond 3.1.x?
- TJ Draper
Replied 12/4/2019 9:36 AM, Edited 12/27/2019 5:52 AM
I'm so sorry I haven't been able to look into this yet. I've been pretty swamped. I just put it in this week's queue in my to-do manager so I should have some answers for you very soon.
- TJ Draper
Replied 12/7/2019 6:44 PM, Edited 12/27/2019 5:52 AM
Sigh. Unfortunately, there is not a good or quick fix for this. Drafts were nowhere on the horizon when Ansel was first written and Craft essentially introduced breaking changes (this is not the only one) in a non-major version of Craft which isn't supposed to happen. Or at least, generally in a semver world isn't supposed to happen. I've been able to mitigate the damage on various issues, but this one is going to require serious re-architecture. For better or worse, and for a multitude of reasons, Ansel stores data in its own table. There is no concept of draft and the image gets moved over to a new entry ID when the draft is created and saved.
I have begun planning for Ansel 3, which at this point is essentially going to be a re-write because of all the breaking changes Craft has been introducing.
However, it's pretty discouraging that Craft breaks the API whenever they feel like it. I have expressed my disappointment, but it is what it is.
In any event, I know that's probably not the answer you wanted to hear, but it's where we're at.
- stefan
Replied 12/27/2019 5:52 AM
This is pretty unfortunate since the Ansel license i bought is basically useless if I want to run a fully patched Craft CMS and the site I'm working on relies heavily on Ansel. I really hope you manage to fix this - Ansel is a great plug-in, much superior to the lousy built-in image cropping feature of Craft. Also, you should probably consider removing support for Craft 3.2+ from the Ansel composer file, since they are not compatible as is.