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

ArrayInputFactory fails in production mode #7604

Closed
giacmir opened this issue Nov 29, 2016 · 5 comments
Closed

ArrayInputFactory fails in production mode #7604

giacmir opened this issue Nov 29, 2016 · 5 comments
Labels
bug report Component: Setup Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release

Comments

@giacmir
Copy link
Member

giacmir commented Nov 29, 2016

I wrote a shell command that imports products from a custom format. At the end of the import process I need to call two other commands to launch a reindex and to empty cache.

To do so I get an Symfony\Component\Console\Input\ArrayInputFactory from my constructor and then I create the ArrayInput object in this way:

$parameters = [
  'command' => 'indexer:reindex',
  'index' => ['cataloginventory_stock'],
 ];

$indexerArgs = $this->arrayInputFactory->create(['parameters' => $parameters]);

This used to work fine in 2.0 but in 2.1 it works only in developer mode. In production mode the command dies with the following error:

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Symfony\Component\Console\Input\ArrayInput::__construct() must be of the type array, object given, called in /var/www/nuna_stage/web/releases/20161128162520/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /var/www/nuna_stage/web/releases/20161128162520/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php:37
Stack trace:
#0 /var/www/nuna_stage/web/releases/20161128162520/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): Symfony\Component\Console\Input\ArrayInput->__construct(Object(Magento\Framework\ObjectManager\ObjectManager))
#1 /var/www/nuna_stage/web/releases/20161128162520/vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Symfony\\Compone...', Array)
#2 /var/www/nuna_stage/web/releases/20161128162520/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Fact in /var/www/nuna_stage/web/releases/20161128162520/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php on line 37

Preconditions

  1. Magento 2.1.2
  2. Php 7

Steps to reproduce

  1. Create a new command
  2. Use ArrayInputFactory as described above
  3. launch the command

Expected result

  1. The command runs without errors both in developer and in production mode

Actual result

  1. In developer mode the command runs, in production it fails.
@giacmir
Copy link
Member Author

giacmir commented Nov 29, 2016

Note that this same exception is mentioned in #2604 and that issue was closed with a "put your site in developer mode before running the command". That could be valid for installing sample data but not in my case obviously.

@shiftedreality
Copy link
Member

Hi @giacmir

We've created internal ticket MAGETWO-62676 to investigate and fix this issue.
As a temporary solution you can create an ArrayInput object via new keyword:

$commandInput = new ArrayInput($arguments);

@shiftedreality shiftedreality added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development develop labels Dec 26, 2016
@giacmir
Copy link
Member Author

giacmir commented Dec 27, 2016

Thanks @shiftedreality

In fact using new is exactly what I've done just after opening this issue. 😉

@phoenix128
Copy link
Contributor

Same error here with custom class. Seems related to \Magento\Framework\ObjectManager\Factory\Compiled class not passing correct arguments

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Component: Setup labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@giacmir, thank you for your report.
The issue is already fixed in develop branch, 2.2.0

@magento-engcom-team magento-engcom-team added Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release labels Oct 17, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Setup Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release
Projects
None yet
Development

No branches or pull requests

5 participants