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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geoffreyr created an issue. See original summary.

geoffreyr’s picture

Title: Taxonomy term import doesn't work; looking for entityManager on » Taxonomy term import doesn't work; looking for entityManager on ContentEntityNormalizer
thursday_bw’s picture

Title: Taxonomy term import doesn't work; looking for entityManager on ContentEntityNormalizer » Import doesn't work; looking for entityManager on ContentEntityNormalizer

I'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.

thursday_bw’s picture

Status: Needs review » Reviewed & tested by the community

Pretty straight forward patch. and critical too.
It's just changed the references to the entityTypeManager. all good in my book.

jonathanthiry’s picture

I had the same issue and the patch fixed it perfectly, thanks!
It would be great to apply it to the development branch.

themetman’s picture

Worked for me as well. Thanks a million.

Gribnif’s picture

I 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

thursday_bw’s picture

This 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.

panshulk’s picture

Was 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.

panshulk’s picture

Status: Reviewed & tested by the community » Needs review
Kwadz’s picture

@panshulk, I think we still need to update the code with the right property name: $this->entityTypeManager which is now the name used in FieldableEntityNormalizerTrait from Drupal ≥8.7.x.

Taiger’s picture

Status: Needs review » Needs work

This 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?

  • geoffreyr authored cd3809b on 8.x-2.x
    Issue #3052772 by geoffreyr, thursday_bw, panshulk, jonathanthiry,...
Blanca.Esqueda’s picture

Thank 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.

Blanca.Esqueda’s picture

@Taiger
Please open another issue with the specific error that you are facing

Blanca.Esqueda’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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

manish34jain’s picture

Thank you. It worked.