Hello,

While testing migration from phpBB to Drupal with the migrate and phpbb2drupal modules, I noticed the following:

  • Posts from currently nonexistent users are all mapped to user admin / User 1
  • Private messages from currently nonexistent users are all mapped to user admin / User 1

This leaves the imported forum in an inconsistent state. I understand that migrate tries to correlate the entries with existing users in the DB, but what can be done about this so that the end result is as follows?

Data from old users is imported with their old user ID and treated as retained data from deleted users.

See also here and here.

Thank you

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Data from old users is imported with their old user ID and treated as retained data from deleted users.

Sorry, I don't understand that... Content authored by users that have been imported will be assigned to their account on the destination site. I.e., if user example1 (user ID 123 on the original site) authored a given piece of content, when they're migrated and get assigned Drupal uid 456, then the account with 456 will be the author of their content (assuming proper usage of sourceMigration(), of course). "retained data from deleted users" makes no sense to me - deleted users of course would not be imported, right?

Now, if there are users that don't get imported because they're deleted, and content that had been authored by them is still pointing at the non-existent account (e.g., an article author is uid 123, but that account was deleted and not imported), then the author by default ends up as Drupal uid 1 - but you can override that mapping and default unresolved authors to another Drupal account if you want.

marktheshark’s picture

Status: Postponed (maintainer needs more info) » Active

Let me clarify my use case further:

I have a 10-year old forum to import. Some forum posts, topics and private messages belong to users that no longer exist.

The default logic of assigning this to User 1 since there is no prerequisite user for these items, doesn't work out very well because:

  • The admin appears to have written all these posts
  • The admin appears to have engaged in private messaging with several users

This is quite a blocking issue for my use case.

Could you advise how to override this and:

  • Either allow the post to be inserted with a nonexistent user ID
  • Or create a mock user for every different source user name, then either delete them automatically and retain their data (or I can detect and delete these old accounts manually afterwards).

Thanks

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Really? You want posts to be authored by a non-existent account? Well, yes, you could create dummy users and then delete the rows from the users table, but there's too much stuff in Drupal and in contrib modules that depends on the database being self-consistent, you'll have a horrible mess on your hands if you break the data model like that.

If you really can't abide the admin or anonymous accounts as owners of orphaned content, then I would suggest creating a single dummy account, say with the username "Deleted User", and defaulting content ownership to that account.

marktheshark’s picture

Well, leaving ownership to the admin can be misleading (people may think the admin actually authored these posts, the content of which may be debateable, it is a public forum after all).

Having one fake user for this content is also a bit problematic, since it would accumulate all content and give the impression that there was a single old user responsible.

Logic similar to "Delete the account and make its content belong to the Anonymous user." from the account settings would be viable I guess, or "Disable the account and keep its content."

The problem with disabling the account is that all users are imported as blocked, so I cannot distinguish old from new.

P.S. When I mean deleting user, I don't mean from the DB directly. But I guess the schema precludes this from happening, thus the user must either be blocked, or the Anonymous user must be used.

mikeryan’s picture

That username for the dummy account could be as helpful as you like (well, up to 60 characters) - e.g., "The account authoring this post has been deleted".

Anyway, you just have to override the uid mapping in your node migrations to change the default value:

$this->addFieldMapping('uid', 'legacy_phpbb_id', FALSE)
     ->defaultValue(0);

That's to get anonymous ownership - alternatively, you could pass the uid of a dummy account.

marktheshark’s picture

Thanks, I guess I'll go for the Anonymous User approach for simplicity.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

markup