sys:check throws fatal error in production mode #241

Closed
hostep opened this Issue Oct 5, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@hostep
Contributor

hostep commented Oct 5, 2016

Hi

I just noticed when trying to run sys:check on a production server that we get this fatal error:

php vendor/bin/n98-magerun2 sys:check
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to N98\Magento\Command\System\Check\Settings\CheckAbstract::__construct() must implement interface Magento\Framework\App\Config\ScopeConfigInterface, instance of Magento\Framework\ObjectManager\ObjectManager given, called in /var/www/html/releases/20161005143021/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /var/www/html/releases/20161005143021/vendor/n98/magerun2/src/N98/Magento/Command/System/Check/Settings/CheckAbstract.php:34
Stack trace:
#0 /var/www/html/releases/20161005143021/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): N98\Magento\Command\System\Check\Settings\CheckAbstract->__construct(Object(Magento\Framework\ObjectManager\ObjectManager))
#1 /var/www/html/releases/20161005143021/vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('N98\\Magento\\Com...', Array)
#2 /var/www/html/releases/20161005143021/vendor/ in /var/www/html/releases/20161005143021/vendor/n98/magerun2/src/N98/Magento/Command/System/Check/Settings/CheckAbstract.php on line 34

This doesn't happen on a development machine, and my guess is that this is most likely because we don't run setup:di:compile locally.
I could reproduce the problem on 3 different completely different production machines, so it isn't depending on a certain environment.

Using magerun2 version 1.2.2, installed using composer.

If you need more info, please let me know :)

@tkn98

This comment has been minimized.

Show comment
Hide comment
@tkn98

tkn98 Oct 5, 2016

Contributor

Thanks for the report and indeed interesting.

From top of my head this should not be handled via ctor but the inject method we have for those dependencies. But that's just quick.

Contributor

tkn98 commented Oct 5, 2016

Thanks for the report and indeed interesting.

From top of my head this should not be handled via ctor but the inject method we have for those dependencies. But that's just quick.

@tkn98 tkn98 added bug support labels Oct 5, 2016

@tkn98

This comment has been minimized.

Show comment
Hide comment
@tkn98

tkn98 Oct 5, 2016

Contributor

Can reproduce on a production system.

Contributor

tkn98 commented Oct 5, 2016

Can reproduce on a production system.

ktomk added a commit to ktomk/n98-magerun2 that referenced this issue Jan 23, 2017

Fix Magento object manager usage, fixes #241
The Magento 2 object manager fails with non-magento classes, like the
check classes of the sys:check command.

Fix is to add constructor injection to the injection helper and
instantiate the Magerun classes via it.

Note: TODO is to run the test-suite as well against a setup with
production mode (e.g. switch from develop to production while building).

Refs:

- #241

- Command: sys:check

@ktomk ktomk added the In Progress label Jan 23, 2017

@ktomk ktomk self-assigned this Jan 23, 2017

ktomk added a commit to ktomk/n98-magerun2 that referenced this issue Jan 23, 2017

Fix Magento object manager usage, fixes #241
The Magento 2 object manager fails with non-magento classes, like the
check classes of the sys:check command.

Fix is to add constructor injection to the injection helper and
instantiate the Magerun classes via it.

Note: TODO is to run the test-suite as well against a setup with
production mode (e.g. switch from develop to production while building).

Refs:

- #241

- Command: sys:check

ktomk added a commit to ktomk/n98-magerun2 that referenced this issue Jan 23, 2017

Skip developer console command tests when in production mode
At least one developer console command is not compatible with production
mode. Therefore skipping tests when the Magento 2 instance the test is
run against is in production mode.

That one command "make:block" via it's test full output:

    There was 1 error:

    1) N98\Magento\Command\Developer\Console\MakeBlockCommandTest::testOutput
    preg_quote() expects parameter 1 to be string, object given

    /.../build-n98-magerun2/magento2/www/vendor/zendframework/zend-filter/src/Word/SeparatorToSeparator.php:94
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/AbstractGeneratorCommand.php:155
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/MakeBlockCommand.php:42
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/MakeBlockCommand.php:30
    /.../build-n98-magerun2/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
    /.../build-n98-magerun2/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php:80
    /.../build-n98-magerun2/tests/N98/Magento/Command/Developer/Console/MakeBlockCommandTest.php:20

Refs:

- #241

- Command: make:block

ktomk added a commit to ktomk/n98-magerun2 that referenced this issue Jan 23, 2017

Fix Magento object manager usage, fixes #241
The Magento 2 object manager fails with non-magento classes, like the
check classes of the sys:check command.

Fix is to add constructor injection to the injection helper and
instantiate the Magerun classes via it.

Refs:

- #241

- Command: sys:check

ktomk added a commit to ktomk/n98-magerun2 that referenced this issue Jan 24, 2017

Skip developer console command tests when in production mode
At least one developer console command is not compatible with production
mode. Therefore skipping tests when the Magento 2 instance the test is
run against is in production mode.

That one command "make:block" via it's test full output:

    There was 1 error:

    1) N98\Magento\Command\Developer\Console\MakeBlockCommandTest::testOutput
    preg_quote() expects parameter 1 to be string, object given

    /.../build-n98-magerun2/magento2/www/vendor/zendframework/zend-filter/src/Word/SeparatorToSeparator.php:94
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/AbstractGeneratorCommand.php:155
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/MakeBlockCommand.php:42
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/MakeBlockCommand.php:30
    /.../build-n98-magerun2/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
    /.../build-n98-magerun2/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php:80
    /.../build-n98-magerun2/tests/N98/Magento/Command/Developer/Console/MakeBlockCommandTest.php:20

Refs:

- #241

- Command: make:block

ktomk added a commit to ktomk/n98-magerun2 that referenced this issue Jan 24, 2017

Fix Magento object manager usage, fixes #241
The Magento 2 object manager fails with non-magento classes, like the
check classes of the sys:check command.

Fix is to add constructor injection to the injection helper and
instantiate the Magerun classes via it.

Refs:

- #241

- Command: sys:check

ktomk added a commit to ktomk/n98-magerun2 that referenced this issue Jan 24, 2017

Skip developer console command tests when in production mode
At least one developer console command is not compatible with production
mode. Therefore skipping tests when the Magento 2 instance the test is
run against is in production mode.

That one command "make:block" via it's test full output:

    There was 1 error:

    1) N98\Magento\Command\Developer\Console\MakeBlockCommandTest::testOutput
    preg_quote() expects parameter 1 to be string, object given

    /.../build-n98-magerun2/magento2/www/vendor/zendframework/zend-filter/src/Word/SeparatorToSeparator.php:94
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/AbstractGeneratorCommand.php:155
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/MakeBlockCommand.php:42
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/MakeBlockCommand.php:30
    /.../build-n98-magerun2/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
    /.../build-n98-magerun2/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php:80
    /.../build-n98-magerun2/tests/N98/Magento/Command/Developer/Console/MakeBlockCommandTest.php:20

Refs:

- #241

- Command: make:block

ktomk added a commit to ktomk/n98-magerun2 that referenced this issue Jan 24, 2017

Fix Magento object manager usage, fixes #241
The Magento 2 object manager fails with non-magento classes, like the
check classes of the sys:check command.

Fix is to add constructor injection to the injection helper and
instantiate the Magerun classes via it.

Refs:

- #241

- Command: sys:check
@ktomk

This comment has been minimized.

Show comment
Hide comment
@ktomk

ktomk Jan 24, 2017

Contributor

Sorry for the slow progress on this issue. I must admit we missed so far to run the test-suite against production mode, it was yet only running against the default.

It took some time to finally realize the culprit, add a change to testing and then fix the sys:check-sub-command creation to deal with production mode. That means, we have a fix!

Next to that some other commands which are intended for development mode (which includes default mode) needed to reflect the new testing as well by skipping the tests in production mode as a quick fix (e.g. the make:block command from the developer console generator commands suite).

Then finally I needed to get the switch to production mode running. Unfortunately Magento 2.0.x is not easy to deal with as the multi-tenant di compile has issues and for a general working way, switching the mode needed to be scripted in more detail (I don't have the best references at hand, this is an older one, I had it with 2.0.{9,10,11}: magento/magento2#4070 , the same error message as here: OptionInterfacePersistor error when compiling magento in production mode).

Contributor

ktomk commented Jan 24, 2017

Sorry for the slow progress on this issue. I must admit we missed so far to run the test-suite against production mode, it was yet only running against the default.

It took some time to finally realize the culprit, add a change to testing and then fix the sys:check-sub-command creation to deal with production mode. That means, we have a fix!

Next to that some other commands which are intended for development mode (which includes default mode) needed to reflect the new testing as well by skipping the tests in production mode as a quick fix (e.g. the make:block command from the developer console generator commands suite).

Then finally I needed to get the switch to production mode running. Unfortunately Magento 2.0.x is not easy to deal with as the multi-tenant di compile has issues and for a general working way, switching the mode needed to be scripted in more detail (I don't have the best references at hand, this is an older one, I had it with 2.0.{9,10,11}: magento/magento2#4070 , the same error message as here: OptionInterfacePersistor error when compiling magento in production mode).

@ktomk

This comment has been minimized.

Show comment
Hide comment
@ktomk

ktomk Jan 24, 2017

Contributor

I brought the fix into develop, please try with the unstable version, you should see this fixed.

Contributor

ktomk commented Jan 24, 2017

I brought the fix into develop, please try with the unstable version, you should see this fixed.

@hostep

This comment has been minimized.

Show comment
Hide comment
@hostep

hostep Jan 24, 2017

Contributor

Just checked, can confirm this is now fixed with the latest develop version.

Thanks again Tom!

Contributor

hostep commented Jan 24, 2017

Just checked, can confirm this is now fixed with the latest develop version.

Thanks again Tom!

@hostep hostep closed this Jan 24, 2017

cmuench added a commit to cmuench/n98-magerun2 that referenced this issue Oct 11, 2017

Skip developer console command tests when in production mode
At least one developer console command is not compatible with production
mode. Therefore skipping tests when the Magento 2 instance the test is
run against is in production mode.

That one command "make:block" via it's test full output:

    There was 1 error:

    1) N98\Magento\Command\Developer\Console\MakeBlockCommandTest::testOutput
    preg_quote() expects parameter 1 to be string, object given

    /.../build-n98-magerun2/magento2/www/vendor/zendframework/zend-filter/src/Word/SeparatorToSeparator.php:94
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/AbstractGeneratorCommand.php:155
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/MakeBlockCommand.php:42
    /.../build-n98-magerun2/src/N98/Magento/Command/Developer/Console/MakeBlockCommand.php:30
    /.../build-n98-magerun2/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
    /.../build-n98-magerun2/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php:80
    /.../build-n98-magerun2/tests/N98/Magento/Command/Developer/Console/MakeBlockCommandTest.php:20

Refs:

- #241

- Command: make:block

cmuench added a commit to cmuench/n98-magerun2 that referenced this issue Oct 11, 2017

Fix Magento object manager usage, fixes #241
The Magento 2 object manager fails with non-magento classes, like the
check classes of the sys:check command.

Fix is to add constructor injection to the injection helper and
instantiate the Magerun classes via it.

Refs:

- #241

- Command: sys:check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment