Full Message:

First parameter must either be an object or the name of an existing class File /home/quickstart/websites/sid.dev/modules/user/user.module, line 552
Processed 1 (0 created, 0 updated, 1 failed, 0 ignored) in 0.1 sec (1074/min) - done with 'SIDstaffContent'

I receive this when trying the import...
my class looks like this:

class SIDstaffContentMigration extends Migration {

  public function __construct() {

    parent::__construct();
    
    $this->description = t('Migrate SID content from csv file');
    
    $columns[0] = array('id_csv', 'Unique ID');
    $columns[1] = array('name', 'name');
    $columns[2] = array('mail', 'mail');   
    
    $this->source = new MigrateSourceCSV(drupal_get_path('module', 'migrate_sid').'/csv/tbl_staff.csv', $columns);
    
    $this->destination = new MigrateDestinationUser();
    
    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'id_csv' => array('type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'description' => 'Unique ID',
                            )
        ),
      MigrateDestinationUser::getKeySchema()
    );
    
    //standard fields
    $this->addFieldMapping('uid', 'id_csv');
    $this->addFieldMapping('name', 'fullname');
    $this->addFieldMapping('mail', 'mail');
    
    //all the fields we don’t wanna map in the destination!!!
      $this->addFieldMapping('pass') 
      ->issueGroup(t('DNM'));
    $this->addFieldMapping('theme') 
      ->issueGroup(t('DNM'));
    $this->addFieldMapping('signature') 
      ->issueGroup(t('DNM'));	  
    $this->addFieldMapping('signature_format') 
      ->issueGroup(t('DNM'));
    $this->addFieldMapping('created') 
      ->issueGroup(t('DNM'));	  
    $this->addFieldMapping('access') 
      ->issueGroup(t('DNM'));
    $this->addFieldMapping('login') 
      ->issueGroup(t('DNM'));  
    $this->addFieldMapping('status') 
      ->issueGroup(t('DNM'));  
    $this->addFieldMapping('timezone') 
      ->issueGroup(t('DNM'));
    $this->addFieldMapping('language') 
      ->issueGroup(t('DNM'));	
    $this->addFieldMapping('picture') 
      ->issueGroup(t('DNM'));	  
    $this->addFieldMapping('init') 
      ->issueGroup(t('DNM'));	
    $this->addFieldMapping('data') 
      ->issueGroup(t('DNM'));
  

  }

Comments

mikeryan’s picture

Category: bug » support
Status: Active » Fixed
$this->addFieldMapping('uid', 'id_csv');

What's happening is that user_save() is seeing a uid value, and without is_new set to tell it you want to create a new user account with that specific uid value it's assuming that it's supposed to update an existing account with that uid. But, there is none.

If you want to preserve the old ID as the Drupal uid, you need to add

$this->addFieldMapping('is_new')
     ->defaultValue(TRUE);

If that's not what you're trying to do, do not map anything to 'uid'.

Status: Fixed » Closed (fixed)

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

tinflute’s picture

This helped me!

mccrodp’s picture

Status: Active » Closed (fixed)

I added user.inc from the migrate_d2d module to my custom migrate module folder and info file and added the following override

$this->addFieldMapping('is_new')
     		 ->defaultValue(TRUE);
    
    $this->addFieldMapping('uid', 'uid');

This does not import users and gives the migration error messages below

MigrateException: First parameter must either be an object or the name of an existing class File ....modules/user/user.module, line 560 in MigrationBase->errorHandler() (line 530 of .../modules/migrate/includes/base.inc).

First parameter must either be an object or the name of an existing class File ....modules/user/user.module, line 560

Everything looks fine at admin/content/migrate/User with uid field in source mapped to uid field in destination. Am I misunderstanding something from your above explanation?

The 'is_new' field mapping is also causing this warning

User addFieldMapping: is_new was previously mapped from , overridden

Thanks,
Paul.

mccrodp’s picture

Status: Closed (fixed) » Active
mikeryan’s picture

Please don't reopen long-closed issues.

I would guess that you added your 'is_new' mapping before the pre-existing do-not-migrate mapping for it, so the latter mapping overrode yours. Remove the other 'is_new' mapping and you should be set.

mccrodp’s picture

Excellent, thanks a lot, actually never knew about the reopening long-closed issues either, sorry and thanks for the info.

I removed 'is_new' from the following array $this->addUnmigratedDestinations(array('is_new', 'role_names')); to $this->addUnmigratedDestinations(array('role_names')); and it worked as you advised.