Closed (fixed)
Project:
Paragraphs
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Sep 2017 at 19:43 UTC
Updated:
5 Mar 2018 at 08:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
citlacom commentedToday needed to work on a migration of field collection items to paragraphs and after experiment few different approaches I found in issues, concluded that the patch from https://www.drupal.org/project/field_collection/issues/2757989#comment-1... was the most close to my expectations so did some coding styling tweaks and ported that patch to the paragraphs module and it worked fine, the migration of some field collection items to paragraphs was a success so I share the final result here.
The migration config looks:
Comment #3
citlacom commentedComment #4
heddnSeems like a duplicate of #2897021: [META] Migrate support for importing field collections as paragraphs and more specifically #2911241: Migrate field collections types as paragraph types
Comment #5
mikelutzReopening this, as the field collection source is different than the field collection type source plugins.
I'm attaching my patch files which include 4 source plugins for field collections, field collection revisions, paragraphs and paragraphs revisions.
When it is time to include translations, I will likely update these to get more metadata from the node which references them to pass in.
No tests, but these files will be required for the other issues in this meta.
Comment #7
mikelutzFixing a typo.
Comment #8
mikelutzI've added a couple of tweaks here to the type plugins that are needed in later stages.
Comment #9
mikelutzComment #10
miro_dietikerI see multiple issues building on top of this.
As this has no test coverage on its own, should we really commit it separately?
Comment #11
mikelutz@miro_dietiker I would probably not commit this on it's own. It's been rolled into the patch I posted on the meta issue already, and that has some test coverage. While these source plugins are self-contained, they do not do anything without the other patches.
Comment #12
miro_dietikerThe fixture is in, triggered a retest here.
@heddn requested to get this in separately. Are we thus moving some tests over?
Comment #13
mikelutzI will rebase against the new fixture and add some test coverage specifically for this issue today.
Comment #14
mikelutzOkay, This patch adds test coverage for each of the 6 source plugins. There is some minor tweaking of the type plugins already committed. I renamed Drupal\paragraphs\Plugin\migrate\source\d7\ParagraphType to ParagraphsType to match the plugin id, and maintain consistency. I refactored FieldCollectionType to not look for a prefix in configuration and just strip the first 6 characters when creating bundle names and descriptions. I unified the class descriptions across all 6 classes.
Pending review, I think this is ready to be committed and used for future migration work in the other issues.
Comment #15
mikelutzI need to do better self review before I post.. I found a few places where code spacing or comments wasn't consistent between similar files, so I fixed them up. No functional changes here from #14, except changing the source id for the field_collection_type from the database numeric id to the field_name, to be consistent with the paragraphs type source.
Comment #16
heddnLots of small nits. This is looking really good.
Renaming is fine as these are just place in time copies. No BC layer needed.
Copy/pasta. Probably can be removed.
It would be super helpful if we could add some doxygen comment to the class explaining what this config option is all about. It isn't just clear.
Let's add a comment on what we are doing here. Or better yet, create a class constant with comments what this magic number is all about.
Is this just the revision id or is it revision id + item_id?
Great comment. Better if we make this a class constant.
It would be nice to add some docs on what this config option is all about.
I think that the data model in D7, paragraphs used a composite ID as well. If I'm correct, then this should be a combo of both values.
Can we keep a BC layer and the former class in the code base? It should extend this new class and add a trigger error, etc as listed in https://www.drupal.org/core/deprecation#how-class. Its been in the code base for a while now, someone might be using it. And its super easy to add the BC layer, so let's just do the right thing.
I think a !empty check would do mostly the same thing. No?
Probably this is just bikeshedding, but should we create a new field_collection test group for these things?
Can we add a quick comment here why we have paragraphs data in a field collection data provider?
Comment #17
mikelutzThis addresses 1,2,3,4,6,7,9,10, and 12
For #5 and #8, the ids are correct. The *item sources migrate the current revision of each entity, and the entity id uniquely identifies the source row. The *item_revision sources migrate the remaining revisions, and the revision id uniquely identifies the source row. This is important because we are potentially migrating both field collection and paragraph entities into paragraph entities, so all the ids and revision ids are changing and we definitely need the migration maps to map them back up again.The source ids are really only used for mapping, and we definitely want to be able to look up the new entity id without knowing the revision and vice versa. The *item migrations let us map the old entity id to the new entity id without knowing the revision, which is important, because later the revision migration needs to be able to look up the entity by the id and create a new revision off of it.
for #11, I think field_collection has it's own field_collection test @group and we should leave them to it. Our namespace is paragraphs
Comment #19
mikelutzHuh. I guess I need to change the id of the BC class, the test passed locally, so I assumed the extra tags would let the plugin manager select the correct class. I never added a BC class in the first place because I kept the plugin_id and the class should have only been loaded by the plugin id, so I figured the plugin manager would just find the new one no problem. Anyway, try this.
Comment #20
heddnNo need for an id on the BC class. Its only there if someone extended it. The id and the plugin system will find the non-BC class in its new name.
Comment #21
mikelutzYou are right, I got confused. This should be deprecated properly.
Comment #22
mikelutzComment #23
heddnI just discovered
ConfigurablePluginInterfaceyesterday. I suggest we use it for all our configs here in these various source plugins. And I also don't see any doxygen added to sources that have config options. Let's add those docs. Not everyone is going to use an automatic deriver, or even know how to find it. So adding the docs on the classes themselves will only help others and our future selves.Otherwise, this is looking really close.
Comment #24
mikelutzComment #25
mikelutzTake a look and tell me if that works for you. I added comments and some base classes to implement ConfigurablePluginInterface.
Comment #26
heddnVery close now.
There's nothing saying config should be snake vs camel. Commerce 2.x uses camel. Its actually not too uncommon in contrib.
This can all be simplified to simple checks as I see you did in other places.
Like:
if ($this->configuration['foo'])Comment #27
mikelutzKeeping the new add_description key, but I moved the BC layer and default configurations out of the base plugin and into the two source plugins, and added proper deprecation documentation and error triggering. I simplified the two config checks I missed. (The middle one you posted was a - row : already fixed)
Comment #28
heddnAll looking good. Only very, very small nits. Which could be resolved at commit or left in the code. Commiter discretion.
Nit: spelling. Can be fixed on commit.
We should trigger only if addDescription is set. No need to check if add_description too. But no big deal either if left in the code. Could be removed at time of commit.
Comment #29
heddnThere's now enough nits I'm going to unfortunately push back to NW.
This, and elsewhere, doesn't match the typical method for doing this. This was bugging me when I looked at the code earlier, but I couldn't put my finger on what it was. Below is much more typical.
Comment #30
mikelutzAlright, I confess to misspelling deprecated a lot, but of, that, particular, and type are all right...
Configurations aren't complex enough to require a nested merge, so I'm fine with simple addition.
My goal was to not override add_description if they were both set, but we definitely need to trigger the error if addDescription is set either way, so I've configured that.
Comment #31
heddnPhenomenal work here. All feedback addressed.
Comment #33
miro_dietikerAwesome progress! Committed so we can easily move forward. :-)