Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Just now I've been working with Content Sync to manage taxonomy terms, and the export capability works great. Importing though is a different story; here's what happens when I try.
$ drush content-sync:import --entity-types=taxonomy_term
Differences of the export directory to the active content:
+---------------------------------+----------------------------------------------------------------------+-----------+
| Collection | Content Name | Operation |
+---------------------------------+----------------------------------------------------------------------+-----------+
(list of all available taxonomy terms here)
+---------------------------------+----------------------------------------------------------------------+-----------+
Do you want to import? (yes/no) [yes]:
>
> [notice]
> [error] Error: Call to a member function getEntityTypeFromClass() on null in Drupal\content_sync\Normalizer\ContentEntityNormalizer->denormalize() (line 49 of /path/to/site/modules/contrib/content_sync/src/Normalizer/ContentEntityNormalizer.php) #0 /path/to/vendor/symfony/serializer/Serializer.php(182): Drupal\content_sync\Normalizer\ContentEntityNormalizer->denormalize(Array, 'Drupal\\taxonomy...', 'yaml', Array)
> #1 /path/to/site/modules/contrib/content_sync/src/Importer/ContentImporter.php(67): Symfony\Component\Serializer\Serializer->denormalize(Array, 'Drupal\\taxonomy...', 'yaml', Array)
> #2 /path/to/site/modules/contrib/content_sync/src/Form/ContentImportTrait.php(79): Drupal\content_sync\Importer\ContentImporter->importEntity(Array, Array)
> #3 /path/to/vendor/drush/drush/includes/batch.inc(251): Drupal\content_sync\Commands\ContentSyncCommands->syncContent(Array, Array, Object(DrushBatchContext))
> #4 /path/to/vendor/drush/drush/includes/batch.inc(196): _drush_batch_worker()
> #5 /path/to/vendor/drush/drush/includes/batch.inc(99): _drush_batch_command('24')
> #6 /path/to/vendor/drush/drush/src/Drupal/Commands/core/BatchCommands.php(22): drush_batch_command('24')
> #7 [internal function]: Drush\Drupal\Commands\core\BatchCommands->process('24', Array)
> #8 /path/to/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
> #9 /path/to/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #10 /path/to/vendor/consolidation/annotated-command/src/CommandProcessor.php(178): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #11 /path/to/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #12 /path/to/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #13 /path/to/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #14 /path/to/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #15 /path/to/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #16 /path/to/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #17 /path/to/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
> #18 /path/to/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
> #19 /path/to/vendor/drush/drush/includes/preflight.inc(18): require('/path/to...')
> #20 phar:///home/me/bin/drush/bin/drush.php(141): drush_main()
> #21 /home/me/bin/drush(10): require('phar:///home/gr...')
> #22 {main}.
> Error: Call to a member function getEntityTypeFromClass() on null in /path/to/site/modules/contrib/content_sync/src/Normalizer/ContentEntityNormalizer.php on line 49 #0 /path/to/vendor/symfony/serializer/Serializer.php(182): Drupal\content_sync\Normalizer\ContentEntityNormalizer->denormalize(Array, 'Drupal\\taxonomy...', 'yaml', Array)
> #1 /path/to/site/modules/contrib/content_sync/src/Importer/ContentImporter.php(67): Symfony\Component\Serializer\Serializer->denormalize(Array, 'Drupal\\taxonomy...', 'yaml', Array)
> #2 /path/to/site/modules/contrib/content_sync/src/Form/ContentImportTrait.php(79): Drupal\content_sync\Importer\ContentImporter->importEntity(Array, Array)
> #3 /path/to/vendor/drush/drush/includes/batch.inc(251): Drupal\content_sync\Commands\ContentSyncCommands->syncContent(Array, Array, Object(DrushBatchContext))
> #4 /path/to/vendor/drush/drush/includes/batch.inc(196): _drush_batch_worker()
> #5 /path/to/vendor/drush/drush/includes/batch.inc(99): _drush_batch_command('24')
> #6 /path/to/vendor/drush/drush/src/Drupal/Commands/core/BatchCommands.php(22): drush_batch_command('24')
> #7 [internal function]: Drush\Drupal\Commands\core\BatchCommands->process('24', Array)
> #8 /path/to/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
> #9 /path/to/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #10 /path/to/vendor/consolidation/annotated-command/src/CommandProcessor.php(178): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #11 /path/to/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #12 /path/to/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #13 /path/to/vendor/symfony/console/Application.php(978): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #14 /path/to/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #15 /path/to/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #16 /path/to/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #17 /path/to/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
> #18 /path/to/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
> #19 /path/to/vendor/drush/drush/includes/preflight.inc(18): require('/path/to...')
> #20 phar:///home/me/bin/drush/bin/drush.php(141): drush_main()
> #21 /home/me/bin/drush(10): require('phar:///home/gr...')
> #22 {main}
> [warning] Drush command terminated abnormally. Check for an exit() in your Drupal site.
In ProcessBase.php line 184:
Unable to decode output into JSON.
content-sync:import [--entity-types [ENTITY-TYPES]] [--uuids [UUIDS]] [--actions [ACTIONS]] [--skiplist] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--druplicon] [--notify [NOTIFY]] [--xh-link XH-LINK] [--] <command> [<label>]
I took a look at the code and it seems that the parent class of ContentEntityNormalizer has a protected property entityTypeManager, but not entityManager. This patch switches the property name, and it looks like it might fix the import. This might be complicated in that there's also an entityFieldManager property, so it might require a second pass to fix those references.
Comment | File | Size | Author |
---|---|---|---|
content_sync-entity_manager_refs.patch | 4.58 KB | geoffreyr |
Comments
Comment #2
geoffreyr CreditAttribution: geoffreyr commentedComment #3
thursday_bw CreditAttribution: thursday_bw at Catalyst IT commentedI've changed the title. I had the exact same issue importing a webform. And looking at the code every thing would fail on import.
I'm applying the patch now to see if it works for me.
Comment #4
thursday_bw CreditAttribution: thursday_bw at Catalyst IT commentedPretty straight forward patch. and critical too.
It's just changed the references to the entityTypeManager. all good in my book.
Comment #5
jonathanthiry CreditAttribution: jonathanthiry commentedI had the same issue and the patch fixed it perfectly, thanks!
It would be great to apply it to the development branch.
Comment #6
themetman CreditAttribution: themetman commentedWorked for me as well. Thanks a million.
Comment #7
Gribnif CreditAttribution: Gribnif commentedI wish someone would commit this patch. It would have saved me quite a bit of time had it already been done.
That said, there is a less urgent issue, in that these methods on $this->entityTypeManager are deprecated: getBundleInfo, getFieldDefinitions, getBaseFieldDefinitions, getEntityTypeFromClass
Comment #8
thursday_bw CreditAttribution: thursday_bw at Catalyst IT commentedThis patch should be committed and then another ticket opened to deal with the deprecations.
That way the bug is resolved and of benefit to users and an action plan for deprecations in place.
Comment #9
panshulk CreditAttribution: panshulk as a volunteer and commentedWas facing the same issue while importing, this patch works as well but there is another patch which involves doing less changes and it just passes the entityManager instance in the constructor.
: https://www.drupal.org/project/content_sync/issues/3076902#comment-13386719
We can review this one as well.
Comment #10
panshulk CreditAttribution: panshulk as a volunteer and commentedComment #11
Kwadz CreditAttribution: Kwadz commented@panshulk, I think we still need to update the code with the right property name:
$this->entityTypeManager
which is now the name used inFieldableEntityNormalizerTrait
from Drupal ≥8.7.x.Comment #12
Taiger CreditAttribution: Taiger as a volunteer commentedThis patch did not work for me and neither did the initial patch on this issue: https://www.drupal.org/project/content_sync/issues/3076902.
I still am unable to successfully import.
Is it just me?
Comment #14
Blanca.Esqueda CreditAttribution: Blanca.Esqueda as a volunteer and commentedThank you @Gribnif,
Patch has been added to 8.x-2.dev
Important: To use 8.x-2.dev the module has to be uninstalled and reinstalled as the content file tree structure has been changed. Also please note the same version has to be used for the source and target sites.
Another issue will be open for " $this->entityTypeManager are deprecated: getBundleInfo, getFieldDefinitions, getBaseFieldDefinitions, getEntityTypeFromClass " as per Gribnif comment.
Comment #15
Blanca.Esqueda CreditAttribution: Blanca.Esqueda as a volunteer and commented@Taiger
Please open another issue with the specific error that you are facing
Comment #16
Blanca.Esqueda CreditAttribution: Blanca.Esqueda as a volunteer and commentedComment #18
manish34jain CreditAttribution: manish34jain as a volunteer and commentedThank you. It worked.