Search_api error from drush errp.

Created on 24 October 2023, about 1 year ago
Updated 29 October 2023, about 1 year ago

Problem/Motivation

The Drush command,
drush errp paragraph
produces the error,

> ArgumentCountError: Too few arguments to function Drupal\search_api\Utility\FieldsHelper::__construct(), 4 passed in /web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 5 expected in /web/modules/contrib/search_api/src/Utility/FieldsHelper.php on line 87 
  #0 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\search_api\Utility\FieldsHelper->__construct()
> #1 /web/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupal\Component\DependencyInjection\Container->createService()
> #2 /web/modules/contrib/search_api/src/Plugin/search_api/datasource/ContentEntity.php(169): Drupal\Component\DependencyInjection\Container->get()
> #3 /web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(21): Drupal\search_api\Plugin\search_api\datasource\ContentEntity::create()
> #4 /web/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(83): Drupal\Core\Plugin\Factory\ContainerFactory->createInstance()
> #5 /web/modules/contrib/search_api/src/Utility/PluginHelper.php(78): Drupal\Component\Plugin\PluginManagerBase->createInstance()
> #6 /web/modules/contrib/search_api/src/Utility/PluginHelper.php(120): Drupal\search_api\Utility\PluginHelper->createIndexPlugin()
> #7 /web/modules/contrib/search_api/src/Utility/PluginHelper.php(151): Drupal\search_api\Utility\PluginHelper->createIndexPlugins()
> #8 /web/modules/contrib/search_api/src/Entity/Index.php(340): Drupal\search_api\Utility\PluginHelper->createDatasourcePlugins()
> #9 /web/modules/contrib/search_api/src/Entity/Index.php(357): Drupal\search_api\Entity\Index->getDatasources()
> #10 /web/modules/contrib/search_api/src/Plugin/search_api/datasource/ContentEntityTrackingManager.php(251): Drupal\search_api\Entity\Index->isValidDatasource()
> #11 /web/modules/contrib/search_api/src/Plugin/search_api/datasource/ContentEntityTrackingManager.php(204): Drupal\search_api\Plugin\search_api\datasource\ContentEntityTrackingManager->getIndexesForEntity()
> #12 /web/modules/contrib/search_api/search_api.module(251): Drupal\search_api\Plugin\search_api\datasource\ContentEntityTrackingManager->entityDelete()
> #13 [internal function]: search_api_entity_delete()
> #14 /web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array()
> #15 /web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
> #16 /web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
> #17 /web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(217): Drupal\Core\Extension\ModuleHandler->invokeAll()
> #18 /web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(900): Drupal\Core\Entity\EntityStorageBase->invokeHook()
> #19 /web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(462): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook()
> #20 /web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(753): Drupal\Core\Entity\EntityStorageBase->delete()
> #21 /web/core/lib/Drupal/Core/Entity/EntityBase.php(347): Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete()
> #22 /web/modules/contrib/entity_reference_revisions/src/EntityReferenceRevisionsOrphanPurger.php(134): Drupal\Core\Entity\EntityBase->delete()
> #23 /web/modules/contrib/entity_reference_revisions/src/EntityReferenceRevisionsOrphanPurger.php(199): Drupal\entity_reference_revisions\EntityReferenceRevisionsOrphanPurger->deleteUnusedRevision()
> #24 /web/modules/contrib/entity_reference_revisions/entity_reference_revisions.module(301): Drupal\entity_reference_revisions\EntityReferenceRevisionsOrphanPurger->deleteOrphansBatchOperation()
> #25 /vendor/drush/drush/includes/batch.inc(245): _entity_reference_revisions_orphan_purger_batch_dispatcher()
> #26 /vendor/drush/drush/includes/batch.inc(192): _drush_batch_worker()
> #27 /vendor/drush/drush/includes/batch.inc(75): _drush_batch_command()
> #28 /vendor/drush/drush/src/Commands/core/BatchCommands.php(25): drush_batch_command()
> #29 [internal function]: Drush\Commands\core\BatchCommands->process()
> #30 /vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
> #31 /vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
> #32 /vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
> #33 /vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process()
> #34 /vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
> #35 /vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run()
> #36 /vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand()
> #37 /vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun()
> #38 /vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
> #39 /vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
> #40 /vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run()
> #41 /vendor/drush/drush/drush(4): require('...')
> #42 /vendor/bin/drush(120): include('...')
> #43 {main}
>  [warning] Drush command terminated abnormally.

In ProcessBase.php line 171:

  Unable to decode output into JSON: Syntax error

  ArgumentCountError: Too few arguments to function Drupal\search_api\Utility\FieldsHelper::__construct(), 
4 passed in /web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 
and exactly 5 expected in Drupal\search_api\Utility\FieldsHelper->__construct() 
(line 87 of /web/modules/contrib/search_api/src/Utility/FieldsHelper.php).

drush cr solves this problem.

(The change below using array [] instead for arguments of the service search_api.fields_helper in file search_api.services.yml solves the problem, the Drush command then applies correctly,

>  [notice] Checked Paragraph revisions for orphans: 50 of 1087 in 0 s (0 deleted)
>  [notice] Checked Paragraph revisions for orphans: 100 of 1087 in 0 s (10 deleted)
...
>  [notice] Checked Paragraph revisions for orphans: 1087 of 1087 in 0 s (100 deleted)
>  [notice] Message: Paragraph: Deleted 100 revisions (100 entities) in 0 s.
>

)

Steps to reproduce

Drupal 10.1.5, Drush 12.3.0.0, Search API 8.x-1.30.
Install and enable modules Entity Reference Revisions and Paragraphs.
Use command drush errp paragraph or drush err:purge paragraph.

Proposed resolution

Cache rebuild after an upgrade to version 8.x-1.30.

(The change in file search_api.services.yml,

  search_api.fields_helper:
    class: Drupal\search_api\Utility\FieldsHelper
    arguments:
      - '@entity_type.manager'
      - '@entity_field.manager'
      - '@entity_type.bundle.info'
      - '@search_api.data_type_helper'
      - '@search_api.theme_switcher'

->

  search_api.fields_helper:
    class: Drupal\search_api\Utility\FieldsHelper
    arguments: ['@entity_type.manager', '@entity_field.manager', '@entity_type.bundle.info', '@search_api.data_type_helper', '@search_api.theme_switcher']

)

Remaining tasks

🐛 Bug report
Status

Closed: duplicate

Version

1.30

Component

General code

Created by

🇫🇷France Chris64 France

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

Comments & Activities

  • Issue created by @Chris64
  • 🇫🇷France Chris64 France

    The patch corresponding to the change suggested.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & sqlite-3.27
    last update about 1 year ago
    545 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    543 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    544 pass
  • I can't replicate this error. But that said I still think this patch should be merged, just so the service formatting is consistent throughout the whole YAML file. I'm leaving this as needs review, but there is no harm in merging this patch.

  • Status changed to Closed: works as designed about 1 year ago
  • 🇫🇷France Chris64 France

    The diff of search_api.services.yml between 8.x-1.29 and 8.x-1.30 is,

    57c57,62
    <     arguments: ['@entity_type.manager', '@entity_field.manager', '@entity_type.bundle.info', '@search_api.data_type_helper']
    ---
    >     arguments:
    >       - '@entity_type.manager'
    >       - '@entity_field.manager'
    >       - '@entity_type.bundle.info'
    >       - '@search_api.data_type_helper'
    >       - '@search_api.theme_switcher'
    87a93,96
    >
    >   search_api.theme_switcher:
    >     class: Drupal\search_api\Utility\ThemeSwitcher
    >     arguments: ['@theme.manager', '@theme.initialization', '@config.factory']

    with one more argument, 4 to 5. Related probably to 4 passed ... 5 expected. So a cache rebuild is needed for these services after a Search API upgrade to 8.x-1.30, and should be missing.

  • Status changed to Closed: duplicate about 1 year ago
  • 🇦🇹Austria drunken monkey Vienna, Austria

    Duplicate of 🐛 Upgrade to 1.30 throws helper too few arguements error Fixed , and a cache clear after upgrading the module (which is always advised anyways) should also fix this.

Production build 0.71.5 2024