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.
Comments
Comment #2
heddnComment #3
heddnComment #4
heddnComment #8
edysmpFixed test.
Change table users_roles to role.
Comment #9
edysmpOther tests.
Comment #10
heddnComment #11
catchLooks like the tests don't fail yet.
Moving to 8.1.x
Comment #12
heddnWe 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.
Comment #13
heddnThis should cause lots of failures. Seems our array comparisons in MigrateTestCase are bit lax.
Comment #15
heddnComment #17
heddnComment #19
heddnPatch in #15 is ready for review.
Comment #20
benjifisherIt 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?
Comment #21
quietone CreditAttribution: quietone as a volunteer commentedHow 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?
Comment #22
mikeryan@heddn - just to be clear, when you say
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)?
Comment #23
heddnre #22, yes, it is a problem of referential integrity (or lack thereof) in at least some version of D6 & maybe D7 (???)
Comment #24
quietone CreditAttribution: quietone as a volunteer commentedAdding tags for Drupal source and destination version.
Comment #25
mikeryanThe 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?
Comment #26
heddnRe #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.
Comment #27
mikeryanAh, I see, the new call to assertArrayEquals()... Good enough for me!
Comment #28
catchThis 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!