I've created a UserMigration class as an extension of the Migration class. What happens to user created content when that user is removed during a Rollback operation on the Migrate admin page?

This is my situation: I've imported a number of users, one of them created some content and then a while later I realised that part of the user migration was incorrect. I fixed my UserMigration class, rolled back the migrated users and the imported again. Everything seemed fine until I realised that the content created by the user had disappeared completely. I may have expected the content to be unpublished or assigned to the Anonymous user, but I didn't expect it to get deleted.

OK, so I'm not entirely sure that the content was removed during the migration rollback, hence I'm filing a support request rather than a bug report at the moment. I will continue to investigate.

Thanks!

Comments

StuartDH’s picture

Have you checked your setting under 'When cancelling a user account' in /admin/config/people/accounts?

eddie_c’s picture

Thanks for the reply StuartDH. I've just checked and it's set to "Disable the account and keep its content."

I'm trying now to see if I can reproduce this problem on a test site.

eddie_c’s picture

I can reliably reproduce this issue on my test site. Content created by a user is always removed regardless of the settings I have under /admin/config/people/accounts.

Is there anyway in which the UserMigration class in which I define the field mappings for source and destination could be breaking the rollback functionality? I assume the rollback operation doesn't use that class at all.

mikeryan’s picture

Status: Active » Fixed

This is how Drupal works - when a user account is deleted (not just canceled, deleted), all content created by that account is deleted as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mwallenberg’s picture

I just encountered this issue, and one workaround is to assign the content to a user that is going to be kept (the anonymous user, for instance) at the beginning of the rollback, and then set back to the correct user after the re-migration.

This can be done by hand if you only wish to keep a small amount of nodes, or it can be included in your migration classes, for example via preRollback() and postImport().

By the way, Migrate is awesome. I recently did a migration from a D6 multisite with 30 sites as well as two peripheral systems to a single D7 site with OG, and Migrate was a huge help there. Thanks for all the hard work you've put into it!

eddie_c’s picture

mwallenberg, Good tip, thanks for that. I'll bear it in mind next time I come across this problem.

StuartDH’s picture

I think the mollom module changes the way that users are deleted, enabling you to delete the user, but reassign the content to another/anonymous.