Issue for developing Poll migration.
It is currently for Drupal 7 and not universal because it relies on migration_lookup to look up values from d7_node_complete:poll and d7_user.
The migration involves multiple steps:
Migrations
1. Importing the configuration. Done in 4 steps :
- poll_field_storage_config to create the Field storage.
- poll_field_instance to attach the entity to the poll node.
- poll_field_instance_display for the default view mode display
- poll_field_instance_form_display for the form display.
2. Import poll choices. Done in the Poll_choice migration
3. Create a poll entity for each poll. Created in poll_question migration
4. Create a reference on the poll node to the poll question. Done in poll_reference migration
5. import the votes. Done in the poll_vote migration
Tests
For the tests, migrate fixtures are included. The test uses MigrateDrupal7TestBase which already imports the standard drupal7 fixtures from core. Only the additional fixtures for poll are needed to be added on top of that.
I followed the guide at https://www.drupal.org/docs/8/api/migrate-api/generating-database-fixtur... to create the fixtures:
1. I used existing fixtures to set up a drupal 7 website.
2. After importing the Drupal 7 fixtures I logged in and created the polls via the UI, with relevant options and then I voted on them via the UI.
2. I used the script to create a dump of the foixtures. Following this I deleted all previous data that is in the core drupal 7 fixtures, only leaving the additions.
3. This would work until there was a change to core fixtures which required bumping the nid and vid to greater than what was added to core, but causedAs this caused nid and vid collisions whenever new data was added to the coredrupal 7 fixtures
4. I manually modified the poll fixtures for the nid and vid to start at arbitrarily high numbers (101 on each).
5. I manually added a fixture to update system table and mark poll module as enabled.
| Comment | File | Size | Author |
|---|---|---|---|
| #135 | interdiff.txt | 4.52 KB | quietone |
Issue fork poll-2638406
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2638406-poll-migrate
changes, plain diff MR !15
- 2638406-poll-migrate-support
changes, plain diff MR !1
Comments
Comment #2
berdirNot sure what you mean with add to any content type? It's a separate entity type, has nothing to do with content types (except you could reference them with a entity reference field).
No plans yet, but any work on this is welcome.
Comment #3
naheemsays commentedAre there any guides/tutorials on writing destination plugins? All the guides/tutorials that I have come across seem to be limited to the node/taxonomy/file cases where plugins already exist.
Comment #4
berdirHave a look at \Drupal\migrate\Plugin\migrate\destination\DestinationBase and any of its subclasses, for example a simple case like \Drupal\ban\Plugin\migrate\destination\BlockedIP.
Basically the import() method is called with the row as provided by the source and then mapped by the configuration/definition in the yml file, and then you take that and save it.
Comment #5
naheemsays commentedI have attached a not working partial not working migration for the poll question and choices.
I cant get the migrations to show up in Migrate drupal UI and my local drush is playing up, so I dont know how many errors there are. (Reading the docs has been a frustrating experience)
My thinking has broken this down to 4 steps in migratio
1. Migrate poll without options
2. Migrate poll options
3. Migrate stored field data
4. Migrate an entity reference of the poll to the poll node
I have attempted the first 2.
Comment #6
naheemsays commentedslightly updated patch from before if anyone wants to look at it - I havent done much since then, but probably a better starting point to improve on.
Comment #7
naheemsays commentedUpdated patch:
1. Migration of Poll Question works.
2. Migration of poll choices does not run and drush gives the following error: "Migration pollchoice did not meet the requirements. [error]"
I cannot seem to get anything more verbose (--debug has been useless) to show why or what requirements are not met.
I have not included my hacky attempts to migrate the vote data - I havent got my head around the data model (votes are not a field?) and I cannot test what I have until migration of poll choices is successfull.
Previous patches had preparerow functions in the source plugin such as the following, but this did not seem to work so using addfield in the query of both plugins instead:
Any pointers at fixing the migration for poll choices will be much appreciated.
Comment #8
naheemsays commentedUpdated patch:
0. No poll entity reference field is created on the original node poll
1. Poll Questions migrated but no reference is created to the poll node.
2. Poll choices are migrated but no reference is created to the poll
3. poll votes migration currently fails.
I need to figure out how to update existing node types during migration to add more fields and how to create references to the newly created entities on existing entities. Any pointers will be welcome.
Comment #9
naheemsays commentedSlight progress:
0. No poll entity reference field is created on the original node poll
1. Poll Questions migrated but no reference is created to the poll node.
2. Poll choices are migrated
2.1. Reference is created to the poll, but current code overwrites itself so only last poll choice reference remains afterwards.
3. poll votes migration currently fails.
I have simplified some of the plugins from prevoius patches too.
Comment #10
naheemsays commentedUpdated code.
Currently:
1. To test, I need to manually create a poll_field entity reference on the poll node. Need to create a migration to add a poll entity reference to the poll node type.
2. The migration to add the reference currently resaves the whole node with a new id. I need to fix that.
3. Creating references to choices on the poll deletes the previously saved choice leaving only one choice per poll. Need to fix.
Comment #11
naheemsays commentedSet to needs review because I need pointers on the two problems:
1. How to create additional field on an existing node type
2. How to make the migration pollchoice_reference not overwrite the previously saved entry.
Comment #12
naheemsays commentedNew Patch.
Before carrying out poll migration, need to manually create field_poll entity reference field on the poll node type. I have asked a question on the forums for ideas on how to do this here: https://www.drupal.org/forum/support/module-development-and-code-questio...
Other than the configuration issue, polls are created correctly with correct options and votes and references to the polls are correctly added to the poll nodes.
Comment #13
naheemsays commentedSlightly updated patch.
Other than the manual step, the rest should work well for Drupal 7 anyway as one of the migrations references another Drupal 7 specific reference.
Comment #14
naheemsays commentedOther than manual step, current patch seems to be fully working.
I have not figured out yet how to create a migration which would add an entity reference to the poll node type but it seems that almost everyone else does that step manually.
Comment #15
naheemsays commentedOK, I have found some documentation in \Drupal\migrate\Plugin\migrate\destination\EntityFieldStorageConfig and \Drupal\migrate\Plugin\migrate\destination\EntityFieldInstance
With Latest patch - field storage is created, but the field instance is not with the following error in the logs:
Source ID : Attempt to create a field without a field_name. ( ... \core\modules\field\src\Entity\FieldConfig.php:112)
Once that above error has been fixed, the patch should be fully complete
Comment #16
naheemsays commentedThe error turned to be an indentation problem which meant the process section of the migration was not being processed.
Full migration from Drupal 7. Marking as RTBC.
There were no database changes between Drupal 6 and Drupal 7 that would impact migration, but as I have not tested from Drupal 6, the tags limit it to Drupal 7 only. Extending it further and potentially adding tests to make sure migration does not break in the future following potential database changes can be done in followups if needed.
Comment #17
naheemsays commentedMoving to RTBC.
Comment #18
heddnMostly just nits. The main thing though to consider is the naming (which is always hard). The real work of this patch is looking nice. Great work.
Nit: we tend to use words separated by an underscore in the naming. And we don't include the word entity, as everything in Drupal is an entity and has no meaning. So split the words with an underscore and drop the entity part.
'embedded_data' is a better source. Empty was used in the past in core, but core doesn't even use it these days. It ends up being the same result, but is more semantic and less risk of having the source plugin deprecated.
Lots of whitespace issues. Tabs and extra whitespace. And no new lines.
Don't include this. It isn't needed as there is no override of the parent.
This isn't needed. Use a 'default_value' plugin in the process or just sent these values with constants in the yaml. It is far easier for someone to alter a yaml then extend and modify a php class file if they want to use some different value.
Comment #19
heddnAlso, another though. Ideally, the fields and field data could be discovered by a field plugin. Is that not possible here? I feel like it could. Then the code here would /drastically/ simplify. And we'd just need a field plugin for the poll entity reference. See https://api.drupal.org/api/drupal/core%21modules%21migrate_drupal%21src%... as an example of what I mean.
Really, the destination in D8 is still a table and not an entity?
I don't see any requirements in composer.json or .info.yml for this module? That means this migration will /fail/ for those who don't have that module installed.
Also, please ping me in slack #migration for assistance if any of these comments seem too dense and need further clarification.
Comment #20
naheemsays commentedThanks for the review!
#18-1 - this should be fixed.
#18-2 - this should be fixed.
#18-3 - this should be fixed. Do you have a special tool that can find these coding fixes?
#18-4 - I assume you did not mean the code comment only, but the whole section. I deleted:
#18-5 - fixed
#19-0 - I looked at this approach a long time ago, I struggled to understand how to use it at the time. I might have another look.
#19-1 - AFAIK votes are fields in the Drupal 8 version of the poll module, but using the tableplugin seemed the simplest path
#19-2 - adding the dependency in the composer or the info.yml file would make migrate_plus a necessity for everyday operation, when it is only used for the migration.
Comment #21
heddnThis is shaping up nicely.
Plural or singular?
Nit: why is storage caps?
One is singular, the other is plural?
I now I'm repeating myself, but this isn't necessary. There is already a node migration for all of this. I think a field plugin is going to be a much better solution. This is going to only work in very specific situations where someone didn't manually create their own differently named reference fields for polls. Use a field migration and this will just get picked up using the normal migrate_drupal processes. For any and all poll reference fields.
Singular or plural?
I think you will be much happier to use an entity destination. Otherwise folks won't have that module installed and this migration will fail and cause odd errors for folks. We can't require the use of that module, so just use an entity destination.
Comment #22
heddnOK, let's drop my mentions of field migrations. I'm embarrassed to say I hadn't done enough homework on poll.module. There aren't any fields to migrate. The implementation of poll in D7 core was pretty simplistic and used hook_field_extra_fields and assumed that all polls where attached to a node type of 'poll'. So, ignore #21.4
One thing you will need to do. You'll need to extend the embedded source plugins for
poll_field_instance.ymlandpoll_field_storage_config.yml. And add a source_module='poll' in those source plugins. Otherwise this will cause issues for folks who enable this module in D8 and don't have a D7 site with poll enabled. We only want those migrations discovered if the source site also had the poll module installed.Comment #23
naheemsays commented#21.1 - fixed. I have decided to go for the singular.
#21.2 - fixed.
#21.3 - fixed.
#21.4 - ignored as per your following comment.
#21.5 - fixed along with the src plugin.
#21.6 - I dont understand what you mean here. In Drupal 7 the votes were simply stored in a table. In Drupal 8 they are a field to an entity (poll_choice). Can this be done or did you mean ignore this aswell in the following comment?
#22 - added the source_module: poll to the two migrations
Comment #24
naheemsays commentedA small error that was not fixed in previous patch
Comment #25
heddnJust list the entity name and drupal's migrate api will store the values. I don't recommend using table in D8 for an entity destination.
Plus those last patches looks a little small?
Comment #26
naheemsays commentedThis should be the full patch and interdiff from comment 20.
Still to address #25
Comment #27
naheemsays commentedFrom the code I cannot see the vote is being attached to any entity. I had expected it to be a field on the poll_choice entity. Any pointers of where to look will be helpful.
Comment #28
heddnIt might be a little tricky from looking at https://cgit.drupalcode.org/poll/tree/src/PollVoteStorage.php and https://cgit.drupalcode.org/poll/tree/src/Entity/Poll.php#n412. You might even need to create a custom destination. But you should be able to pass choices to poll and save them.
Comment #29
naheemsays commentedChoices (well, their references) are already passed to poll (the question). What is remaining is the votes which are currently copied over via the table plugin.
For the votes I see 2 options if we do not go by what we have right now:
1. A custom destination. But this will probably be a simplified version of the table plugin.
2. Change the poll vote to an entity and use the standard entity plugin destination method.
If 2. is chosen, should it use the same table as now or should it have a new name?
Comment #30
naheemsays commentedBefore re-rolling this my understanding is that we need to get #3042995: Convert votes into entities in.
Any comments on the patch over there is welcome.
Comment #31
naheemsays commentedUpdated patch on top of #3042995: Convert votes into entities
Comment #32
naheemsays commentedCode sniffer fixes only.
Patch works well.
The only issue is that the entity reference instances added to the node poll is disabled in the node form and not in the correct position for display. There is no content loss, but a user will need to manually update these settings.
Comment #33
heddnTo get the weighting and activation of those fields to function, see PerComponentEntityFormDisplay and PerComponentEntityDisplay. Both of these have really great examples in their doxygen.
Comment #34
dippers commentedI had two issues in the migrate source Poll.php.
1. My migration was only finding 2 out of 101 polls from my D7 site. The problem seems to be due to the join statement at line 50 for joining poll to node where it uses n.vid = p.nid. I think this should be n.nid = p.nid as we want to match node ids NOT revision id to node id.
2. When running upgrade_d7_poll_question I was seeing SQL errors due to non-existent column 'pid'. It seems standard SQL does not support column aliases in ON clauses. Instead in getIds() I used
Which avoids using the 'pid' alias in the ON clause.
Comment #35
dippers commentedI also found that the poll_reference migration config was not working. I modified it to:
The poll_question migration lookup required two keys, nid and vid. You cannot use the d7_node:poll table to lookup the destination vid as it is not stored. There is no need to change the 'changed' or 'title' fields as this migration should just be updating the poll reference field.
Comment #36
naheemsays commented@Dippers - do you know where the issue was - was it with the creation of the polls (ie in teh database were all the polls being imported) or with the attachment to the node?
We do need to take the vid into account otherwise AFAIK, in nodes with multiple revisions, only one revision will have a poll attached. Maybe the same logic doesnt apply for the poll_question and the poll_reference migrations though.
Comment #37
dippers commentedIf you do want to reference all revisions then you need to lookup the revision id in the d7_node_revision:poll migration:
This makes the d7_node_revision:poll migration a dependency. We generally do not migrate node revisions and having a revision dependency might be a drawback in the case when you just want to migrate the current nodes/polls. It would probably be more useful to have a poll_reference migration and a poll_reference_revision migration to deal with the revisions separately.
There is the wider question of dealing with revisions of polls in D8. As it stands it appears that multiple revisions of D7 poll nodes will create multiple poll entities in D8 - is this the desired effect?
Comment #38
naheemsays commentedComment #39
naheemsays commentedUpdated patch.
For some reason I am getting a bogus extra poll node being created with a title which is a random string of letters. I cant track down why. but on my new test setup I did have one poll node which had a revision to it to test how the migration handled them.
Other than that it works.
Any help in tracking down the bug(s) much appreciated.
Before this can be finished, we need a resolution on #3042995: Convert votes into entities or agreement/guidance for an alternative form of destination plugin for poll votes that will be acceptable.
(My comment in post 36 was wrong - we were not adding the poll to all the revisions anyway)
Comment #40
naheemsays commentedAdding for retest - nothing to do with this patch, just checking if the module works with php 7.3.
Comment #41
naheemsays commentedWhile reading Migrate related issues, I came across reference to the PathAlias migrate destination.
Using a similar approach, I have gotten the poll_vote migration to (mostly) work.
The only two issues I can see that are remaining are:
1. A bogus extra node is created during the migration. It seems to coincide with having 1 extra revision on my test database. I cannot seem to figure out why this is happening.
2. The poll_vote migrate mapping is not saved. The log shows the following message: "Could not save to map table due to missing destination id values"
Comment #42
naheemsays commentedGit-foo fail. Correct patch.
Comment #43
naheemsays commentedThe fix for the poll_reference creating nodes was in comment 35 - thanks @Dippers.
The only remaining fix is figuring out why the migrate map for poll_vote is not being saved.
Comment #44
naheemsays commentedCode style fixes (interdiff includes diff in comment 43)
Comment #45
naheemsays commentedBeyond the remaining bug with poll votes note being added to the migrate map table, I think this module should have migrate tests.
I have created fixtures following the guide at https://www.drupal.org/docs/8/api/migrate-api/generating-database-fixtur... however the tests page at https://www.drupal.org/docs/8/api/migrate-api/migration-tests-in-drupal-8 is not too useful.
Any pointers/guides?
Comment #46
naheemsays commentedRelevant fixtures for anyone interested in working on tests.
Comment #47
naheemsays commentedMigrate Map should now also be working.
Comment #48
heddnSeems like one missing piece at this point is tests.
Comment #49
naheemsays commentedIs there a good link/guide that I can follow for relevant tests?
Comment #50
heddnhttps://www.drupal.org/docs/8/api/migrate-api/generating-database-fixtur...
Comment #51
naheemsays commentedUpdated patch.
I do not expect it to work - I cannot seem to get my head around testing...
I tried a migration with the patch on comment 47 on my test site hundreds of polls and thousands of choices/votes.
At some point during the migration the choices seem to be imported/attached twice to the poll (I havent checked which it is yet.) and at that same point it seems the votes are no longer attached to the choice.
For a small number of polls and votes the code seems to work well.
Comment #52
naheemsays commentedNow with the correct patches.
Comment #53
naheemsays commentedSmall cleanups - mostly coding style and notes for what needs testing.
Still not functional.
Comment #54
naheemsays commentedTesting patch
Comment #55
naheemsays commentedMore tests. Fixtures probably still dont load.
Comment #56
naheemsays commentedmore updates. Hopefully the fixture will be found now.
(I cannot seem to figure out the local testing environment - the failures are cryptic with no details.)
Comment #57
naheemsays commentedUpdating fixtures to account for new additions in drupal 8.9.
Is there any way to automate these values? I can see having to update the fixtures to keep up new with core tests being troublesome.
Comment #58
naheemsays commentedMost tests are in place now. Just need to make it work.
Comment #59
naheemsays commentedmore improvements and fixes.
Comment #60
naheemsays commentedFix errors from last test
Comment #61
naheemsays commentedGoing further down the rabbit hole. Shouldnt these be done by MigrateDrupal7TestBase?
Comment #62
naheemsays commentedlets try this
Comment #63
naheemsays commentedComment #64
naheemsays commentedOne more time - enable the text module.
Comment #65
naheemsays commentedAdding comment module to be enabled. Might also need to load the schema specifically.
Comment #66
naheemsays commentedAdd image module to test setup.
Comment #67
naheemsays commentedAdd telephone module.
Comment #68
naheemsays commentedComment #69
heddnHere's an attempt to fix up some of the tests. They now run, although fail and the errors seem to be legit. All the time I had for today though.
Also, sorry for the interdiff noise. The test name changed from a folder of Migrate to migrate.
Comment #70
heddnComment #71
naheemsays commentedThanks! I was starting to pull my hair out over getting the tests to run.
That above test doest seem to have run all the tests - the number of passes match before this patch.
Having a look at the interdiff, the nodes being tested have been changed to 1, 2 and 3. The fixtures have the nodes with nids 11, 12 and 13. I am reverting that change.
Comment #72
naheemsays commentedAnother question - core has the tess/src/Kernel/Migrate folder with a capital M. Are contrib meant to be different in this case?
Comment #73
naheemsays commentedTesting to see if tests are run if the tests folder name is reverted to Migrate with a capital M.
EDIT - I accidentally changed the namespace to migrate without a capital m in this patch...
Comment #74
naheemsays commentedLets test having them both with lower case m.
Comment #76
naheemsays commentedFinally the tests/failures are showing!
interdiff from comment 71 - 74 attached.
Comment #77
naheemsays commentedHopefully this works better.
Comment #79
naheemsays commentedTry to fixed poll votes test - check specifically if vote count is 8 + make sure that pid check uses integers
Comment #81
naheemsays commentedThe previous patch erroneously tests for 8 votes - the database only has 6.
Nodes do not seem to be loading correctly, so trying a different way.
Also testPollNodeType() didnt seem to run, so renamed to testNodeType()
Comment #82
naheemsays commentedFix typo in last patch
Comment #83
naheemsays commentedSlight update - keeping test name to testNodeType() but I think it was actually passing before - reverting the debuginfo in the assert message as that caused the test to fail.
Still need to fix connection query/use to get the nids from the destination database
Comment #84
naheemsays commentedI still can't get the testing to work on my PC (using Acquia Dev Desktop), so testing here.
Comment #85
naheemsays commentedfixing use of fetchCol()
Comment #86
naheemsays commentedComment #87
naheemsays commentedlets try this
Comment #89
naheemsays commentedUpdating fixtures. Is there a way of making them less brittle? Right now we will have to update them for every update to node fixtures in core.
Can we start our test data at an arbitrarily high start value for nid and vid?
Comment #91
naheemsays commentedCall migrateContent(); before main migration. Lets see if this works.
Comment #93
naheemsays commentedIn this patch I have tried to move to the d7_node_complete migration. It still doesnt work - failure is before the tests even start. The setup rabbit hole needs to be fixed.
I have also merged all 3 tests into 1 - since setup doesnt need to happen 3 times, the test runs are faster for me.
Comment #95
quietone commentedJust a very brief look at the Kernel test.
The migrations here need to be in dependency order. This is a known bug and there is an issue for it.
Comment #96
quietone commentedAgain, just looking at the Kernel test setup.
The parent setUp() method will install the migrate_drupal test fixture. I don't know what will happen when you try to load another fixture, I never tried it. If you want to alter that fixture then your test can implement MigrateDumpAlterInterface, see \Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldInstanceLabelDescriptionTest for an example.
However, if you are altering the core dump you run the risk of having to update your test anytime the core fixture changes, specifically adds nodes. Given the remaining issues, that is unlikely but possible. You could copy the core fixture to your project to avoid that or make your nid/vid values higher.
Comment #97
naheemsays commentedSome progress: Fixtures were not the problem, but the comemnt on slack about the grouping of the migration was helpful - Thanks!
The poll_vote migration gives an error in the tests - the following code gives an empty pid:
Deleting this migration from the test then allows the setup to complete. For me next failures were when loading Poll node type and again when comparing counts of polls in source and destination databases.
Comment #98
naheemsays commentedThe fixtures needed fixing - not all had been updated when changing the Node ID's the last time.
Now the setup should all work. Next step: fix the actual tests!
Comment #100
quietone commentedSorry to be piecemeal with my comments, just being pulled in many directions today.
After migration_lookups it is common to test the transformed value and skip if it is empty. That way you are not trying to save a NULL value. This sample is from d6_vocabulary_entity_display.yml and skips the row but you skip just the process, if that is needed.
Comment #101
quietone commentedThis issue is part of a meta for better contrib support, adding related issue.
Comment #102
quietone commentedOh, and add a migrate state file. Modules can now declare their Drupal 8 upgrade status so that 'poll' will be listed as 'will be upgraded' when someone upgrades via /upgrade.
Comment #103
naheemsays commentedI have added the poll/migrate_drupal.yml file. A question however - I have marked it as finished. Drupal 7 and earlier poll module had a feature to set an offset for votes. This feature does not exist in Drupal 8 but actual votes are all migrated. Should the migrations still be marked as complete?
The Note Type test assert checking that a field_poll is attached passes and the node is also loaded correctly. Currently I am having issues around line 163 of the MigratePollTest.php file:
I think I am using referencedEntities incorrectly as its not returning a result.
Comment #105
quietone commented@NaheemSays, Hi, how is this progressing? Here are responses to #103 and then I took a look at the source plugins and made some suggestions.
#103.1 I am not familiar with poll but if all the possible source data is migrated then the migration has done it's job of getting the data into Drupal 8 or 9. It sounds like the data is migrated so finished would be correct. You may want to add a comment to the Poll project page to clarify what the migration actually does.
#103.2 I don't know the structure. $destination_poll_node->field_poll->target_id?
Source plugins just get the data, they perform the Extract action of an ETL process. So, the summary can be 'Gets the poll data from the source database'.
Why not extend from DrupalSqlBase? For one, it will has a requirement that the source module is enabled in the source database and if not throw a RequirementsException.
It is better to add all the fields to the query, not just the ones you are using in your process pipeline. This allows other contrib of custom modules, who may need the other data, to use this source plugin without modification. They can just add make their own migration yml file.
setSourceProperty sets a value on \Drupal\migrate\Row not a yml file. Adding a comment here explaining the structure of $choices may help the next dev to look at this code. It would save them a bit of time reading the query.
Similar here, 'Gets the poll choices data from the source database.'
And here too, 'Gets the poll votes data from the source database.'
Speaking for myself, when I have assertions inside a foreach look I add the the changing value to the message so I know exactly which set of data failed.
Comment #106
naheemsays commentedMany thanks for your replies - they are very helpful.
I am moving forward slowly but surely. I have avoided writing tests before, so its a slow process (and most of my prior experience with drupal/php was years ago when we were in a procedural world.)
103.1 - I will sugggest that for a project page update when this patch is ready.
103.2 - I havent gotten this to work so unchanged in this patch. The migration adds a field_poll instance to the poll node type and at this stage I want to 1, test that there is a poll attached to the node, and check that only 1 poll is attached. I can get around it here by loading a poll directly.
I need to get the referencedEntities() code to work, though, because while I can avoid using it here, the next use of it is around 10 lines later where I cannot see a different approach - choices are referenced entities on polls and there is no guarantee that there are a specific number of them (2 test migration has 2 polls with 3 options, 1 poll with 2).
1. changed
2. I need to look into this further. I cant remember why I chose one over the other or even if I was aware of the other at the time.
3. changed
4. I tried improving the comment, but I feel it is still terrible. Should I be pointing out what is being done in the subprococess plugin, or the purpose of the prepareRow() function?
5. changed.
6. changed.
7. changed.
Comment #108
naheemsays commentedUpdated patch. The referencedEntities() code wasnt working because the migrations were all being skipped. Simplified migration code and it now runs.
Now only errors are lines 197/198: later poll vote testing already passes.
These migrations could work for Drupal 6 and 7, however are drupal 7 only because they depend on eg d7_node_complete:poll being completed first. Is there a way to define an or relationship in the yaml that would prevent the need to duplicate the full migration yaml file?
Comment #110
naheemsays commentedAll tests pass locally with this patch (Drupal 9.0.1, phpunit 8.5)
Comment #112
naheemsays commentedI cannot reproduce the error on line 166 locally.
As for the other test, I have opened #3154918: Failing tests as from what I can see they are unrelated.
Question on fixtures - currently the numbering for the nodes and revisions immediately follows what is last item in core fixtures. however as new fixtures are added to core, these will need to be amended to keep up. Should I start at an arbitrarily high number such as 101 instead?
Comment #113
naheemsays commentedIncluded the fix to the failing FieldUI test and also removed hard coded migrate mapping to one that is loaded from the migrate tables - it will make the tests less brittle.
I still need to investigate why there was a failure on line 166 on CI - I cannot reproduce it on my local Drupal 9 setup so it may be Drupal 8 related or due to a lower versioned phpunit.
Comment #115
naheemsays commentedUpdated comment and removed fix to failing FieldUI test that has been committed separately. (interdiff is just the comment change - I am unsure how to include the other change after rebasing.)
Will still (probably) fail on CI as i havent made any changes to address that.
Comment #117
naheemsays commentedAttempt at fixinf failing test.
Comment #118
naheemsays commentedw00t!
Only question (other than things found in future reviews) is the question on fixtures. Is it reasonable to start the nids and vids on arbitrarily high numbers instead of following on from what is in core fixtures?
Comment #119
heddnUsing high nids is a good way to insulate things if you alter the core fixture. See #96 for possible other options.
Nit: new line at end of file is needed.
Nit: "choice id" should be "choice ID".
Are we sure that the IDs can't change? Why can't we use
migration_lookup. Requiring fixed IDs is not a good idea for the reason that incremental migrations won't work. Core supports fixed and non fixed IDs for this reason.Is this strictly necessary? I can't see why it would be. And really, there's a few questionable modules, like telephone, datetime, etc. Maybe a review and removal of some of the non-needed modules could be done. It would speed up the test.
Comment #120
deepak goyal commentedHi @heddn
Fixed #119.1 and #119.2
please review.
Comment #121
deepak goyal commentedComment #122
deepak goyal commentedHi @heddn
Fixed #119.4 please review.
#119.3 is still pending.
Comment #124
naheemsays commentedThanks for updating the patch Deepak - I have added the datetime and telephone modules back into the setup as their omission was causing a failure.
I tried looking into comment 96 above but I couldnt figure out how to do that or get around the need to calculate new values for the nid and vid after import of the main fixtures so I have kept the current method.
I have updated the patch to change the fixtures to start at 101 for nid and at 111 for revision ID's. The chid is also looked up with migrate_lookup now.
There is something wrong with the interdiff, it is showing that the new lines added by Deepak are deleted, but that is (AFAIK) not the case with the main patch.
Comment #125
naheemsays commentedHas any one else tested this yet?
It would be good to have another tester before setting to rtbc, but if not I will do that in a few days.
Comment #126
naheemsays commentedSetting to RTBC.
If this is committed the commit message and module front page should note that migrate suport is limited to Drupal 8.9+ only.
Comment #127
naheemsays commentedComment #128
quietone commentedWow, this looks very nice!
I did not read the entire issue, I focused on a very 'light' first pass at a review of the patch.
1. There are no coding standard errors. Yay!
2. There are no source plugin tests. :-(
3. The Migration tests does provide a database fixture with the needed data. That is excellent. It is not a 'complete' fixture in the sense that one can't install it in a D7 site and use it. Therefor, can someone add in the IS how that was created. And comment on why you believe it is accurate.
4. I notice that the use statements in a least one file is not alphabetized. Usually they are which makes is easier to read the file. This is not a Drupal standard but it an accepted practice.
And then some other items.
I think there are all content so should have the tag 'Content'
should use DrupalSqlBase so checkRequirements run
Same again
this can be shorted to
$this->installConfig(static::$modules);
Comment #129
quietone commentedAnd let's make this a task because it is something that needs to be done to support the users of Poll.
Comment #130
naheemsays commentedUpdated issue summary with how the test fixtures were generated/modified.
Comment #132
naheemsays commentedI couldnt figure out how to get git to push my local changes so I have manually added them manually via gui with some trial and error. what is uploaded now should be idential to patch in comment 124
Comment #133
naheemsays commentedChanges following comment #128:
1. Reordered the use statements
2. Added the Content migration tag
3. Use DrupalSqlBase
4. shortened install config to $this->installConfig(static::$modules);
Comment #134
naheemsays commentedfrom comment #128 items 1 and 4 have been done.
I have tried to do 2. and 3. but using DrupalSqlBase has always failed for me. I dont know how to do that change or if it is required.
tests should be passing again - apologies for such a ling time to fix the tests, my test system was broken and I finally got around to updating the patch.
There is also an extra line in src/Plugin/migrate/destination/PollVote.php, but I cant see it in my vscode, so I cant push a fix from there. I am guessing there is a problem with my config here.
Please feel free to commit to the branch and get this over the line, especially as Drupal 7 is coming to EoL so this issue has greater importance.
Comment #135
quietone commentedI have added the start of a source plugin test for the Poll source plugin. Like any test they are worth doing, even for the source plugins. Here that are not overly complicated. Hopefully, someone will use that to update the other source plugins to use DrupalSqlBase and to write the tests.
And fixed some coding standards issues.
Some questions:
Feel free to ping me in #migration when a review is needed.
Well, once again I cannot push. Therefor I have added an interdiff with my changes. Can someone add them to the MR?
Edit: fix grammar
Comment #136
naheemsays commentedThank you for looking at this!
I have enabled the setting to allow commits from members in the merge request. I hope this is enough.
I have pushed a commit with the interdiff minus the mode to drupalSqlBase as that was causing the following error:
In relation to the two questions, I will have to go back and check but from my recollection:
1. the reason was that the poll does not have revisions and from the manual testing I did, adding the field to the node displayed it on all revisions.
2. The source plugin works for both Drupal 6 and 7. if I depended on the node source plugins I would need to have 2 versions. (probably less of an issue now since Drupal 6 migrations are not in core.)
Comment #137
naheemsays commentedI have updated the merge request and I would be grateful for another review/pointers:
1. I switched to DrupalSqlBase from sqlBase. I also needed to change source_module to node instead of poll as otherwise the test complained that the source module was not installed. If this is the incorrect fix, I would be grateful for a pointer where I need to change it.
Fixed main branch failires. if any remain past this point, they are from this branch (tests currently running)2. There are test failures but these seem to exist on Drupal 9.3 onwards on the main module too - testing on Drupal 9.2 shows no errors. Again, any pointers where I need to fix what I assume are deprecations would be much appreciated.
Comment #138
naheemsays commentedComment #139
naheemsays commentedok, tests fixed. Just the one question from comment 137 over whether I did the right thing.
Comment #140
naheemsays commentedI managed to figure out why using DrupalSqlBase had resulted in errors previously: the fixtures had not included changes to the system table to mark the poll module as enabled.
I have manually added that to the fixtures now and the tests work properly without the previous workaround of having to set the source module to node.
If tests pass, this is ready. All previous feedback now dealt with
EDIT - Failing test does not seem to be due to this patch but due to change to testing on Drupal 9.4 and failing FieldUITest. Second test run will confirm.
Comment #141
naheemsays commentedComment #142
naheemsays commentedrebased to fix unrelated failing test.
Comment #143
phjouThe poll status to know if a poll is active or not is not migrated. It is always active when using the migration for me.
The migration is putting the published status in the status property of the entity, but the status is actually used for "active", so the active value should go in the property status.
Comment #144
naheemsays commentedgood catch @phjou - should be fixed now.
Comment #145
phjouI confirm that the issue I've reported is fixed :)
Comment #146
naheemsays commentedCan you confirm how big of a dataset you tested this one? Also, I would be grateful if you could change the status to rtbc - it technically isnt but I suspect it wont get the necessary eyeballs until that is done. Last time I did it myself, but it feels a little... egotistical.
Comment #147
naheemsays commentedI think the patch is ready. I have incorporated the feedback and fixed issues.
Comment #148
berdirThe test is failing on D10.
Comment #149
naheemsays commentedIt should be passing again i Just had to remove the mention of a module that was no longer a separate module in drupal 10.
The commits on the merge request are a bit of a mess but my attempt to rebase them was... less than adequate so when merging please make sure to squash into one. Thanks!
Comment #152
naheemsays commentedI have moved the code into a new merge request to avoid the previous messy commit history.
It is the same code as before plus a fix to a coding standards error (which is separate commit).
I would be grateful to get this done as I want to work on another feature for poll (multiple poll types), but I dont want to touch that until this is in place to ensure that nothing is broken by that work
Comment #154
berdirI didn't test this myself nor review in depth, but I see it has been tested a bit and it shouldn't interfere with regular functionality of the module, so merged.
And don't worry about clean commits, merge requests are always squashed when using the d.o tools