Type error in AttachMediaToGroup.php after updating Core to 10.3

Created on 13 August 2024, 11 months ago
Updated 9 September 2024, 10 months ago

Problem/Motivation

After updating Drupal Core from 10.2 to 10.3, I ran into this error during "drush updb". It appears that the constructor of AttachMediaToGroup has the 5th argument typed as Drupal\Core\Logger\LoggerChannelInterface but an instance of Psr\Log\NullLogger is provided. One way to fix this is to relax the type hint to Psr\Log\LoggerInterface. But I wonder if this is a better way. The patch is for Group Media v2.2.0 because we are locked into Group Media v2 for now.

In ProcessBase.php line 171:
                                                                                                                                                                                                                                                               
  Unable to decode output into JSON: Syntax error                                                                                                                                                                                                              
                                                                                                                                                                                                                                                               
  TypeError: Drupal\groupmedia\AttachMediaToGroup::__construct(): Argument #5 ($logger) must be of type Drupal\Core\Logger\LoggerChannelInterface, Psr\Log\NullLogger given in Drupal\groupmedia\AttachMediaToGroup->__construct() (line 88 of /app/web/modul  
  es/contrib/groupmedia/src/AttachMediaToGroup.php).  

The full call stack:

>  [notice] Update started: block_content_post_update_revision_type
> TypeError: Drupal\groupmedia\AttachMediaToGroup::__construct(): Argument #5 ($logger) must be of type Drupal\Core\Logger\LoggerChannelInterface, Psr\Log\NullLogger given in /app/web/modules/contrib/groupmedia/src/AttachMediaToGroup.php on line 88 #0 [internal function]: Drupal\groupmedia\AttachMediaToGroup->__construct(Object(Drupal\groupmedia\MediaFinderManager), Object(Drupal\group\Plugin\GroupContentEnablerManager), Object(Drupal\Core\Extension\ModuleHandler), Object(Drupal\Core\Entity\EntityTypeManager), Object(Psr\Log\NullLogger))
> #1 /app/vendor/symfony/dependency-injection/ContainerBuilder.php(1140): ReflectionClass->newInstanceArgs(Array)
> #2 /app/vendor/symfony/dependency-injection/ContainerBuilder.php(586): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'groupmedia.atta...')
> #3 /app/vendor/symfony/dependency-injection/ContainerBuilder.php(531): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('groupmedia.atta...', 1)
> #4 /app/web/core/lib/Drupal.php(197): Symfony\Component\DependencyInjection\ContainerBuilder->get('groupmedia.atta...')
> #5 /app/web/modules/contrib/groupmedia/groupmedia.module(50): Drupal::service('groupmedia.atta...')
> #6 [internal function]: groupmedia_entity_update(Object(Drupal\block_content\Entity\BlockContentType), 'block_content_t...')
> #7 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): call_user_func_array(Object(Closure), Array)
> #8 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'groupmedia')
> #9 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(423): Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_update', Object(Closure))
> #10 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(343): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array)
> #11 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(564): Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook('update', Object(Drupal\block_content\Entity\BlockContentType))
> #12 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(489): Drupal\Core\Entity\EntityStorageBase->doPostSave(Object(Drupal\block_content\Entity\BlockContentType), true)
> #13 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(257): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\block_content\Entity\BlockContentType))
> #14 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\block_content\Entity\BlockContentType))
> #15 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(614): Drupal\Core\Entity\EntityBase->save()
> #16 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php(192): Drupal\Core\Config\Entity\ConfigEntityBase->save()
> #17 /app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php(147): Drupal\Core\Config\Entity\ConfigEntityUpdater->doOne(Object(Drupal\block_content\Entity\BlockContentType), Object(Closure))
> #18 /app/web/core/modules/block_content/block_content.post_update.php(93): Drupal\Core\Config\Entity\ConfigEntityUpdater->update(Array, 'block_content_t...', Object(Closure))
> #19 /app/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(280): block_content_post_update_revision_type(Array)
> #20 /app/vendor/drush/drush/includes/batch.inc(257): Drush\Commands\core\UpdateDBCommands::updateDoOnePostUpdate('block_content_p...', Array)
> #21 /app/vendor/drush/drush/includes/batch.inc(204): _drush_batch_worker()
> #22 /app/vendor/drush/drush/includes/batch.inc(75): _drush_batch_command('4303')
> #23 /app/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(136): drush_batch_command('4303')
> #24 [internal function]: Drush\Commands\core\UpdateDBCommands->process('4303', Array)
> #25 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array(Array, Array)
> #26 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #27 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #28 /app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
> #29 /app/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #30 /app/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #31 /app/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #32 /app/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
> #33 /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))
> #34 /app/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
> #35 /app/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run(Array)
> #36 /app/vendor/drush/drush/drush(4): require('/app/vendor/dru...')
> #37 /app/vendor/bin/drush(119): include('/app/vendor/dru...')
> #38 {main}
>  [warning] Drush command terminated abnormally.

Steps to reproduce

Proposed resolution

πŸ› Bug report
Status

Fixed

Version

2.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kevin w

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024