Update constructor when #3100732: Allow specifying metadata on JSON:API objects lands

Created on 2 June 2024, 26 days ago

Problem/Motivation

After upgrading from 3.24 to 3.25, when I try to run drush updatedb or drush cr, I get the following error:

 [error]  TypeError: Drupal\jsonapi_defaults\Controller\EntityResource::__construct(): Argument #12 ($jsonapi_defaults) must be of type Drupal\jsonapi_defaults\JsonapiDefaultsInterface, Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher given in Drupal\jsonapi_defaults\Controller\EntityResource->__construct() (line 75 of /var/www/html/web/modules/contrib/jsonapi_extras/modules/jsonapi_defaults/src/Controller/EntityResource.php) #0 [internal function]: Drupal\jsonapi_defaults\Controller\EntityResource->__construct()

Reverting to 3.24 clears the error. By moving backwards one commit at a time in the git history, I traced the breakage to 🐛 Pages with default includes are not cached Fixed .

Drupal 10.2.6, PHP 8.3.

📌 Task
Status

Postponed

Version

3.0

Component

Code

Created by

🇯🇵Japan ptmkenny

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

Merge Requests

Comments & Activities

  • Issue created by @ptmkenny
  • 🇯🇵Japan ptmkenny

    Full stacktrace:

    Fatal error: Uncaught TypeError: Drupal\jsonapi_defaults\Controller\EntityResource::__construct(): Argument #12 ($jsonapi_defaults) must be of type Drupal\jsonapi_defaults\JsonapiDefaultsInterface, Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and defined in /var/www/html/web/modules/jsonapi_extras/modules/jsonapi_defaults/src/Controller/EntityResource.php:75
    Stack trace:
    #0 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\jsonapi_defaults\Controller\EntityResource->__construct()
    #1 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService()
    #2 /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(20): Drupal\Component\DependencyInjection\Container->get()
    #3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityResolverManager.php(106): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition()
    #4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityResolverManager.php(219): Drupal\Core\Entity\EntityResolverManager->getControllerClass()
    #5 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php(48): Drupal\Core\Entity\EntityResolverManager->setRouteOptions()
    #6 [internal function]: Drupal\Core\EventSubscriber\EntityRouteAlterSubscriber->onRoutingRouteAlterSetType()
    #7 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
    #8 /var/www/html/web/core/lib/Drupal/Core/Routing/RouteBuilder.php(189): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
    #9 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild()
    #10 /var/www/html/web/core/includes/common.inc(485): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild()
    #11 /var/www/html/web/core/includes/utility.inc(41): drupal_flush_all_caches()
    #12 /var/www/html/vendor/drush/drush/src/Commands/core/CacheRebuildCommands.php(70): drupal_rebuild()
    #13 [internal function]: Drush\Commands\core\CacheRebuildCommands->rebuild()
    #14 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
    #15 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
    #16 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
    #17 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(387): Consolidation\AnnotatedCommand\CommandProcessor->process()
    #18 /var/www/html/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
    #19 /var/www/html/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run()
    #20 /var/www/html/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
    #21 /var/www/html/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
    #22 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
    #23 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
    #24 /var/www/html/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run()
    #25 /var/www/html/vendor/drush/drush/drush(4): require('...')
    #26 /var/www/html/vendor/bin/drush(119): include('...')
    #27 {main}
      thrown in /var/www/html/web/modules/jsonapi_extras/modules/jsonapi_defaults/src/Controller/EntityResource.php on line 75
     [warning] Drush command terminated abnormally.
    
  • Merge request !51inject event_dispatcher → (Open) created by ptmkenny
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 26 days ago
    17 pass, 2 fail
  • Status changed to Needs review 26 days ago
  • 🇯🇵Japan ptmkenny

    The eventDispatcher never got injected, but it is provided by core, so then in construct() all the arguments get out of order, breaking the site. This MR injects the eventDispatcher so that the parent constructor can be called properly.

  • Pipeline finished with Failed
    26 days ago
    #189168
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    1:32
    59:47
    Running
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    57:44
    55:48
    Running
  • Pipeline finished with Canceled
    26 days ago
    Total: 205s
    #189183
  • Status changed to Postponed 26 days ago
  • 🇯🇵Japan ptmkenny

    So this issue was caused by me having applied the MR in Allow specifying `meta` data on JSON:API objects Needs work . When this issue eventually gets committed to core, the code will need to be updated, so I'm marking postponed for now. But feel free to close if you would rather handle this once the commit actually happens.

  • Pipeline finished with Failed
    26 days ago
    Total: 249s
    #189190
  • Pipeline finished with Failed
    21 days ago
    Total: 178s
    #193415
  • Pipeline finished with Success
    16 days ago
    Total: 356s
    #196967
  • Pipeline finished with Failed
    16 days ago
    Total: 206s
    #197540
  • Pipeline finished with Canceled
    16 days ago
    Total: 147s
    #197542
  • Pipeline finished with Failed
    16 days ago
    Total: 270s
    #197543
  • Pipeline finished with Failed
    16 days ago
    #197552
  • Pipeline finished with Failed
    16 days ago
    Total: 388s
    #197583
  • Pipeline finished with Success
    16 days ago
    Total: 281s
    #197591
  • Pipeline finished with Success
    16 days ago
    Total: 302s
    #197599
  • Pipeline finished with Success
    15 days ago
    Total: 1133s
    #197657
  • Pipeline finished with Success
    15 days ago
    Total: 204s
    #197669
  • Pipeline finished with Failed
    15 days ago
    Total: 300s
    #198255
  • Pipeline finished with Failed
    14 days ago
    Total: 298s
    #199186
  • Pipeline finished with Failed
    14 days ago
    Total: 296s
    #199193
  • Pipeline finished with Canceled
    14 days ago
    Total: 197s
    #199203
  • Pipeline finished with Failed
    14 days ago
    Total: 306s
    #199206
  • Pipeline finished with Failed
    14 days ago
    Total: 303s
    #199219
  • Pipeline finished with Failed
    14 days ago
    Total: 301s
    #199239
  • Pipeline finished with Skipped
    14 days ago
    #199257
  • Pipeline finished with Failed
    14 days ago
    Total: 309s
    #199253
  • Pipeline finished with Failed
    14 days ago
    Total: 292s
    #199272
  • Pipeline finished with Success
    12 days ago
    Total: 151s
    #200133
  • Pipeline finished with Failed
    11 days ago
    Total: 40s
    #200706
  • Pipeline finished with Success
    11 days ago
    Total: 144s
    #200846
  • Pipeline finished with Manual
    10 days ago
    #199399
  • Pipeline finished with Manual
    9 days ago
    #202696
  • Pipeline finished with Skipped
    8 days ago
    #204135
  • Pipeline finished with Failed
    7 days ago
    Total: 198s
    #204786
  • Pipeline finished with Failed
    7 days ago
    Total: 273s
    #204847
  • Pipeline finished with Failed
    7 days ago
    Total: 283s
    #204969
  • Pipeline finished with Success
    7 days ago
    Total: 281s
    #204976
  • Pipeline finished with Success
    7 days ago
    Total: 312s
    #204981
  • Pipeline finished with Success
    7 days ago
    Total: 266s
    #204990
  • Pipeline finished with Failed
    7 days ago
    Total: 195s
    #205012
  • Pipeline finished with Success
    7 days ago
    Total: 281s
    #205054
  • Pipeline finished with Success
    7 days ago
    Total: 370s
    #205061
  • Pipeline finished with Success
    7 days ago
    Total: 277s
    #205098
  • Pipeline finished with Success
    7 days ago
    Total: 287s
    #205107
  • Pipeline finished with Success
    7 days ago
    Total: 279s
    #205118
  • Pipeline finished with Success
    6 days ago
    Total: 279s
    #205409
  • Pipeline finished with Failed
    6 days ago
    Total: 283s
    #205429
  • Pipeline finished with Success
    6 days ago
    Total: 276s
    #205444
  • Pipeline finished with Failed
    6 days ago
    Total: 206s
    #205461
  • Pipeline finished with Failed
    6 days ago
    Total: 277s
    #205536
  • Pipeline finished with Success
    6 days ago
    Total: 274s
    #205551
  • Pipeline finished with Success
    6 days ago
    Total: 309s
    #205626
  • Pipeline finished with Success
    6 days ago
    Total: 296s
    #205631
Production build 0.69.0 2024