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.
Comments
Comment #2
nginex commentedHello,
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
Comment #3
guido_sReverting 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.
Comment #4
nginex commented@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.
Comment #5
rodrigoaguileraUsually 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.
Comment #6
nginex commented@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
Comment #8
rodrigoaguileraOpened an MR
Comment #9
rodrigoaguileraI tested on the site that was giving me problems to update
Comment #10
nginex commentedComment #12
nginex commentedComment #13
nginex commentedHere we go https://www.drupal.org/project/single_content_sync/releases/1.4.8