Hello,

I have the tipical circular dependencie error: "MigrateException: Failure to sort migration list - most likely due to circular dependencies involving FichaB2C,LocalLocal en migrate_migrations() (línea 82 de C:\devdesktop\esMadridPro\profiles\clusters\modules\contrib\migrate\migrate.module)"

I don´t know why, We have some migrations with hierachial dependencies but, not with circular dependencies, I think.

My example is like that.

class BasicProfilePartnerMigration extends ContentBaseMigration {
  
  public function __construct() {
    $this->dependencies = array('McbUser');
...
  }
}

McbUser hasn´t any dependencies

class FichaB2CMigration extends ContentBaseMigration {
  public function __construct() {    
    $this->dependencies = array('McbUser', 'LocalLocal');
  }
}

class LocalLocalMigration extends ContentBaseMigration {
  public function __construct() {
    $this->dependencies = array('McbUser','AlojamientoLocalMigration');
  }
}

class AlojamientoLocalMigration extends ContentBaseMigration {
  public function __construct() {    
    $this->dependencies = array('McbUser',);
  }
}

This is the dependencie code and I explode into migrate code and although, I understand the reason of the problem, I don´t understand how we can do it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Island Usurper’s picture

Status: Active » Needs review
FileSize
7.34 KB

I had a similar problem with my migrations, and I think I just had too many for the code to sort through at once. So I implemented a proper topological sort algorithm and it seemed to fix it. If this works for you, maybe we can get this change into 2.6.

Island Usurper’s picture

My only worry with this patch is that if your dependency graph is too large, you'll hit the PHP recursion limit, or slow things down too much because PHP is awful at recursion. But I think to do that, you'd need dozens and dozens of migrations in a very deep dependency graph.

Island Usurper’s picture

Version: 7.x-2.5 » 7.x-2.6-rc1
FileSize
5.96 KB

Would really like to get this in before 2.6 is released, so I've updated the patch.

Status: Needs review » Needs work

The last submitted patch, 3: 2358767-topological-sort-2.6.patch, failed testing.

Island Usurper’s picture

Whoops. Path is kind of important in patches.

Island Usurper’s picture

Status: Needs work » Needs review

mikeryan’s picture

Status: Needs review » Fixed

Looks good, tested by playing around with dependencies in migrate_example, got "Failure to sort migration list due to circular dependencies involving beer." Yep, I have trouble sorting when beer is involved too...

Committed, thanks!

mikeryan’s picture

Issue tags: -migrate +Migrate 2.6
daniroyo’s picture

I want to add some info to my initial problem, It was a stupid problem with my work.

If you see the previous code, you can see I used AlojamientoMigration at dependencies in the LocalLocalMigration Class.

It should be only Alojamiento instead if AlojamientoMigration.

Status: Fixed » Closed (fixed)

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