Problem/Motivation

Here's an example scenario. An 'editor' role is created. A block is created with visibility rules assigned to that role. The role is then deleted. Now block migrations into D8 fail because when the migrate plugin is called internally inside BlockVisibility, it cannot find a value from the role migration and the migration dies a painful death.

Proposed resolution

In the gathering of roles inside Block->prepareRow() source plugin, do a join against the roles table and only select roles that are still in existence. And filter out those that do not exist. The join should work equally well for D7 & D6. But we found this issue on a D6 site.

Remaining tasks

Attached patch seems to fix the issue but we should add a test to validate.

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heddn created an issue. See original summary.

heddn’s picture

Issue summary: View changes
heddn’s picture

Version: 8.0.x-dev » 8.2.x-dev
Status: Active » Needs review
FileSize
1.42 KB
heddn’s picture

Issue summary: View changes
Issue tags: +Needs tests

Status: Needs review » Needs work

edysmp’s picture

Fixed test.
Change table users_roles to role.

edysmp’s picture

heddn’s picture

catch’s picture

Version: 8.2.x-dev » 8.1.x-dev
Priority: Normal » Major
Issue tags: +Migrate critical

Looks like the tests don't fail yet.

Moving to 8.1.x

heddn’s picture

We need to test BlockVisibility that it returns the right data. But the existing test of that class is doing that in a strange manner. If someone else know more about how to test these source plugins, please take a stab. Due to client hour constraints we might not be able to fix this right now.

heddn’s picture

This should cause lots of failures. Seems our array comparisons in MigrateTestCase are bit lax.

Status: Needs review » Needs work

heddn’s picture

Status: Needs review » Needs work
heddn’s picture

Status: Needs work » Needs review

Patch in #15 is ready for review.

benjifisher’s picture

It looks as though the patch from #15 was tested against 8.1.x, so I just queued a test for 8.2.x. I hope that was the right thing to do. If not, then which patch should be reviewed?

quietone’s picture

How do the changes to d7/FieldInstanceTest.php, d7/FieldTest.php, d6/FilterFormatTest.php, d7/FilterFormatTest.php, MigrateTestCase.php and d6/NodeTest.php relate to the issue? What am I missing?

Shouldn't this have tests added to MigrateBlock test, where a role being used by a block is deleted and then the migration is run and tested?

mikeryan’s picture

@heddn - just to be clear, when you say

An 'editor' role is created. A block is created with visibility rules assigned to that role. The role is then deleted.

these are steps taken on the source site before migration? So this is triggered by a D6 (at least) data integrity bug (leaving dangling references to a non-existent role)?

heddn’s picture

re #22, yes, it is a problem of referential integrity (or lack thereof) in at least some version of D6 & maybe D7 (???)

quietone’s picture

Issue tags: +migrate-d6-d8, +migrate-d7-d8

Adding tags for Drupal source and destination version.

mikeryan’s picture

The fix itself looks good, as well as the block test changes, I'd just like to echo quietone's question on the changes to Field and FilterFormat tests - are those in scope here?

heddn’s picture

Re #21 / #25

It is a symptom of retrievalAssertHelper being a lot more strict. Those values are in the db dump. So we need to make sure they are also in the "expectation" of the various tests.

mikeryan’s picture

Status: Needs review » Reviewed & tested by the community

Ah, I see, the new call to assertArrayEquals()... Good enough for me!

catch’s picture

Status: Reviewed & tested by the community » Fixed

This is the kind of issue that makes me really glad we added configuration dependencies to 8.x, even if we're still dealing with the fallout of never having them before.

ommitted/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!

  • catch committed b313cdc on 8.2.x
    Issue #2705977 by heddn, edysmp: D6/7->D8 migration: User role based...

Status: Fixed » Closed (fixed)

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