This repository was archived by the owner on Aug 9, 2024. It is now read-only.
Add support for plain text field migrations#49
Open
domstubbs wants to merge 1 commit intonewism:masterfrom
Open
Add support for plain text field migrations#49domstubbs wants to merge 1 commit intonewism:masterfrom
domstubbs wants to merge 1 commit intonewism:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I’ve just migrated an old Craft 2 project to Craft 3 and wanted to convert some old Plain Text fields containing URLs to Embed fields. There was no "Changing this may result in data loss” exclamation mark so I assumed I’d be on safe ground, but although the old data wasn’t touched the Embed field type wasn’t able to parse it either, so when viewing old entries in the CP they appear to have no data in the video field and as soon as the entry was saved the old plain text value was deleted.
This little change adds a check for plain text URLs and normalises them. I’ve verified that it works on the frontend and backend and that existing JSON data is unaffected by the change.
This does mean that frontend requests can trigger slow
embed->parsecalls that I assume normally only happen in the CP, but that’s easily addressed by runningcraft resave/entriesto ensure that all of the old text values are migrated to the Embed JSON format.