Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
We need a method to upgrade/migrate from D7 field collections to D8 paragraphs.
Proposed resolution
Field Collections => Paragraphs deriver and base migration using Node as a pattern.
Remaining tasks
- #2904765: Alter derived migration definition early in life
- #2890690: MigrateLookup plugin has inconsistent return values.
- #2954937: Object of class FieldCollectionItem could not be converted to int in FieldCollectionItem->fields()
- The latest dev version of Entity Reference Revisions, the patch from #2944836: Migrate destination plugin attempts to update new entities, preventing creation of stub entities, or a release that contains it.
- Document example migrations, such as data only for a single Field Collection. We can generate a template from #30, #32 and the extra process (see later comment) for migrating the IDs as well.
User interface changes
API changes
Data model changes
Follow-up issues
- No ticket yet: Add support for #2904705: Support asymmetric translation in experimental widget when it gets in.
Issue fork paragraphs-2911244
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mikelutzThis is the last of the patches, and this one needs to be applied over https://www.drupal.org/project/paragraphs/issues/2911243 and https://www.drupal.org/project/paragraphs/issues/2911242. It still probably won't handle translations, and this patch won't pass tests without the other two, so I'm just leaving it here for review. The patch is included in #2897021: [META] Migrate support for importing field collections as paragraphs
Comment #3
mikelutzComment #4
mikelutzI'm going to close this issue and roll the patch directly into the parent issue patch. I can't apply it on top of dev, and it's just getting impossible to manage as a separate issue.
Comment #5
mikelutzResetting this issue to prepare for more work. Currently blocked by #2911242 and #2911243
Comment #6
mikelutzAdding in initial work. This patch is based on some previous work I did and still needs some love.
Comment #7
noel.delacruz CreditAttribution: noel.delacruz commentedHi @mikelutz,
I'm still stuck with this issue
Input should be an array.
lurking once I started migrating the node/content type, this is using the latest patch. Apologies, but this issue is really a PITA. I have tried different approaches even to the point of testing early versions of drupal 8.4 and I'm still stuck with the same issue. Already even tried using a different migrate-upgrade module an added the upgrade_ prefix manually still the same, that is how desperate I am in trying to resolve this issue. Even tried creating a new/fresh drupal 8 instance and following the steps and procedures in the following order.Some migration requirements/dependencies that I need to migrate in order to resolve some of the migration errors
Missing bundle entity, entity type comment_type, entity id comment_node_page.
YML Configuration
I'm open to anything to try and resolve this issue.
Comment #8
mikelutz@noel - I know you've been struggling with this, and I wish I had an idea on how to help you. I can tell you this much: "Input should be an array" is an error that occurs in the extract plugin, when the input is not an array (ok, duh..). The extract plugin takes in an array and returns the value at a specific index. If you are getting that error, then the previous migrate_lookup plugin is clearly not returning an array. This plugin returns the destination id(s) of a previous migration, and if your field collection migrations use the paragraphs destination (as in the latest patch), then that extends the entity_revision_reference destination, which has entity_id and revision_id as destination ids, so migrate_lookup should return an array, so extract should be happy.
Now if the migration lookup fails, the plugin attempts to create a stub paragraph, and thanks to a flaw in the system, rather than getting an array back, it just gets back the entity_id of the new paragraph. I'm aware of this, and working on a couple issues/workarounds to help resolve it, but at the moment it should only be a problem for nested field_collections/paragraphs. In your simple case, and with your field collection migrations running prior to the node migration, you should not be creating stub entities; your migration should succeed and you should get an array back for extract.
With the exception of nested field collections, I can't duplicate the error. If you could xdebug break at the line in the extract plugin that throws the error, and show the state of the migration, and other variables at that point it may help. If we could track down which of the two extract plugins is causing the problem, that might help. Maybe try getting rid of the target_id block and then switching out the target_revision_id block to see if the error message changes.
Finally, if you can catch me in slack (I know there's a time difference) I would be happy to try to talk through some debug stuff live. I hang out in the migration channel among others.
Comment #9
noel.delacruz CreditAttribution: noel.delacruz commented@mikelutz
Hello mike, thanks for sharing your inputs. Sent you message.
Just to add, here is the YML configuration for my field collection
Comment #10
rozh CreditAttribution: rozh commentedTotally understand that work still in progress. Just want to share my results with testing latest patch.
Still don't have any migrated node with at least one field_collection item attached. But I have exact number of paragaphs in database as I have FC items in D7 database. Tables with fields attached to paragraphs types contain no data though.
I'm using core Migrate UI module (8.5.*-dev) with dev version of Paragraphs and patch from #6.
Comment #11
StevenPatzJust a testing update from my end. I've been able to do a FC to Paragraph migration multiple times and with a code review from a coworker. We've pushed our code and run migrations on our dev server, just waiting for QA to verify the data is correct.
Comment #12
colan@mikelutz: It's now been 2 weeks so I'm just wondering if you've moved onto other things. I finally have some time to get a content migration done for one of my current projects, and ideally I'd have it working in the next half-week. The new site is already configured so I just need to migrate the data itself, nothing else. So I'm really wondering what's left for this.
If you have moved on, I was wondering about the following:
As "love" isn't very specific, would you kindly let us know what you believe to be the outstanding bits?
#8:
Would you kindly point us to these issues/workarounds, or let us know what you're thinking so we can try to solve? I've got some nesting in my data, and I'm sure others do too.
If you haven't moved on, and are simply distracted, please let us know when you'd have a chance to get back to work on it. Any info you can add here would help the rest of us (possibly myself) finish it off (if you're too busy to do it yourself in the near future).
Thanks so much for getting it this far!
Comment #13
colanI've been trying to work with this stuff for the past week, trying to migrate data (only, everything else is already in place), but hitting roadblocks every step of the way, starting with #2956107: Database connection failures during migrations aren't logged anywhere. Some questions:
src\Plugin\migrate\destination\Paragraphs.php
if #2944836: Migrate destination plugin attempts to update new entities, preventing creation of stub entities is in? Does our code do anything different that's missing from ERR?The @todo says:
@noel.delacruz: I'm assuming #9 didn't work because this was missing? Please update us on your progress. Would be good to know where you're at, what worked, and what didn't so we can at least nail down and one working template for migrating a single field collection to a paragraph.
deriver: Drupal\paragraphs\Plugin\migrate\D7FieldCollectionItemDeriver
I'll keep hacking on this, and report back as I move forward. I'm now getting "No migrations found.", which is at least honest. Before fixing the DB connection issue, I was told that the migration was successful, and all I was getting was stub entities.
Comment #14
mikelutz@colon It is a very long story, but I need #2904765: Alter derived migration definition early in life so that I can fix a bug with migrate_upgrade which causes migration_lookup to break. Basically the standard drupal migrate ui knows that when I tell it to do a migration_lookup from d7_field_collections I need it to look through ALL the derived D7 field migrations. When you convert these plugins to configs with migrate_upgrade and migrate_plus the derivative relationship breaks, and the plugin can't find all the field migrations to reference. It breaks taxonomy hierarchy as well, and a few other things. The workaround is to manually change the migration_lookup migration references in each content migration to directly reference the corresponding field migration.
#2890690: MigrateLookup plugin has inconsistent return values. breaks nested field collections, since I can't create and reference stubs.
#2944836: Migrate destination plugin attempts to update new entities, preventing creation of stub entities is in ERR now, so you could go back to using that destination plugin.
I haven't given up on this, or even been distracted really. All of those issues could potentially be worked around in this patch, btu it adds a lot of extra cruft, that I doubt would get committed, so I'm trying to fix the upstream issues before I do more work here.
Again, if you are working on a one-off migration, and don't mind hacking core a little or adjusting the migrate_upgrade configs, you can work around all of the content issues, I just don't have a clean committable way to code everything up yet.
Comment #15
colan@mikelutz: Thanks for your response.
Totally understandable, and a good plan IMHO.
Understood. What would be good to have here though, until all of the upstream stuff is resolved, is a list of additional things we'd need to apply/do manually along with the patch here.
Here's what I think that list should be. Please let me know if I'm missing anything. Once we can agree on an initial list, we can add it to the issue summary (IS).
Anything else?
As far as #6 goes, let's say it definitely needs work (NW) based on the duplication of ERR code. We should also add this, and any other known NW items to the IS. So that's two lists really. Is there anything else that should be added to this one?
Comment #16
colanERR duplication removed. The latest dev version of ERR is now required to get #2944836: Migrate destination plugin attempts to update new entities, preventing creation of stub entities.
Comment #18
colanNot sure how that makes any sense. Even the stable version off ERR has the plugin, which is included in the test.
Comment #19
mikelutzThese would all need to specify the entity type derivitive
plugin: entity_reference_revisions:paragraph
Comment #20
heddnThere's no @require entity_reference_revisions. Might also check if err is listed as a test_dependency. I'd assume it was.
Comment #21
colanThanks guys. Hopefully this does the trick. Also fixed few coding standards violations the testbot was complaining about.
Comment #23
mikelutzComment #24
mikelutzThe ERR patch added a flag that was needed to save a new revision that wasn't necessary in the one-off plugin I wrote. Adding the flag should fix your test.
Comment #26
mikelutzOkay, the test is passing locally, but failing on d.o because it's using the stable version of ERR, which does not have the commit needed to make this work. I'm adding a new patch here which adds a new lookup plugin and code to work around all the migrate_upgrade, migrate_plus, and migration_lookup issues and should support revisions, nested paragraphs/field_collections, and migrate-upgrade. The code is not cleaned up, this is meant more as a proof of concept and out for some manual testing. For a clean solution some of this code really needs to be refactored a bit and put upstream, but I wanted to get something working for people to use and test in the meantime.
I may put the destination plugin back in tomorrow, just to keep to passing tests and not being dependent on ERR-dev.
Anyway, I'm putting this up for review, not so much for a code review to be committed, because I don't think it should be, but for people to run some manual tests with migrate_upgrade and migrate_plus and let me know if it anything is seriously broken, and if not, I can start pushing the cleaned up versions upstream.
If you've already generated your migration configs with migrate upgrade, you will have to start again with this patch, delete them and re-generate.
This patch still does not handle translation, and I think that is fine for this issue queue. I'd like to get this code (once fixed up) committed first and then add translation support in another issue. This makes sense since we are still waiting on #2904705: Support asymmetric translation in experimental widget or something like it to manage translations and core migrate_drupal isn't stable for translations either.
I hope this helps move people forward on this issue. I know it seems like its been stagnant, but I'm actively working on two separate migration projects both heavily using field collections in D7 and needing paragraphs in D8. I'm pushing my code back as best I can, but for it to be right, I need things to happen in core, migrate_upgrade, migrate_plus and/or here, and I'm actively working to get the right code in the right places to do this right.
Comment #27
mikelutzComment #28
mikelutzI pinged Miro on getting a new release on ERR, which should fix that test. I'd rather that than reintroduce the destination plugin, but we'll see what he says.
In the meantime, @colan, if you could try the latest patch with ERR-dev and let me know if it helps your nested field collections, I would like to hear how it goes.
Comment #29
miro_dietikerCommitted the Paragraphs issue. Is there anything that should go into ERR prior to a new release to unlock progress here?
I'm postponing an ERR release until THU to avoid potential challenges in the upcoming critical security issue.
About Asymmetric translation and related topics, see the priorities i outlined in the #2954487: New Roadmap
I think it's very important to care about Content Moderation and a clean storage first.
Comment #30
colanSo far, as has been happening earlier, the entities are getting created without field data. When I look at the entity before it's saved, I see that the entity's
values
array is populated, butSqlContentEntityStorage->saveToDedicatedTables()
is skipping all of those because$this->entityManager->getFieldDefinitions()
is only returning metadata field info. Maybe there's some field definition info we need to add to the entity? That's as far as I am with debugging at the moment.I'm trying to do a single migration for the one nested field collection that I have. Once I can actually get field data, I'll add all of the other YAML files. I still have no idea how to grab the FC ID and use it for the Paragraph ID, which I'll need for other migrations, but that's my second problem. I don't even want to think about that until I can get field data to show up in a single migration. Here's my YAML.
Any help to move this along would be greatly appreciated.
Comment #31
colanThat's not it. In the following code from EntityReferenceRevisions->getEntity():
...
$bundle
gets set to "quality_issues". This should instead be "quality" as I have in my config."quality" is the target paragraph type, where I'd like the data to go, the one with the destination fields, so I have no idea where "quality_issues" is coming from (having trouble tracking this down; possibly somewhere in the source plugin strangely). So it can't find any fields on "quality_issues" because it doesn't exist.
When I hardcode
$bundle
to "quality", the field data actually comes through, and the migration works. Is this the correct way to specify the target bundle in the configuration? Am I doing it wrong? Or is there a bug in the code somewhere?Comment #32
mikelutzActually, in that situation, you just need to remove the type: bundle line from your process array. The code is designed to work with the core migrate ui, and assumes you used the type and field migrations from the module. This maps the "field_quality_issues" field collection to a new 'quality_issues' paragraph bundle. your default_bundle in the destination isn't used because you specify the bundle from the source directly in your process array. For your custom migration, either remove it, or set it to a constant to override the bundle name derived from your field_collection.
Comment #33
colanThank you! That worked. I just added the IDs like so, so I'm assuming I won't have to worry about look-ups later if I migrate dependent FCs first:
I saw this in both
d7_field_collection_revisions
andd7_paragraphs_revisions
:Should it instead be:
... as per the docs?
I updated the IS with everything we discussed above. I also updated the status as more review would be helpful before we start refactoring. For example, I haven't (and probably won't) be testing revisions.
Comment #34
mikelutzBoth are valid yml syntax, and there is no formatting standard for Drupal yml files beyond that they are valid yml syntax. Core configuration files format the arrays in both ways. We could change it for readability as a nit, but as everything will need to be refactored and moved around upstream projects, I'm more concerned with functionality as a proof of concept at the moment.
Comment #35
colanNot a problem then; I was just worried it would break something.
Comment #36
colan@miro_dietiker wrote:
Just wondering if you're still planning on cutting a release soon. It would be great to get this fix into stable.
Also, a Paragraphs release would be nice too.
Comment #37
colan@mikelutz: How can I get the paragraph ID from the parent ID? Can the
paragraphs_lookup
process plugin help with this? There's not much user/in-line documentation there, and it's rather long so it's tricky to figure out. (I'm sure this will be less of an issue once it gets refactored.)I need to migrate some regular field data (not in a field collection) from a D7 node into a D8 paragraph that's a child of the node, where it doesn't contain the data in question. The destination paragraph would have already been migrated from the its corresponding FC, and the node would have been migrated as well. I've got the YAML file all written for this Node to Paragraph migration, except that I don't know how to get the ID of the previously-generated paragraph when adding additional data to it. In fact, the IDs are going to be the same on the source and destination nodes and FCs/paragraphs; not sure if that helps any.
I'm thinking of something like this:
Comment #38
mikelutz@colan It sounds like your node already contains a field collection, and your goal is to move some fields from the node into the new paragraph created from the field collection. The paragraphs_lookup is just the migration_lookup with a few workarounds for some migrate-upgrade and migration_lookup issues to help with nesting and derivative lookups. Assuming your original field collection field only allows a single delta, and you don't need to worry about multiples, you would be looking at running 3 migrations -
1:
Source: field_collection_item
field_name: your field
Destination: ERR:paragraphs
2:
Source: d7_node
node_type: your node_type
Process:
{{field maps}
id:
- plugin: migration_lookup
migration: {{migration #1 above}}
source: field_whatever/0/value
- plugin: extract
index:
- 0
revision_id:
- plugin: migration_lookup
migration: {{migration #1 above}}
source: field_whatever/0/value
- plugin: extract
index:
- 1
destination: ERR:paragraphs
3:
source d7_node
field_whatever: use the generated paragraphs_lookup plugins
destination: entity:node
You may need to play around with the source value for the id and revision id in the second migration, I'm not sure if you will need the delta off the top of my head. if your field only accepts a single value, field_whatever might be enough to get the lookup, I just don't know without checking the code.
You may need to tweak this if I'm misunderstanding your situation too, but the short of it is that you can't get the id from the parent id, but if you are using the parent as the source, then you should get the id from the field, or a migration lookup against the field.
If you catch me on slack, I can probably help more as well.
Comment #39
heddnI've added two related issues that have bearing here.
#2890690: MigrateLookup plugin has inconsistent return values. is important because we don't have a way to know if the values returned from migration_lookup are keyed by numeric 0, 1, etc or if they are keyed by entity_id i.e. 123.
#2976379: Expand all derived migrations in migration_lookup is important because migrate_upgrade doesn't expand out all derived migrations, including those from here.
Comment #40
mpotter CreditAttribution: mpotter at Phase2 commentedThis patch no longer applies to the 8.x-1.3 release. Is it still needed or does it need a reroll?
Comment #41
mikelutzThis patch seems to still apply for me, but I've re-queued the test to check.
Comment #42
mpotter CreditAttribution: mpotter at Phase2 commentedHmm, odd, it works for me now too. Maybe it was a composer caching issue. Certainly had some other composer-related issues doing updates today. Thanks for getting back quickly.
Comment #43
super_romeo CreditAttribution: super_romeo commentedA long Update method names to be more meaningful in MigrateFieldInterface, function processFieldValues() should be renamed to defineValueProcessPipeline().
Otherwise FieldCollection::processFieldValues() not calls for node migrations.
Comment #45
mikelutzUpdate to patch to work on 8.6, still broken on 8.7.
Fix for that, and tests are coming.
Comment #46
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedOne of the test failures for Drupal 8.7 is that in ParagraphsLookup the method
skipOnEmpty()
is called, which is replaced withskipInvalid()
: https://www.drupal.org/node/3001283.I see that ParagraphsLookup has some coding standard issues as well:
Double empty lines.
Docblock missing.
Extra empty line at the start of the method.
Newline missing.
With Drupal 8.7 nearly arriving, would it be a good idea to drop support for Drupal 8.6 with new patches? It doesn't look like a final patch would make it before the next minor release of Drupal.
Comment #47
heddnLet's see if this fixes some things.
Comment #48
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedWorked fine for me. Patch created the migrations that create paragraphs out of field collections along with their fields, and then content migrations to migrate content and its revisions.
Here I am adding the respective Configuration and Content tags so the field collection migrations can run along others.
Comment #49
heddnFailures on 8.7 and 8.8. Back to NW.
Comment #50
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedI realized that I was getting the wrong associations between paragraphs and their parent entities because the parent_id and parent_type properties were not being set. Here is a patch that fixes it.
Comment #52
quatrys CreditAttribution: quatrys commentedI have install the patch #50 but i have an error during migration : Error : Call to a member function createInstance() on null dans Drupal\paragraphs\Plugin\migrate\process\ParagraphsLookup->transform() paragraphs/src/Plugin/migrate/process/ParagraphsLookup.php ligne 38
Regards,
Comment #53
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commented@quatrys, I don't know what may be causing that error. Can you step into that line with a debugger to gather further insight?
Comment #54
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commented@quatrys: I just experienced the same bug that you did. I don't know how I did not stumbled upon this before.
Here is a patch that fixes it.
Comment #56
Merlin TribukaitA normal Paragraph Migration is ignoring the Paragraph Type, giving the field_name along with the bundle in the D7ParagraphsItemDeriver should fix this little issue.
Comment #57
rd.michael CreditAttribution: rd.michael commentedHi guys, thanks for all the work thus far on this. I'm trying to test this on a big and complex site (80 paragraph bundles and 4000+ paragraphs_item rows) and I'm running into a memory issue when trying to setup the migrations with
drush migrate:upgrade
.PHP Fatal error: Allowed memory size of 12633243648 bytes exhausted in ...modules/contrib/paragraphs/src/Plugin/migrate/field/Paragraphs.php on line 73
As you can see I updated my allowed memory size to 12048M. Any ideas? I'm using php 7.1.29, Drush 9, and Drupal 8.6.14, and mysql 5.7.25.
Note, I'm only getting the error with the patch. Setting up
drush migrate:upgrade
worked fine prior to testing these patches.Edit
I put a
var_dump($field_name);
inmodules/contrib/paragraphs/src/Plugin/migrate/field/Paragraphs.php
on line 73 and the output is continually one field name. In my case it's "field_accordion_items".Edit 2
Oh I see on line 73 you have a call to the same method causing an endless loop. Did you mean to use
parent::processFieldValues($migration, $field_name, $data);
?Edit 3
So based on my last edit I was able to setup the migrations. However, when I try to run one of them I get the following error:
So I'm thinking that the edit I made before is incorrect, or there is a new problem.
Comment #58
volkswagenchickTagging for DrupalCamp Asheville. Thanks!
Comment #59
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedThis patch should fix tests.
Comment #60
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedToday I discovered that having parent::prepareRow() at the beginning of FieldCollectionItem::prepareRow() made it impossible for hooks_migrate_prepare_row() implementations to access the field data of each row. This patch fixes that.
Comment #61
volkswagenchickComment #62
rd.michael CreditAttribution: rd.michael commentedI've gotten this to work pretty well for me now (80 paragraphs 4000+ paragraph_item rows), and I just wanted to share one bug I found.
In
Drupal\paragraphs\Plugin\migrate\field\Paragraphs
line 73, you need to change:$this->processFieldValues($migration, $field_name, $data);
to
$this->defineValueProcessPipeline($migration, $field_name, $data);
Otherwise it causes an infinite loop. If you create a new patch that would be awesome.
Comment #63
colanComment #64
DamienMcKennaRerolled, and includes the feedback in #62.
Comment #65
drupalninja99 CreditAttribution: drupalninja99 at Mediacurrent commentedI can confirm that patch #64 works for me as expected
Comment #66
super_romeo CreditAttribution: super_romeo commentedI've made patch more universal.
Please look.
Comment #67
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedI think that we should use meaningful variable names.
This would stop the migration process. Do we want that?
Comment #68
super_romeo CreditAttribution: super_romeo commentedjuampynr, thank you for review.
1. Let it name $process_element.
2. More precisely, we will stop generation of migration configurations. Ok. We can use drush_print().
Comment #69
heddnre 68: many sites don't use drush. let's not assume they have it installed.
Why do we remove these class checks? This seemed useful. What problem are we trying to solve in #66? It isn't really clear.
Comment #70
heddnAlso hook_migration_plugins_alter is a runtime hook, so I believe throwing \Exception will kill the migration from executing.
Comment #71
super_romeo CreditAttribution: super_romeo commentedWe don't know, in what exact migrations "entity_type" will be used. E.g. it used in "user_picture_field" and "field_group" migrations...
You are right. We should just drop a message. Maybe we can just do Drupal::logger("rg")->Error().
Comment #72
heddnHmm, while we don't know the migration name, we do know the source plugin name, no? Which is what we were testing against.
Comment #73
super_romeo CreditAttribution: super_romeo commentedSource plugin name is not needed in my patch. And I just assume that 'entity_type' and 'targetEntityType' values all should be changed to 'paragraph'. Maybe it is just workaround...
Comment #74
goodDenis CreditAttribution: goodDenis as a volunteer commentedThank you!!!
I can confirm that patch #64 works for me as expected.
I had some problem with d7 field_colection revision table and the migration not working for me. (There were more rows than it should be. I think this one https://www.drupal.org/project/field_collection/issues/2000690 was the reason)
I did not need to migrate revision, so I just delete it.
Maybe it will be helpful for someone.
Comment #75
super_romeo CreditAttribution: super_romeo commentedSome fixes.
Comment #76
super_romeo CreditAttribution: super_romeo commentedComment #78
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedWhy adding this new dependency?
@super_romeo, can you post an intediff from #64 to #75? I am not clear on the set of changes that were introduced since then.
Comment #79
super_romeo CreditAttribution: super_romeo commented@juampynr, interdiff attached in #75.
We need $migrationPluginManager in transform() method.
I don't know how it works before :)
I will try to fix patch today.
Comment #80
super_romeo CreditAttribution: super_romeo as a volunteer commentedTest fixed.
Comment #81
super_romeo CreditAttribution: super_romeo as a volunteer commentedAnother test should be fixed. I'll do it today.
Comment #82
super_romeo CreditAttribution: super_romeo as a volunteer commentedMy patch intendent for D8.8.x.
I understand:
1. Tests for D8.7.8 does not passed, because I use migrate.lookup service, that has been added in D8.8: New Migration Lookup and Stub services have been added.
2. Tests for D8.8.x does not passed, because tests intendent for D8.7.
Comment #83
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedHi @super_romeo!
I am not sure how to help: tests were passing in #64. Then you made the patch, quoting your words in that comment, "more universal" at #65. Some of us gave you some feedback asking for the reasoning behind some of the changes that you made and then, in following patches, tests stopped passing.
Bases on the above, I suggest that we revert back to the patch at #64 and move forward from there.
Comment #84
super_romeo CreditAttribution: super_romeo as a volunteer commentedOk. I agree.
But what we should do then 8.8 will released? Will return to #80 patch?
Comment #85
miro_dietiker@juampynr so #64 it is as RTBC? I'm really not deep into migrations. Please sign it off from your side so we can commit it then.
Comment #86
super_romeo CreditAttribution: super_romeo as a volunteer commentedGood question.
Please read #82, 83. Patch #64 and 66 works. I think 66 better. But those patches for D8.7.8.
I use D8.8 and I couldn't develope patches for D8.7.8 so far. Last my patch works for D8.8 but tests should be fixed for D8.8.
Comment #87
Zarghor CreditAttribution: Zarghor commentedHi guys,
I have an old project (d8), which uses field collections. I would like to migrate data to paragraphs d8 (the same site). Is it possible to do that using above patches or are they only d7 field_collection to d8 paragraphs. Thank you in advance.
Comment #88
super_romeo CreditAttribution: super_romeo as a volunteer commentedAFAIK only d7 field_collection to d8 paragraphs.
Comment #89
rutiolmaIndeed, the patch #64 was working fine for me and others and was passing the tests but D8.8.x introduced some modifications to migration lookup that should be addressed (as explained on comment #82).
Patch #80 works with Drupal 8.8-rc1 but it doesn't seem to make use of the new services (and I think it should). I believe we should focus on providing a patch that is compatible with core 8.8.x in order to be committed (and for D8.7.x one could use patch #64)
Comment #90
fadonascimento CreditAttribution: fadonascimento at CI&T for CI&T commentedThank you!!!
I can confirm that patch #64 works for me as expected with Drupal core 8.7 version.
Comment #91
super_romeo CreditAttribution: super_romeo as a volunteer commentedNow patch #80 passes tests and needs review, I think.
Comment #92
Will KirchheimerAny thoughts on a 8.8 patch?
Nvrmnd, see it states that it is functional
Comment #93
Will KirchheimerApplying #80 to 8.8 I am seeing:
Fatal error: Cannot redeclare Drupal\paragraphs\Plugin\migrate\field\Paragraphs::defineValueProcessPipeline() in /app/web/modules/contrib/paragraphs/src/Plugin/migrate/field/Paragraphs.php on line 79
I see this error when visiting the migrations listing page for a migration group.
Comment #94
iancawthorne CreditAttribution: iancawthorne commentedI have applied the patch at #80 on Drupal 8.8.
Can I check what the exact intentions of the patch are? I ask this because, with the patch I get migrations for both field collections AND paragraphs. Without it, these two different types are not present as migrations.
Field collection migration works well for me with said patch.
Paragraphs seems to get 3/4 of the way there. The paragraphs are migrated onto their nodes, but the fields on the paragraphs have no values.
Is it the intention of this ticket that it should provide migrations for both field collections and paragraphs?
Comment #95
fredonia_webteam CreditAttribution: fredonia_webteam commentedWe are getting same results as @iancawthorne, except we are getting successful paragraphs migration for the first paragraph type (alphabetically), but the other paragraph types are being ignored, which is resulting in empty values on the nodes. This is happening for both the single entity reference fields as well as the multiple entity reference fields. Any idea if this example is only for field collection only, and will not work if you have a mix of both field collections and paragraphs to migrate?
Comment #96
ghalusa CreditAttribution: ghalusa commentedI'm experiencing the same as @iancawthorne and @fredonia_webteam. I can confirm that the paragraphs are migrated onto their nodes, but the fields on the paragraphs have no values when there's a mix of both field collections and paragraphs on the D7 side using the patch at #80.
I've been toiling on this for weeks. I've tried a simple migration within vanilla D7 and D8 environments, with paragraphs and no field collections, and it worked fine. With paragraphs AND filed collections, it failed.
EDIT: Here's a CSV export of the totals from migrate:status, which are all the same for both paragraphs and paragraphs revisions, respectively. I'm hoping that this may help diagnose the issue.
Comment #97
fredonia_webteam CreditAttribution: fredonia_webteam commentedAfter checking in the db for target_revision_id values, it is not getting the proper value to display the paragraph item on the node. This may be a larger issue with the paragraphs migration.
As for the patch in #80, the fields collection items are getting migrated properly into D8.
I have submitted a new issue here: https://www.drupal.org/project/paragraphs/issues/3122342
Comment #98
artem_sylchukI found a problem while testing, the "field_name" property doesn't exist in the ParagraphsType row (D7ParagraphsItemDeriver::getDerivativeDefinitions line 120), it causes source plugin skipping the bundle condition and adding all paragraph items into each paragraph_item migration.
Here is the updated patch.
Comment #99
bubuI migrated successfully from Field Collections (7.x-1.1) to Paragraphs with patch #98 without any problem. I'm using Drupal 8.8.5, Paragraphs 8.x-1.11, Entity Reference Revisions 8.x-1.8. Thanks for the patch!
Comment #100
Sseto CreditAttribution: Sseto commented@bubu, do you have any tutorials for migrating?
Thanks!
Comment #101
bubu@Sseto, I didn't do anything special.
Comment #102
Sseto CreditAttribution: Sseto commented@bubu, it worked! I migrated my Field Collections to Paragraphs.
The only thing that's missing is none of my content that's using Field Collections is migrated into paragraphs. Any idea what's missing?
Thanks!!
Comment #103
DamienMcKenna@Sseto: Please clarify:
Thank you.
Comment #104
Sseto CreditAttribution: Sseto commented@DamienMcKenna
Thanks Damien!
Comment #105
DamienMcKenna@Sseto: So, in summary, the data structures were converted correctly, but the content for them did not.
Putting this back to Needs work as it seems we might need some more test coverage.
Comment #106
Sseto CreditAttribution: Sseto commented@DamienMcKenna
I figured it out!
I followed @bubu by installing paragraphs 8.x-1.11 instead of paragraphs 8.x-1.x-dev. So I reinstalled paragraphs using the dev version, then applied the patch from #98, and finally used migrate UI. Everything got migrated. woohoo!
Thanks guys!
Comment #107
DamienMcKennaOk, that's great to hear.
I still think it needs more test coverage.
Comment #108
DamienMcKennaWorking on defining test coverage.
Comment #109
bubuI'm done with migrating Field Collections to Paragraph on another site. Same setup and steps as in #99. Thanks.
Comment #110
DamienMcKennaThe existing patch appears to round out the test coverage that was already there from previous issues, well done everyone on that work!
I think it would be worth filling out the test coverage a little more to make sure that all of the three nodes with field collections (nodes 8, 9, 10) have the expected data, I made a start on it.
Comment #111
DamienMcKennaComment #112
huzookaEven though I need D7 paragraphs -> D9 paragraphs migration, this issue seems to be the best foundation for adding that as well.
But since the patch from #110 (that ends with -109) uses services that were removed from Drupal 9 (while the 8.x-1.x HEAD seems to be compatible with Drupal 9), I think that the next, reasonable step is adding a test for the state that #110 already provides on Drupal core 8.8.whatever.
The attached patch adds an extra functional test for testing Paragraphs' migrations via the Migrate UI.
* It adds the missing source fixture files (for the file migrations)
* It uses the Migrate UI for executing all of the migrations.
* Based on entity IDs and labels, it verifies that the expected entities exist after the migration.
Comment #113
bubu@huzooka, I can't install #112 on drupal/paragraphs 1.12.0.
Output:
I'm before a migration. I can test your patch If you upload a new one.
Comment #114
DamienMcKenna@bubu: Are you sure that your local install of Paragraphs is 8.x-1.12? I just downloaded 8.x-1.12 and the patch applied ok with only this variance:
Comment #115
bubu@DamienMcKenna, thanks for the replay.
Yes, I'm sure. I'm working with composer. I'm patching with composer, and I got this issue:
I don't know why this happens. This is the first time this has happened to me... Here is the long output. But, yes patching by hand is working:
Comment #116
bubuI performed migration with manually patched (#112) Paragraphs 8.x-1.12 and Entity Reference Revisions 8.x-1.8. It seems me everything OK.
In one of my previous comment I mentioned a problem with views. I fount that is an another issue, not related to this.
Thanks for the patches!
Comment #117
huzookaRe-rolled #112.
It seems that being able to correctly handle multilingual situations for both paragraph and field_collection entities is too big task for me :(. I'm sorry.
I think we will be unable to solve the paragraphs AND field_collection migrations by relying only on the migration lookup and the migration order, especially for multilingual situations:
For now, I'll create a new patch for making the existing migration plugins (except the paragraphs lookup) work with Drupal 9; but this one is only a re-roll.
Comment #118
huzookaComment #119
huzookaParagrapsProcessOnValue prevented the migration of comment field config (=field instance) config entities.
Comment #120
huzookaThis patch went a bit forward, and adds the parent entity identifiers for the paragraphs entity migration.
There are still open questions and tasks, but I hope that this will pass on both Drupal 8.8 and Drupal 9.0. Let's see.
Comment #121
huzookaComment #122
huzookaThe failing tests on core 8.9.x of #121 are exactly the same ones that are failing with 8.x-1.x HEAD.
I have concerns about migrating the field collection IDs: I think that Paragraphs has to keep the paragraph entity IDs and revision IDs.
Anyway, I think that this is close to be 'finished' (issue title is about the deriver and the base migration), and only Remaining tasks.5 has to be addressed.
Please confirm this!
Comment #123
heddnVery minor things. Tests seem very solid. Things are looking nice.
This should include 'Content' as well.
This variable is no longer used.
This classes seems more involved then I think is necessary now we have the lookup and stub service in core. Could we leverage them and remove some extra overhead?
Could we implement
ConfigurableInterface
so we don't have to litter the code w/ issets?Can't we just cast to an array?
8.7 has very little life left. Could we just start using the new stub service already?
s/threats/treats/
Comment #124
heddnThere's also:
paragraphs.module ✗ 6 more
line 5 Doc comment short description must end with a full stop
11 Unused use statement
12 Unused use statement
13 Unused use statement
14 Unused use statement
494 Missing parameter comment
496 Description for the @return value must be on the next line
tests/src/Kernel/migrate/ParagraphContentMigrationTest.php ✗ 1 more
71 There must be no blank line following an inline comment
tests/src/Traits/ParagraphsSourceData.php ✗ 1 more
129 A comma should follow the last multiline array item. Found: ]
Comment #125
huzooka@heddn, thanks for the instant feedback!
I realised that we still have to finish `ParagraphContentMigrationTest`.
Comment #126
zoraxHi all,
I try to migrate field_collection by drush.
paragraphs": "1.x-dev", entity_reference_revisions": 1.8
I have install the patch #121 but i have an error during migration of upgrade_d7_field_formatter_settings
[error] The "field_collection_fields" plugin does not exist. Valid plugin IDs
Do I need to change something in the upgrade_d7_field_formatter_settings ?
Comment #127
huzookaIssues #123.3, #123.4 and #123.6 still needs to be addressed.
I also finished the
ParagraphContentMigrationTest
kernel test I found following the coding standard errors raised in comment #124. (And also addedParagraphMultilingualContentMigrationTest
.)Comment #128
huzookaRe #126: @zorax, I think (I guess) that the
upgrade_d7_field_formatter_settings
migration you want to migrate misses the field type mapping what the patch(es) here trying to add. Could you please share its structure?Comment #129
heddnre #126: you also might need to flush cache.
Comment #130
heddnI don't think the conditional is needed. Casting an array to an array doesn't hurt and the conditional just adds to the cognitive overload.
$migration_ids = (array) $this->configuration['migration'];
Nit: spelling of avalilable
Hmm, this is a test. So we want to maybe use a data provider or something to trigger both paths. Or... explicitly only support node complete.
Paragraphs at this point only support 8.8+. See https://git.drupalcode.org/project/paragraphs/-/blob/8.x-1.x/paragraphs..... But we need to be able to handle both classic and the new node complete migration for some time. Because, there is a settings.php entry that allows people to use one or the other. Meaning, this isn't related to drupal security support. Is the testing impacted if we use one vs the other?
Comment #131
heddnI think knowing that paragraphs only support 8.8 might make implementing the remaining feedback from #123 easier. No need to support 8.7 at all!
Comment #132
huzookaRe 130:
130.1: Yeah, I realized right after I hit the Save button :)
130.3:
I think that Drupal 8.8.x wont get the complete migration path. :(
Comment #133
zoraxFor answering Huzoka, #128
Here is my class upgrade_d7_field_formatter_settings
Comment #134
Wim LeersI can confirm this — see @catch in #3076447-95: Migrate D7 entity translation revision translations:
Comment #135
huzookaRight after i fixed the migration for the Migrate Drupal UI (fixed means that I force the same migration execution order that we have in the paragraphs migration kernel tests for a while), I was unable to get the same results with the UI test :)
@heddn, I don't really want to touch ParagraphsLookup since I don't know how it should work. The way that may work is to create a 100% test coverage for its current functionality, and try to refactor after we have the test coverage.
Changes:
Further tasks discovered:
entity_reference_revisions
, I'd use theentity_complete
migration destination plugin for migrating paragraphs and field collections, but unfortunately it isn't available on Drupal 8.8.x. Shouldn't we just copy it and it's tests into Paragraphs?.. That would simplify our content entity migrations...d7_paragraphs:node:article:paragraph_bundle_one
,) or based on their parent field (e.g.d7_paragraphs:node:article:field_paragraph_one_only
). If we do continue derive them by their own bundles, it will easily end in orphaned paragraphs and partially migrated paragraph entities, since a paragraph can also have a paragraph reference field.It would be nice to have other test nodes that are translated with Entity Translation module.Edit: Paragraphs 7.x does not support Entity Translation.I'd like to ask for addressing all of these issues/ideas in separate issues, including also the ParagraphsLookup migration process plugin refactor.
Comment #136
huzookaUpdate for #135 Further tasks #5: Basically, this is how the current patch derives field collection migrations.
Comment #137
ghalusa CreditAttribution: ghalusa as a volunteer commentedLast patch that somewhat worked for me was #98.
The #135's patch is producing requirements errors for all of the revisions, but the requirements have clearly been executed.
Comment #138
huzooka@ghalusa, what do you have in your paragraph entity migration yaml(s)?
Comment #139
huzookaComment #140
huzookaComment #141
huzookaComment #142
huzookaComment #143
huzookaI just filed an issue (with a patch) that addresses #135 Further tasks #5 at #3145755-2: Orphaned (nested) paragraphs entities after migration & (invalid) stub paragraph entity leftovers.
Comment #144
heddnSeeing as we are over 100kb and this has gone through a ton of review and manual testing, we need to see this land sooner, rather then later. We can always refactor things in follow-ups, as long as we don't have BC concerns. Which I think we are stable enough with the current approach to say we are "good enough".
Just a few small nits, mostly just adding todos.
Can we open and link in an issue for this todo?
Nit: these don't contain the ascii art that was in them in core.
Comment #145
huzookaComment #146
huzookaAddressed #144.
Also added a patch without the test improvements and new tests.
Comment #147
heddnI'm happy to mark RTBC.
Comment #148
Wim Leers🥳🥳🥳
Comment #149
fredonia_webteam CreditAttribution: fredonia_webteam commentedWe are running into the same errors as @ghalusa has in #137. Patch #98 was working for field collections and paragraphs migration from D7. Updated to patch #146, now we are having errors with migrating D7 paragraphs_revisions. Not certain this patch is the problem as we did update to Drupal 8.9 and Paragraphs 1.12 also.
Comment #150
benjifisher@fredonia_webteam,
It would help if you could give enough details so that others could reproduce your problem.
Comment #151
Sseto CreditAttribution: Sseto commentedDo you guys know if it's safe to remove all my field_collection tables in my database after the migration?
I want to remove these tables:
migrate_map_d7_field_collection
migrate_map_d7_field_collection_revisions
migrate_map_d7_field_collection_type
Thank you!
Comment #152
Sseto CreditAttribution: Sseto commentedHey guys,
I recently migrated my D7 site to D8. In the upgrade, I migrated all my Field_Collection module content to use Paragraphs.
Everything worked perfectly until I decided to try out Layout Builder...
When I activate Layout Builder in a content type that uses paragraphs, I get:
The website encountered an unexpected error. Please try again later.
in dblog, it says this:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "field_collection_item" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of C:\wamp64\www\sseto\web\core\lib\Drupal\Core\Entity\EntityTypeManager.php).
Any idea how to fix this issue?
Thank you!
Comment #154
BerdirLots of tests, RTBC from @heddn and most importantly, ASCII art from DS9. That's good enough for me to commit without checking too closely. Thanks everyone!
@Sseto: i suggest you create a separate issue for that, doesn't sound related to the migration.
Comment #156
mstrelan CreditAttribution: mstrelan commentedThis is amazing and perfect timing. Thanks to all involved.
Comment #157
iancawthorne CreditAttribution: iancawthorne commentedLast time I tried to get both field collection and paragraphs migrations to work was with patch #80 on here. On that occasion field collections migrated fine in full, while paragraphs seemed to be a bit all over the place - wrong fields, wrong data etc.
I've just tried the latest dev release of paragraphs, which if I have understood correctly includes the committed patch here. Now I get paragraphs migrating 100% fine, but on the field collections, the fields of the collection are missing. No errors in the feedback during the migration using drush. Are there any follow up tickets for this one? Does anyone have any tricks to get it to work like running certain migration items before others?
Comment #158
vacho CreditAttribution: vacho at Skilld commentedThere are at least a full example ymls that works?
At this time I can't get works the importer yml that set the paragraphs into node (d7_node)
I get the yml that uses the plugin d7_field_collection_item works well getting the field collection values into paragraphs structure.
Comment #159
Wim LeersA bug was reported and a fix was provided at #3192993: [migrate_upgrade compatibility] d7_field_instance upgrade fails due to redundant 'field_' prefix removal on bundle.
Comment #160
Wim LeersAnd … Drupal >=9.1.4 broke this: #3203739: Paragraphs migrations broken in Drupal >=9.1.4.