0

On the basis of an RSS feed, I am required to create Group entities and Users out of the feed's items.

Each item contains sufficient data:

<item>
  <id>123</id>
  <title>An example</title>
  <description>Some &lt;strong&gt;HTML&lt;/strong&gt; description.</description>
  <author>John Doe</author>
  <email>john.doe@example.com</email>
  <pub_date>09/19/2017 - 08:30</pub_date>
</item>

I am using Core's migration module along with migrate_plus and migrate_tools and wrote two migration yml files, one for creating Group entities out of the items and one to generate users out of the author & email fields.

Taken separately, both work fine, that is I am getting Group entities and User entities as expected. The only issue which I can't get my head wrapped around is to set the respective User to be the Group's owner.

Here's the processing part of the Group yml file:

process:
  uid:
    plugin: migration_lookup
    migration: migrate_plus.migration.users
    no_stub: true
    source: email
  label: title
  field_description: description
  created:
    plugin: format_date
    from_format: 'm/d/Y - H:i'
    to_format: 'U'
    source: pub_date
  status:
    plugin: default_value
    default_value: 1
  type:
    plugin: default_value
    default_value: my_group_type

migration_dependencies:
  required:
    - migrate_plus.migration.users

All fields except for uid are set correctly. If I change the user id process part to something static like

  uid:
    plugin: default_value
    default_value: 1

it works as well and the Group's owner is set to the Super User account. So, I reckon there's something wrong with the migration_lookup processing part. I have read numerous tutorials on how to use that and it looks fine to me. I also read that migration_lookup fails silently if there is an error which makes it hard to debug.

Looking at the migration map table in the database it looks fine too:

mysql> select * from migrate_map_users limit 1;
+-----------------+----------------------+---------+-------------------+-----------------+---------------+------+
| source_ids_hash | sourceid1            | destid1 | source_row_status | rollback_action | last_imported | hash |
+-----------------+----------------------+---------+-------------------+-----------------+---------------+------+
| 009d...234ef457 | john.doe@example.com |     118 |                 0 |               0 |             0 |      |
+-----------------+----------------------+---------+-------------------+-----------------+---------------+------+
1 row in set (0.00 sec)

Due to the migration dependency through

migration_dependencies:
  required:
    - migrate_plus.migration.users

the User migration should also run first, but it still doesn't work. Even after both migrations have run through, I tried an update migration run, but the Group's owner is never set (stays at being 0/Anonymous).

Is there soemthing wrong with my yml file? Are there other means to connect user and groups?

0

s/migrate_plus.migration.users/users/

The "migrate_plus.migration." is not part of the migration plugin ID - it is only part of the filename for the config entity.

  • Since all tutorials actually write just users, I tried that first, of course, but it never worked at all. Thus, I started using migrate_plus.migration.users and then the reference happened. For my specific problem, I ended up using entity_lookup instead of migration_lookup as a workaround. – Paul Sep 20 '17 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.