Hi to all,

When I am trying to migrate my migration with drush I get an error with no description at node.inc. The line is at
$query->execute(); and when I drush_print it I get the following :

>drush mi mymigration -v
Initialized Drupal 6.22 root directory at /var/www/html/mysite [notice]
Initialized Drupal site html at sites/default [notice]
Importing 'mymigration' migration [notice]
WD location: Deleting unreferenced location with LID 199. [notice]
UPDATE {node_revisions} SET uid=:db_update_placeholder_0
WHERE (vid = :db_condition_placeholder_0)

(/var/www/html/esynet.gr/sites/default/modules/migrate/plugins/destinations/node.inc:256)[error]
Processed 1 (0 created, 1 updated, 1 failed, 0 ignored) in 0.6 sec [completed]
(98/min) - done with 'mymigration'
Command dispatch complete [notice]

Any help ?
Thanks in advance

Comments

drewish’s picture

What's in the PHP error log at that point? Anything? Seems like there's a problem with the SQL that's being generated but it's hard to see exactly what… it seems staring it's trying to re-use the placeholder. As far as I know that's not allowed, but I'm not sure why the version id would make sense as a user id...

kyriakoy’s picture

Thank you, I really don't know how to troubleshoot this.

The query:
UPDATE {node_revisions} SET uid=:db_update_placeholder_0
WHERE (vid = :db_condition_placeholder_0)
is produced by the drush_print($query) a was put at the error line.

The migration is work ok except 2 things:
1. the above error
2. the content type I try to insert/update have a field_userA (node relation to user node), I cannot update, it I try both,
$this->addFieldMapping('field_duserA', 'siteid_c'); //siteid_c is an ID to an existing user from an external DB
and
$this->addFieldMapping('field_duserA_uid', 'siteid_c'); // I notice that at the content type table the 'field_duserA' is actually the field 'field_duserA_uid'

unfortunately nothing is updated for this field

At least a way to troubleshoot this ?

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Last things first:

$this->addFieldMapping('field_duserA_uid', 'siteid_c'); 

is wrong - you use the field name, not the SQL column name in field mappings.

$this->addFieldMapping('field_duserA', 'siteid_c'); 

You say siteid_c is the external user ID - thus, you need to add ->sourceMigration('MyUserMigration') so Migrate can translate that external ID to the Drupal uid.

As for the error, as drewish points out it seems funky to have the same placeholder show up in both places. A drush_print_r($fields) might help, as well as seeing what $node->vid is.

kyriakoy’s picture

Thanks for the tip for users!!

A drush_print_r($fields) shows:

Array
(
    [uid] =>
)

The $node->vid is the same as $node->nid

The error happens only when a record exist and try to update it (it not happen when create a new record), I am using highwater value.

>Processed 1 (0 created, 1 updated, 1 failed, 0 ignored) in 0.9 sec [completed]

And when it happens ti logs the following 4 records at mymigrations_messages table:

1. (C:\Apache\htdocs\mysite\sites\default\modules\migrate\plugins\destinations\node.inc:258)
2. Undefined index: !message
File C:\Apache\htdocs\mysite\sites\default\modules\migrate\includes\base.inc, line 562(file: C:\Apache\htdocs\mysite\sites\default\modules\migrate\includes\base.inc, line 562)
3.Undefined index: uid
File C:\Apache\htdocs\mysite\sites\default\modules\nodeaccess\nodeaccess.module, line 491(file: C:\Apache\htdocs\mysite\sites\default\modules\nodeaccess\nodeaccess.module, line 491)
4.Trying to get property of non-object
File C:\Apache\htdocs\mysite\sites\default\modules\nodeaccess\nodeaccess.module, line 852(file: C:\Apache\htdocs\mysite\sites\default\modules\nodeaccess\nodeaccess.module, line 852)
5.Undefined index: messages
File C:\Apache\htdocs\mysite\themes\acquia_marina\template.php, line 38(file: C:\Apache\htdocs\mysite\themes\acquia_marina\template.php, line 38)
6.Undefined property: stdClass::$uid
File C:\Apache\htdocs\mysite\modules\node\node.module, line 953(file: C:\Apache\htdocs\mysite\modules\node\node.module, line 953)

mikeryan’s picture

I'm guessing that you are mapping something to 'revision_uid', and for that row it's empty, correct? What if you don't map it? Or, if in node.inc you replace isset($node->revision_uid) with !empty($node->revision_uid)?

jonskulski’s picture

Running into this as well. Added a debug statement here:

246       $revision_uid = isset($node->revision_uid) ? $node->revision_uid : $node->uid;
247       dd("$revision_uid :: $node->revision_uid :: $node->uid");
248       if ($revision_uid != $GLOBALS['user']->uid) {

showed that all those variables are not set, resulting in

  :: :: 

So changing

 $revision_uid = isset($node->revision_uid) ? $node->revision_uid : $node->uid;

to

 $revision_uid = !empty($node->revision_uid) ? $node->revision_uid : $node->uid;

won't change anything. Let me know if there is any other debugging I can help with.

jonskulski’s picture

For those looking for a work around, mapping or specifying the uid should work just fine:

      $this->addFieldMapping('uid')->defaultValue(4);
      // or
      $this->addFieldMapping('uid', 'sourceuid')->defaultValue(4);      
kyriakoy’s picture

No, I am not mapping something to revision_uid.

kyriakoy’s picture

It sows the same result:
:: ::

kyriakoy’s picture

Actually adding this:

<?php $this->addFieldMapping('uid')->defaultValue(1); ?>

it's not produce any error.
It's seems that assign the uid to something except 'Anonymous' is a requirement.

Thanks

mikeryan’s picture

I'm not clear on where this left off - is setting defaultValue(1) for uid working fine for you?

jonskulski’s picture

Mike,

Pretty sure I had the exact same issue. #6 provides some info, though I did not dig deeper. #7 (providing a default value) works just fine.

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Fixed

defaultValue() works fine.

Status: Fixed » Closed (fixed)

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