Problem/Motivation
When upgrading from 2.x -> 3.x extra settings (title_format, title_fallback) are added but we do not update existing content, leading to broken embeds that just output the raw text.
Steps to reproduce
- Install ckeditor5 and video_embed_field 2.x
- Set ckeditor5 as the text editor for an available format at /admin/config/content/formats
- Add the "Video Embed" button to the toolbar
- Create a new piece of content using the video embed tool
- Upgrade video_embed_field to 3.x
- Clear cache
- View content, note raw output
Proposed resolution
Provide an upgrade path that checks for text, text_long, or text_with_summary field configuration on nodes, paragraphs, and block_content. Then, check those fields in the database for video_embed_wysiwyg usage and add the missing configuration to the settings.
Comments
Comment #3
matslats commentedI've made another update.
- a bit cleaner,
- very fast,
- covers all multiline text fields and db revisions
- does one database table per pass (not tested on that)
- converts settings to json instead of manipulating strings
Shouldn't do any harm, at least.
Comment #4
mably commentedShouldn't the rendering code also be fixed to avoid rendering raw content? 🤔
Comment #5
matslats commentedcan you say a bit more about that?
Comment #6
mably commentedCan't we just use some default value when the new configuration is missing?
Comment #7
cchiste commented@matslats Thank you for the improvement suggestions! I tried running this locally and noticed a couple of issues.
@mably I might be misunderstanding, but I believe we are providing the default value (as far as Video Embed Field goes) in the following. Let me know if I am off base though.
Comment #8
matslats commented@mably That approach also seems valid, and would require less upgrade code, but its also cleaner in the long term to update the old data so that all the data managed by the module is consistent. So its up to the maintenance team to decide.
Comment #9
goldI've just hit this and only incidentally found this issue. I'm going to dive into testing it, but thought I'd update the Title to something that would have jumped out to me as relating to my issue.
Comment #10
goldMR!84 is looking good to me.
While the reworking at #3 may be less code, MR!84 is very readable, doesn't introduce extra constants or functions outside of the update hook. It is also working in it's current state. If this code was going to be used repeatedly the proposed optimisation would be worth exploring, but with it being a one-shot update, I don't see the need.
MR!84, as it stands now, gets my RTBC.
Comment #12
mably commentedOk, let's merge this and see how it goes.
Comment #14
jwmorris commentedThis patch doesn't seem to work with translations. We installed and ran the DB updates, and whilst it did correctly restore all the videos, it converted all fields with videos into the site's default language despite those fields being translated before running the DB update.
Comment #15
jwmorris commentedHere's an updated version of the MR84 patch - specifically, an extra condition at line 141 of .install to take into account the langcode.
Comment #16
mably commented@jwmorris previous patch has already been merged.
Could you provide an MR against the 3.x branch with your fix please?
Comment #18
mably commented@jwmorris I just created MR 86 to include the diff from your patch.
Can you confirm that it fixes the problem ?
Comment #19
mably commented@matslats could you have a look at MR 86 too, please?
Wondering if the langcode field always exists...
Comment #21
mably commented