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

No surprises in production mode #7659

Closed
fooman opened this issue Dec 2, 2016 · 10 comments
Closed

No surprises in production mode #7659

fooman opened this issue Dec 2, 2016 · 10 comments

Comments

@fooman
Copy link
Contributor

fooman commented Dec 2, 2016

Preconditions

  1. Any Magento 2.x version

Steps to reproduce

  1. Create a module with the same code as mentioned in issue Compilation enforces coupling to parent class Context contents #6114
  2. Test and install the module in 'developer' mode
  3. Enable production mode / run bin/magento setup:di:compile

Expected result

  1. Error message "RedirectFactory already exists in context object" is thrown in 'developer' mode

Actual result

  1. Error message only appears when enabling production mode.

This is problematic as it is unexpected. As a developer I would expect the developer mode to scream at me with any issue that I might face in production mode. Any error that is not coming up in developer mode but only appears in production mode creates the real potential of code tripping up sites that are live sites.

@antonkril
Copy link
Contributor

Integrity test \Magento\Test\Integrity\Di\CompilerTest runs same checks as compiler. This is not exactly what you requested, but the test will help detect the issue on your #2 test stage.

That said, this check should be removed.

@fooman
Copy link
Contributor Author

fooman commented Dec 7, 2016

@antonkril great to hear that this is being improved. Just to provide some more context around this. The main problem is that the compiler with the above check applied is not run in developer mode and you can end up with something like this:

1.) Install the following extension https://github.com/fooman/CompilerProdVsDev with
php -f vendor/bin/composer config repositories.fooman-compiler-prod-vs-dev vcs https://github.com/fooman/CompilerProdVsDev.git
php -f vendor/bin/composer require fooman/compiler-prod-vs-dev-m2
php -f bin/magento module:enable Fooman_CompilerProdVsDev
php -f bin/magento setup:upgrade

2.) "Test" the extension by opening http://example.com/foomancompilerprodvsdev/example
Observe it is working as expected (OK displayed)

3.) Run php -f bin/magento deploy:mode:set production

Actual Result

$:/var/www$ php -f bin/magento deploy:mode:set production
Enabled maintenance mode
Static content deployment start
Requested languages: en_US
=== frontend -> Magento/blank -> en_US ===
.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Successful: 1985 files; errors: 0
---

=== frontend -> Magento/luma -> en_US ===
..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Successful: 2058 files; errors: 0
---

=== adminhtml -> Magento/backend -> en_US ===
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Successful: 1864 files; errors: 0
---

=== Minify templates ===
.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Successful: 849 files modified
---

New version of deployed files: 1481078965
Static content deployment complete
Start compilation
Command returned non-zero exit code:
`php -f /var/www/bin/magento setup:di:compile-multi-tenant 2>&1`

This leaves the store offline as it is still in maintenance mode and in a semi compiled state. This is particularly bad for any one installing through the Web Setup Wizard as they don't have any means of recovery without resorting to command line.

@shiftedreality
Copy link
Member

Hi @fooman

On develop branch current flow does not break Magento deployment.
It only displays incorrect dependencies.
Could you please try to reproduce it on the latest version?

@fooman
Copy link
Contributor Author

fooman commented Jan 6, 2017

@shiftedreality tested with 2d6bb43 and I am getting

Compilation was started.
%message% 0/7 [>---------------------------]   0% 1 sec 50.0 MiB%message% 0/7 [>---------------------------]   0% 1 sec 50.0 MiBProxies code generation... 0/7 [>---------------------------]   0% 1 sec 50.0 MiB
Proxies code generation... 1/7 [====>-----------------------]  14% 1 sec 56.0 MiB
Repositories code generation... 1/7 [====>-----------------------]  14% 1 sec 56.0 MiB
Repositories code generation... 2/7 [========>-------------------]  28% 12 secs 162.0 MiB
Service data attributes generation... 2/7 [========>-------------------]  28% 12 secs 162.0 MiB
Service data attributes generation... 3/7 [============>---------------]  42% 12 secs 162.0 MiB
Application code generator... 3/7 [============>---------------]  42% 12 secs 162.0 MiB
Application code generator... 4/7 [================>-----------]  57% 32 secs 182.0 MiB
Interceptors generation... 4/7 [================>-----------]  57% 32 secs 182.0 MiB
Interceptors generation... 5/7 [====================>-------]  71% 55 secs 200.0 MiB
Area configuration aggregation... 5/7 [====================>-------]  71% 55 secs 200.0 MiB
Area configuration aggregation... 6/7 [========================>---]  85% 2 mins 274.0 MiB
Interception cache generation... 6/7 [========================>---]  85% 2 mins 274.0 MiBErrors during compilation:
	Fooman\CompilerProdVsDev\Controller\Example\Index
		Incorrect dependency in class Fooman\CompilerProdVsDev\Controller\Example\Index in /var/www/magento2/vendor/fooman/compiler-prod-vs-dev-m2/src/Controller/Example/Index.php
\Magento\Framework\Controller\Result\RedirectFactory already exists in context object
Total Errors Count: 1
Errors during compilation:
	Fooman\CompilerProdVsDev\Controller\Example\Index
		Incorrect dependency in class Fooman\CompilerProdVsDev\Controller\Example\Index in /var/www/magento2/vendor/fooman/compiler-prod-vs-dev-m2/src/Controller/Example/Index.php
\Magento\Framework\Controller\Result\RedirectFactory already exists in context object

which is much better as it doesn't take the store down.

The above error message was repeated quite a few times when 1 would have been sufficient.
I also suggest changing the wording to a warning as it works.

@KrystynaKabannyk
Copy link

Hello @fooman, we couldn't reproduce the issue on 2.0.13 and 2.1.5. If there is still the issue, please provide additional info and specific version.

@grafikchaos
Copy link

grafikchaos commented Mar 14, 2017

Still an issue in Magento CE 2.1.5

Our Magento is installed via composer but the Magenest_QuickBooksDesktop module is committed to our repository. When we do a deploy to the remote server this is the error we get during the bin/magento -- setup:di:compile task

Compilation was started.
Proxies code gene…-------------------------]   0% 1 sec 56.0 MiB
Repositories code generation... 1/7 [====>-----------------------… 1 sec 60.0 MiB
Service data attributes generation... 2/7 [========>------…------]  28% 9 secs 168.0 MiB
Application code generator... 3/7 [============>----…==>---------------]  42% 9 secs 168.0 MiB
Interceptors generation... 4/7 [================>----------…---]  57% 23 secs 186.0 MiB
Area configuration aggregation... 5/7 [====================>--…71% 42 secs 210.0 MiB
Interception cache generation... 6/7 [=================…=======>---]  85% 57 secs 292.0 MiB
Errors during compilation:
      01 	Magenest\QuickBooksDesktop\Controller\Connection\Start
      01 	Incorrect dependency in class Magenest\QuickBooksDesktop\Controller\Connection\Start in /chroot/home/mastersu/master-supplements.com/staging/releases/20170314224825/app/code/Magenest/QuickBooksDesktop/Controller/Connection/Start.php

\Magento\Framework\Controller\Result\RedirectFactory already exists in context object
      01 \Magento\Framework\Controller\Result\RedirectFactory already exists in context object
      01 Total Errors Count: 1
      01 Errors during compilation:
      01 	Magenest\QuickBooksDesktop\Controller\Connection\Start
      01 	Incorrect dependency in class Incorrect dependency in class Magenest\QuickBooksDesktop\Controller\Connection\Start in /chroot/home/mastersu/master-supplements.com/staging/releases/20170314224825/app/code/Magenest/QuickBooksDesktop/Controller/Connection/Start.php
      01 \Magento\Framework\Controller\Result\RedirectFactory already exists in context object
      01 Total Errors Count: 1
      01 Errors during compilation:
      01 	Magenest\QuickBooksDesktop\Controller\Connection\Start
      01 	Incorrect dependency in class Incorrect dependency in class Magenest\QuickBooksDesktop\Controller\Connection\Start in /chroot/home/mastersu/master-supplements.com/staging/releases/20170314224825/app/code/Magenest/QuickBooksDesktop/Controller/Connection/Start.php
      01 \Magento\Framework\Controller\Result\RedirectFactory already exists in context object
      01 Total Errors Count: 1
Interception cache generation... 7/7 [===================…========] 100% 2 mins 292.0 MiB

@Vinai
Copy link
Contributor

Vinai commented Mar 21, 2017

Cross reference to PR #8955

@KrystynaKabannyk
Copy link

hi @fooman, the issue is reproducible, the internal ticket is created MAGETWO-66539.

@maghamed
Copy link
Contributor

maghamed commented May 5, 2017

closing this issue as PR #8955 which addresses this problem merged into mainline

@maghamed maghamed self-assigned this May 5, 2017
@maghamed
Copy link
Contributor

maghamed commented May 5, 2017


@maghamed maghamed closed this as completed May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants