Problem/Motivation

Updating the module from version 1.4.6 to 1.4.7 breaks my site / drush commands.

The error shown on the cli:

TypeError: Drupal\single_content_sync\Utility\CommandHelper::__construct(): Argument #6 ($entity_repository) must be of type Drupal\Core\Entity\EntityRepositoryInterface, string given, called in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 in /app/web/modules/contrib/single_content_sync/src/Utility/CommandHelper.php on line 85 #0 /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php(261): Drupal\single_content_sync\Utility\CommandHelper->__construct(Object(Drupal\single_content_sync\ContentImporter), Object(Drupal\Core\Config\ConfigFactory), Object(Drupal\Core\Entity\EntityTypeManager), Object(Drupal\single_content_sync\ContentSyncHelper), Object(Drupal\Core\File\FileSystem), '/app...')
#1 /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php(179): Drupal\Component\DependencyInjection\Container->createService(Array, 'single_content_...')
#2 /app/vendor/drush/drush/src/Runtime/LegacyServiceInstantiator.php(289): Drupal\Component\DependencyInjection\Container->get('single_content_...')
#3 /app/vendor/drush/drush/src/Runtime/LegacyServiceInstantiator.php(253): Drush\Runtime\LegacyServiceInstantiator->resolveFromContainer(Object(Drupal\Core\DependencyInjection\Container), 'single_content_...')
#4 [internal function]: Drush\Runtime\LegacyServiceInstantiator->resolveArgument('@single_content...')
#5 /app/vendor/drush/drush/src/Runtime/LegacyServiceInstantiator.php(223): array_map(Array, Array)
#6 /app/vendor/drush/drush/src/Runtime/LegacyServiceInstantiator.php(193): Drush\Runtime\LegacyServiceInstantiator->resolveArguments(Array)
#7 /app/vendor/drush/drush/src/Runtime/LegacyServiceInstantiator.php(167): Drush\Runtime\LegacyServiceInstantiator->instantiateObject('\\Drupal\\single_...', Array)
#8 /app/vendor/drush/drush/src/Runtime/LegacyServiceInstantiator.php(117): Drush\Runtime\LegacyServiceInstantiator->create('\\Drupal\\single_...', Array, Array)
#9 /app/vendor/drush/drush/src/Runtime/LegacyServiceInstantiator.php(54): Drush\Runtime\LegacyServiceInstantiator->instantiateServices(Array)
#10 /app/vendor/drush/drush/src/Boot/DrupalBoot8.php(242): Drush\Runtime\LegacyServiceInstantiator->loadServiceFiles(Array)
#11 /app/vendor/drush/drush/src/Boot/DrupalBoot8.php(218): Drush\Boot\DrupalBoot8->addDrupalModuleDrushCommands(Object(Drush\Boot\BootstrapManager))
#12 /app/vendor/drush/drush/src/Boot/BootstrapManager.php(211): Drush\Boot\DrupalBoot8->bootstrapDrupalFull(Object(Drush\Boot\BootstrapManager), NULL)
#13 /app/vendor/drush/drush/src/Boot/BootstrapManager.php(397): Drush\Boot\BootstrapManager->doBootstrap(5, 6, NULL)
#14 /app/vendor/drush/drush/src/Application.php(214): Drush\Boot\BootstrapManager->bootstrapMax()
#15 /app/vendor/drush/drush/src/Application.php(180): Drush\Application->bootstrapAndFind('locale:check')
#16 /app/vendor/symfony/console/Application.php(266): Drush\Application->find('locale:check')
#17 /app/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /app/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /app/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /app/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run(Array)
#21 /app/vendor/drush/drush/drush(4): require('/app...')
#22 {main}
TypeError: Drupal\single_content_sync\Utility\CommandHelper::__construct(): Argument #6 ($entity_repository) must be of type Drupal\Core\Entity\EntityRepositoryInterface, string given, called in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 in Drupal\single_content_sync\Utility\CommandHelper->__construct() (line 85 of /app/web/modules/contrib/single_content_sync/src/Utility/CommandHelper.php).

I don't have any custom modules extending single_content_sync.

Reverting to version 1.4.6 gets rid of the error.

Command icon 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:

Comments

guido_s created an issue. See original summary.

nginex’s picture

Status: Active » Postponed (maintainer needs more info)

Hello,

There is a notes in the release https://www.drupal.org/project/single_content_sync/releases/1.4.7

Did you try that already?

I noticed it on one project too, but not for others, seems like a cache issue. Reinstall the module to fix it

guido_s’s picture

Reverting to 1.4.6 and then updating to 1.4.7 again seems to work, but it would be good if it was working on the first attempt as I'm concerned what would happen on automatic deployments on several stages as this will just install what's in composer.json and core.extension.yml and not uninstalling and reinstalling anything. Would be bad if this is some kind of gambling on which environments it will work and on which it will break anything.
So this could still be an issue.

nginex’s picture

@guido_s

in terms of code it's looking good, there are no breaking changes or so, just one more service is added to dependency injection, so nothing I can do there. I already deployed the upgrade for multiple projects and there were no issues, so I need more details about environment where it happened or at least what drupal core version was used to understand and apply a possible fix.

rodrigoaguilera’s picture

Status: Postponed (maintainer needs more info) » Needs work

Usually modules changing injected services add an empty hook_post_update_NAME() to force a cache clear. Read more here:
https://www.drupal.org/node/2960601

To solve a single_content_sync.post_update.php file can be created with this hook.

nginex’s picture

@rodrigoaguilera it might work, thanks, will need to create a new release to include that file, I will review other issues as well, so I can include multiple fixes to a new release

rodrigoaguilera’s picture

Status: Needs work » Needs review

Opened an MR

rodrigoaguilera’s picture

I tested on the site that was giving me problems to update

nginex’s picture

Assigned: Unassigned » nginex

nginex’s picture

Assigned: nginex » Unassigned
Status: Needs review » Fixed
nginex’s picture

Status: Fixed » Closed (fixed)

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