Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error in ResetIndexesCommand.php #19430

Closed
Rafelder opened this issue Mar 15, 2023 · 4 comments · Fixed by #19518
Closed

Type Error in ResetIndexesCommand.php #19430

Rafelder opened this issue Mar 15, 2023 · 4 comments · Fixed by #19518

Comments

@Rafelder
Copy link

🐛 I'm reporting a Bug 🐛

There is a type error in the ResetIndexesCommand.php:

$this
->addOption(
'reset-indexes',
true,
InputOption::VALUE_NONE,
'Resets registered ES indexes prior to reindex'
)

CRITICAL  [console] An error occurred while using the console. Message: "Symfony\Component\Console\Command\Command::addOption(): Argument #2 ($shortcut) must be of type array|string|null, bool given, called in /app/vendor/akeneo/pim-community-dev/src/Akeneo/Tool/Bundle/ElasticsearchBundle/Command/ResetIndexesCommand.php on line 49"

The error prevents the console to be used without a command and prevent the use of the command akeneo:elasticsearch:reset-indexes completely.

Steps to reproduce:

  • Setup a new Akeneo (in my case CE 7.0.10)
  • Call "bin/console" without a command or call the command akeneo:elasticsearch:reset-indexes

I cant provide a system file, because the system page needs functioning ElasticSearch nodes and the bug prevents reseting the nodes.

@Rafelder
Copy link
Author

Rafelder commented Mar 23, 2023

The same error occurs in the following commands:

  • vendor/akeneo/pim-community-dev/src/Akeneo/Pim/Enrichment/Bundle/Command/CalculateCompletenessCommand.php
  • vendor/akeneo/pim-community-dev/src/Akeneo/Pim/Enrichment/Bundle/Command/CleanRemovedProductsCommand.php
  • vendor/akeneo/pim-community-dev/src/Akeneo/Pim/Enrichment/Bundle/Command/IndexProductCommand.php
  • vendor/akeneo/pim-community-dev/src/Akeneo/Pim/Enrichment/Bundle/Command/IndexProductModelCommand.php
  • vendor/akeneo/pim-enterprise-dev/src/Akeneo/AssetManager/back/Infrastructure/Persistence/Sql/CLI/RefreshAssetsCommand.php
  • vendor/akeneo/pim-enterprise-dev/src/Akeneo/AssetManager/back/Infrastructure/Symfony/Command/IndexAssetsCommand.php
  • vendor/akeneo/pim-enterprise-dev/src/Akeneo/Pim/WorkOrganization/Workflow/Bundle/Command/IndexProductProposalCommand.php
  • vendor/akeneo/pim-enterprise-dev/src/Akeneo/Pim/WorkOrganization/Workflow/Bundle/Command/IndexPublishedProductCommand.php
  • vendor/akeneo/pim-enterprise-dev/src/Akeneo/ReferenceEntity/back/Infrastructure/Symfony/Command/IndexRecordsCommand.php

@jmleroux
Copy link
Contributor

jmleroux commented Mar 28, 2023

Hello @Rafelder ,

Didn't you upgrade your Symfony version in vendor?

Because CE PIM requires Symfony 5.4, and we can see that the addOption shortcut is not typed in this version here

You're stil right about the type issue, but it should not throw error because it's only PhpDoc type on SF 5.4.

Yet, we will have an issue if upgrading to Symfony 6.0+, because the shortcut will be typed

jmleroux added a commit that referenced this issue Mar 29, 2023
* GH-19430: Command shortcut cannot be a boolean

* GH-19430: Use InputOption::VALUE_OPTIONAL
@Rafelder
Copy link
Author

I installed a fresh copy of Akeneo 7.0.10 (with smyfony 5.4) when the errors occured. I checked the typings of the addOption function and can confirm that the typing is only done in PhpDoc. I don't know why the critical errors occured in my case but they are gone now.

I guess the issue can be closed. Thank you.

@DanieliMi
Copy link

DanieliMi commented Jun 27, 2023

This is still an issue in v7.0.19. When is this expected to be released in a Tag?

Downgrading to symfony/console ^5.4 helps though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants