Closed (works as designed)
Project:
Drupal core
Version:
9.4.x-dev
Component:
migration system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Jan 2020 at 01:09 UTC
Updated:
8 Nov 2022 at 20:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
wim leersInteresting!
This is probably due to
content_moderation'shook_entity_presave()+hook_entity_insert()implementations.Comment #3
mariaioann commentedI have the same problem. Moreover, due to content moderation new revisions are created for nodes when executing an incremental nodes migration (with --update flag).
Comment #4
kualeeI have just tried migrating one site from latest D7 to D8.8.2 and faced the exact same issue.

Any content types that doesn't have content moderation applied would migrate just fine, all revisions included.
Those content types with content moderation applied would face the above issue (unpublished)
I have also faced another issue (not sure whether related):
When trying to publish those unpublished contents, I also get error message "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved."
I found this old issue that is possibly related, see https://www.drupal.org/project/drupal/issues/2848089#comment-12609586 #9, first point.
The patch in this issue has been committed to core though, not sure why this issue still persists.
Comment #5
mariaioann commentedI have managed to overcome the problem with content moderation and migration as follows:
Comment #6
logickal commentedWe ran into this ourselves after we had added moderation to a content type and re-tested our migration. After some digging, I think the solution is relatively straightforward:
1) We had already subclassed the d7_node source plugin for our own purposes, and had a prepareRow() implementation already. If you don't have that, then you can either take this approach or create an event subscriber similar to what is outlined in https://www.lullabot.com/articles/overview-migrating-drupal-sites-8.
In our prepareRow, we based that check on published state, so it looks something like this:
What we are doing here is adding the moderation_state property to the row, since it doesn't exist from the Drupal 7 data.
2) Now, you just need to make sure that your migration config is handling that data from the row and setting the destination with that property:
moderation_state: moderation_stateComment #9
akozoriz commentedI think you could use static_map plugin to properly setup moderation_state and node state
Comment #10
quietone commentedAn idea for a test.
Comment #12
quietone commentedMaybe put some login on EntityContentBase that adds the moderation state.
Comment #14
quietone commentedCoding standard fixes.
Not sure why there are failures, the test passes locally.
Comment #16
quietone commentedOf course, I am working on 9.1.x.
Comment #17
mikelutzIt's quite a large patch for such a tiny change, but I think the test is useful. The fix looks correct, and it fixes the test, LGTM.
Comment #19
mikelutzRtbc for 9 and 9.1, will need a reroll if RMs want to backport to 8.
Comment #20
larowlanIt is possible to enable moderation of entities other than nodes - should we be using some of the logic that CM uses - ie.
$entity_type->hasHandlerClass('moderation')is there a reason we check for the 'moderation' property, but then set the 'moderation_state' property?
Unfortunately, we cannot assume this either. Moderation states are per-site. Yes, these two are defined in the editorial workflow in the standard profile, but they may be named something completely different in actual sites.
Can we make that configurable perhaps?
Or should this whole thing just be resolved by process pipelines, i.e Migrate can't know all the things, and this might be some customisation that migrating sites need to consider?
Comment #21
mikelutzSo the big issue here is, what are we trying to code for? In core, typically we are coding for the big one-off migration. In that case, nothing in d7 or d6 was moderatable except for nodes, so on that level, #20.1 makes sense, and is also the reason for #20.3, in that we are trying to map the status into the default moderation state. For #20.2, I maybe wrong, but I think somewhere we set the moderation property to tell the destination to treat the import as a moderated node, and should therefore set the moderation_state, but I do need to check that still.
The bigger issue right now is, If we go back to the initial issue reproduce steps though, we get:
This, of course is not how the core migration system works. The migration system in core is a direct migration from a d7 site. The steps to reproduce above is not running a core migration. it's creating a custom migration. Which is fine, we support and allow that. So the issue is really just asking for a custom migration using the standard destination to set the moderation state if it's enabled. That gets tricky for a few reasons, #20.3 above specifically.
So what's really important here, is that if you are coming from d7 workbench moderation that we handle that correctly. And if you are migrating a custom migration into a moderated node bundle, that we give you a way to handle that correctly, and I think we already do. If you do steps one and two above, then in step three, you are responsible for setting status and moderation_state according to however you set up that node. we should not be trying to guess in core. I think this is working as designed. I'm going to set it to NW for a week for someone to convince me otherwise, but I don't think this needs to be done in core.
Comment #23
mrP commentedRan into this same issue. The static_map approach as in #9 worked great for my purposes.
@akozoriz Thanks!
EDIT -- I did find that
node_field_data.publish_stateandnode_field_data.unpublish_statedid not get populated. However, that appears to be more on the scheduler end of things. Perhaps they can address this as a part of #3012154: Migration handler for publish_on and unpublish_on node fields.Comment #25
wim leersI think you're right. But I also think it needs to be documented explicitly. Perhaps in a change record, for visibility and discoverability? (Even if that is atypical.)
Comment #26
nikhil_drupal commented@larowlan Did you found a solution for this...?
I came across same issue now, In D7 we have different moderation states like draft, needs-review, rejected, etc. when I'm migrated the d7_node_Complete_node_type plugin, it dont show the custom moderation states names and rather it saves as draft for all the revision version even the published version.
Can someone help with fix .
My drupal version is 8.9.7
Comment #27
hardik_patel_12 commentedFaced this same issue. The static_map approach suggested in #9 worked great for my purposes.
@akozoriz Thanks!
Comment #29
aolvera commentedReroll for 9.3.x
Comment #30
mikelutzClosing this as there is consensus that there is nothing to do for core migrations.
Comment #31
fengtanWe ran into this as well and applied a fix similar to #6 and #9, with moderation state mappings defined in the yml migration file instead of the event subscriber: