Problem/Motivation
I have been developing a site that uses migrate fairly heavily to migrate data from a D6 site to a D8 site. Migration has run just fine on the site until doing an upgrade to 8.5.4 - the migration runs in 8.5.3, but after upgrading to either 8.5.4 or 8.5.5 migration consistently is broken. The symptom, for example when running drush ms is
Error: Call to a member function getSetting() on null in [error]
Drupal\migrate_drupal\Plugin\migrate\EntityReferenceTranslationDeriver->getDerivativeDefinitions()
(line 101 of
/home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php)
#0
/home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101):
Drupal\migrate_drupal\Plugin\migrate\EntityReferenceTranslationDeriver->getDerivativeDefinitions(Array)
#1
/home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87):
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array)
#2
/home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/modules/migrate/src/Plugin/MigrationPluginManager.php(256):
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#3
/home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(175):
Drupal\migrate\Plugin\MigrationPluginManager->findDefinitions()
#4
/home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/modules/migrate/src/Plugin/MigrationPluginManager.php(109):
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
#5
/home/elections/domains/develections.cruiskeenconsulting.com/public_html/modules/contrib/migrate_tools/migrate_tools.drush.inc(499):
Drupal\migrate\Plugin\MigrationPluginManager->createInstances(Array)
#6
/home/elections/domains/develections.cruiskeenconsulting.com/public_html/modules/contrib/migrate_tools/migrate_tools.drush.inc(149):
drush_migrate_tools_migration_list('')
#7 phar:///usr/bin/drush/includes/command.inc(422):
drush_migrate_tools_migrate_status()
#8 phar:///usr/bin/drush/includes/command.inc(231):
_drush_invoke_hooks(Array, Array)
#9 phar:///usr/bin/drush/includes/command.inc(199): drush_command()
#10 phar:///usr/bin/drush/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#11 phar:///usr/bin/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 phar:///usr/bin/drush/includes/startup.inc(462): drush_main()
#13 phar:///usr/bin/drush/includes/startup.inc(369):
drush_run_main(false, '/', 'Phar detected. ...')
#14 phar:///usr/bin/drush/drush(114): drush_startup(Array)
#15 /usr/bin/drush(10): require('phar:///usr/bin...')
#16 {main}.
Error: Call to a member function getSetting() on null in /home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php on line 101 #0 /home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\migrate_drupal\Plugin\migrate\EntityReferenceTranslationDeriver->getDerivativeDefinitions(Array)
#1 /home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array)
#2 /home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/modules/migrate/src/Plugin/MigrationPluginManager.php(256): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#3 /home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(175): Drupal\migrate\Plugin\MigrationPluginManager->findDefinitions()
#4 /home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/modules/migrate/src/Plugin/MigrationPluginManager.php(109): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
#5 /home/elections/domains/develections.cruiskeenconsulting.com/public_html/modules/contrib/migrate_tools/migrate_tools.drush.inc(499): Drupal\migrate\Plugin\MigrationPluginManager->createInstances(Array)
#6 /home/elections/domains/develections.cruiskeenconsulting.com/public_html/modules/contrib/migrate_tools/migrate_tools.drush.inc(149): drush_migrate_tools_migration_list('')
#7 phar:///usr/bin/drush/includes/command.inc(422): drush_migrate_tools_migrate_status()
#8 phar:///usr/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#9 phar:///usr/bin/drush/includes/command.inc(199): drush_command()
#10 phar:///usr/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#11 phar:///usr/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 phar:///usr/bin/drush/includes/startup.inc(462): drush_main()
#13 phar:///usr/bin/drush/includes/startup.inc(369): drush_run_main(false, '/', 'Phar detected. ...')
#14 phar:///usr/bin/drush/drush(114): drush_startup(Array)
#15 /usr/bin/drush(10): require('phar:///usr/bin...')
#16 {main}
Error: Call to a member function getSetting() on null in Drupal\migrate_drupal\Plugin\migrate\EntityReferenceTranslationDeriver->getDerivativeDefinitions() (line 101 of /home/elections/domains/develections.cruiskeenconsulting.com/public_html/core/modules/migrate_drupal/src/Plugin/migrate/EntityReferenceTranslationDeriver.php).
Drush command terminated abnormally due to an unrecoverable error. [error]
I'm not quite certain how to proceed at this point, this sounds quite a lot like it may be related to https://www.drupal.org/project/drupal/issues/2912348 - but that appears to be fixed. If there is any help possible here I'd appreciate it.
Steps to reproduce
TBD
Proposed resolution
Add a check for NULL before using the returned array. The docs for \Drupal\Core\Entity\EntityFieldManagerInterface::getFieldDefinitions() doesn't state that NULL can be returned.
Remaining tasks
Manual testing - There are 3 reports of successful manual testing of the patch in #3, See #8, #10, #12, and #26.
Write a test - To do this a field needs to be created that does not have a definition. How to do that?
Review
Commit
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 2984460-3.patch | 1 KB | quietone |
| #14 | interdiff_3-14.txt | 13.93 KB | neelam_wadhwani |
| #14 | 2984460-14.patch | 1.59 KB | neelam_wadhwani |
| #3 | 2984460-3.patch | 1 KB | maxocub |
Comments
Comment #2
jumoke commentedHi Steve, did you ever figure this out? I am running into the same issue with 8.5, wondering what your fix was.
Comment #3
maxocub commentedCan you try this patch? I think it should fix it.
Comment #4
maxocub commentedNW for the tests.
Comment #5
steve hanson commentedYes - patch in comment 3 did the trick - migration is working fine again. Thank you from the bottom of my heart.
Comment #6
jumoke commentedAwesome! Patch in #3 works. Thank you so much Max
Comment #7
heddnLet's re-title and move this into 8.7's queue.
Comment #8
wgallop99 commentedWorked for me as well!!
Comment #10
ramonma1989#3 works for me. Thanks.
Comment #12
vgardner#3 worked for me. Cheers
Comment #13
neelam_wadhwani commentedComment #14
neelam_wadhwani commentedDid the changes and tested for drupal 8.9.x.
Comment #15
neelam_wadhwani commentedComment #17
prabha1997 commentedI am working in this issue
Comment #18
dhirendra.mishra commented#3 patch cleanely applies to 8.9.x.
This is then RTBC for me.
Comment #19
jungleCoding standards check must pass
See https://www.drupal.org/pift-ci-job/1582583
Comment #20
jungleRe #14. oh, no, drupal/address": "1.x-dev" should not be added
#3 patch is the right one to review. Set back to Needs review.
Comment #21
jungleWould be great to have test coverage. But not sure whether it's a must-have.
Comment #22
jungle@prabha1997 claimed to work on this, but no progress for 4 days. if you are still working on it, please assign to yourself again. Thanks!
Comment #23
quietone commentedHad a go at writing a test for this with no progress. I don't see how to make a field without a definition. I'd like to know what was in the original db that caused this. If you see how to write the test, pleas comment.
Anyway, there are 3 reports of successful manual testing, #8, #10, #12.
The change itself is just to check for NULL before using the returned array. The docs for \Drupal\Core\Entity\EntityFieldManagerInterface::getFieldDefinitions() doesn't state that NULL can be returned.
I am re-uploading the successful patch from #3.
Comment #25
mikelutzSetting this back to NW for tests again. If we can't duplicate the behavior in a test, then there may be some other issue here. If there is a bug in \Drupal\Core\Entity\EntityFieldManagerInterface::getFieldDefinitions() that it is returning NULL (or if the docs are just wrong) then we should address those.
Comment #26
alexrayu commented#23 resolved the issue for me. Thanks!
Comment #28
quietone commentedUpdate the IS. The original report was for a D6 source, so adding tag.
If you are using the patch please leave a comment stating the Drupal version of the source and destination sites. Thanks.
Comment #30
quietone commentedClosed #3032739: Error: Call to a member function getSetting() on null as a duplicate, adding credit.
Comment #31
quietone commentedI can get this failure locally by running d7_node_type, d7_field, d7_field_instance and d7_node_complete with the taxonomy module disabled. So, I started writing a test but that I can't get to the execution of d7_node_complete. I get errors in d7_field_instance resulting in the fatal error in this issue #3192893: [META] Serialization issues in Migration tests. And then when I apply that I get
Which is totally unexpected but might be a clue to #3123950: 'Field discovery failed for Drupal core version 7' errors if migration source database key is not 'migrate'. It is too late to investigate further. It will have to wait for another day.
Comment #32
thomaswalther commentedI also got the error with drupal 8.9.13 and slick (8.x-2.2) in view with slick_views (8.x-2.3):
Comment #34
4kant commentedPatch from #23 worked for me
Migration from 7.80 to 9.1.10
Thanks
Comment #35
vlad.dancerI confirm too that patch from #23 works for me too.
Doing migration from 7.77 to 9.2.0
Comment #38
felubraThe patch on #23 also worked for me in Drupal 9.4.0
Comment #39
grevil commentedWe just ran into the same issue! Patch from #23 works perfect!
We are migrating a large site from Drupal 7 to Drupal 9.4.5. Re #31 our migrate key is ['migrate']['default'] so this doesn't seem to be the reason for us.
Comment #40
huzookaYou all are using Drush migrate commands probably. I think the issue is about Drush’s migrate command.
That command instantiates all migration plugin instances at a very early phase, and also performs a requirement check The problem with this approach is not just that it can eat your memory (because after this, the plugin instances stored in memory will also contain fully instantiated source and destination plugin instances which often store their host object in a property), but this will make your source/destination plugin instances contain entity* managers with potentially outdated static definition caches.
If you try to execute these follow up migrations after everything is finished, in a "new" PHP thread, the issue won’t happen.
Keep in mind that there is a fundamental difference between Migrate Drupal UI and Drush migrate: while the built-in UI executes each migration in a separate batch task (which also means a new PHP thread), Drush migrate import executes every migration in the same PHP thread.
Comment #42
anybodyThanks for the heads-up @huzooka do you see any chance to fix that? At least the memory-thing? Using the UI for large migrations sounds untypical.
Comment #44
grevil commentedFYI, Patch #23 still applies cleanly on latest 11.x.
Comment #45
quietone commentedThe Migrate Drupal Module was approved for removal in #3371229: [Policy] Migrate Drupal and Migrate Drupal UI after Drupal 7 EOL.
This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
The deprecation work is in #3522602: [meta] Tasks to remove Migrate Drupal module and the removal work in #3522602: [meta] Tasks to remove Migrate Drupal module.
Migrate Drupal will not be moved to a contributed project. It will be removed from core after the Drupal 12.x branch is open.