Closed (fixed)
Project:
Field Collection to Paragraphs
Version:
2.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Jul 2021 at 16:07 UTC
Updated:
9 Aug 2021 at 17:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
damienmckennaI can confirm this bug.
Comment #3
damienmckennaAfter running the migraiton the parent_id, parent_type and parent_field_name values in the paragraphs_item_field_data table are blank.
Comment #4
damienmckennaThe new fields on the parent entity (node__FIELDNAME_paragraph) are also blank.
Comment #5
ckngYes, correct, same observation. Going through the codes.
Comment #6
damienmckennaI noticed that when you first install the module and run migrate:status the field_collection_to_paragraph_parent_node migration shows zero records to import, but then when it runs it finds some records, though not all of them.
So there are two problems here: the query is wrong, and the data doesn't get migrated.
Comment #7
damienmckennaquery() generates a query that looks like this:
Shouldn't it query the source data instead of the destination data?
Comment #8
damienmckennaNever mind, I forgot that the source is D8, so that part of the query is correct X-)
The query gets a list of unique node IDs that have the field records, so while there might be e.g. 200 records in the table there might only be 50 unique nodes as many of them have multiple values.
Comment #9
damienmckennaWhen the import has not been ran yet $bundles does not have any values, so query() fails early. And that's because $mappings is empty. And $mappings is empty because migrate_map_field_collection_to_paragraph_parent_field_instance hasn't ran yet.
Comment #11
damienmckennaWhen the migration gets to FieldCollectionParentNode::prepareRow() it has the node ID and revision ID but it doesn't have the paragraphs data, so it can't update the records. Instead it loops over the values from the node and just re-assigns them, which does nothing. It has FieldCollectionParentNode::$fields but that's hardcoded with most of the columns from node_field_data, but then it doesn't use it.
Comment #12
damienmckennaI think the parent migrations should load all of the records from the original field and then manually save them in the new paragraphs field after reconfiguring the columns. Specifically, the source table has FIELDNAME_value and FIELDNAME_revision_id, while the destination has FIELDNAME_target_id and FIELDNAME_target_revision.
Comment #13
damienmckennaI was going about this wrong - the source plugin isn't supposed to prep the data for the destination, FieldCollectionItemParentSourceMigration is supposed to add extra fields to the process section of the migration to map the data. But for some reason it doesn't seem to be executed.
mikeybycode: Did this actually work for you?
Comment #14
damienmckennaIt was suggested to update to the latest dev snapshot of Paragraphs, because of #2911244, but this didn't solve the problem for me.
Comment #15
damienmckennaI worked out the fix!
Comment #17
damienmckennaThis fixes the problem in my local testing. Committed.
Comment #18
ckngTested, working for me too.