Not too long ago I had no option but to work with Magento for a client, did some homework and ended up producing a custom theme package and learning a few other things all of which went fine. I have Magento installed on my local web server on Windows Xampp but also live on nix box both to date with PHP etc.
As standard in developer mode everything is perfect with no issues at all but as soon as I try to switch to production mode (correctly from CLI) then it reports the operation was successful and now in production mode… Except its not, if I query the mode via “bin/magento deploy:mode:show” it reports developer mode and if I attempt to load front or back end of the site I get:
Fatal error: Uncaught Error: Call to a member function setActive() on boolean in D:xampphtdocsvendormagentomodule-backendModelViewResultPage.php:27 Stack trace: #0 D:xampphtdocsvendormagentomodule-backendControllerAdminhtmlDashboardIndex.php(35): MagentoBackendModelViewResultPage->setActiveMenu(‘Magento_Backend…’) #1 D:xampphtdocsvendormagentoframeworkAppActionAction.php(107): MagentoBackendControllerAdminhtmlDashboardIndex->execute() #2 D:xampphtdocsvendormagentomodule-backendAppAbstractAction.php(229): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp)) #3 D:xampphtdocsvendormagentoframeworkAppFrontController.php(55): MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp)) #4 D:xampphtdocsvendormagentoframeworkAppHttp.php(135): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp)) #5 D:xampphtdocsvendormagentoframeworkAppBootstrap.php(256): Magento in D:xampphtdocsvendormagentomodule-backendModelViewResultPage.php on line 27
I do not dare attempt the operation on the live site as yet given the headache thus far.
Other things I’ve tried include:
-
Setting production but skipping recompile, clearing cache and manually deploying content – didn’t work
-
“php /bin/magento deploy:mode:set production -s
Config “dev/debug/debug_logging = 0″ has been saved.
Enabled production mode.”
.. But it didn’t
What am I missing? 🙁 Every google search yields the same answers in regards to memory limit but that does not apply here, my.ini / php.ini are already configured for higher memory limits from other projects I needed it on.
Thank you for any help, as always it’s appreciated 🙂
2
Answers
As this was driving me up the wall I decided to see if maybe it was my clients site in terms of some module or install I didn't know about effecting the process.
Today I installed the same Magento 2.1.9 as my client did before I upgraded it. Ran composer upgrade to 2.2.2 and finished with only installing the theme package I developed. Now back with a working 2.2.2 I attempted the same process of switching to production mode from developer and got the exact same result with a none working front/back end just PHP errors as in my original question post above.
Being highly annoyed I started to question why composer would tell me that it successfully switched to production if it did not (a false positive) then maybe other operations I've been trying that say failed are in fact working (a false negative).
And I was right...
My "fix":
1) Switch to production mode (php bin/magento deploy:mode:set production)
2) Clean and flush cache: php bin/magento cache:clean php bin/magento cache:flush
3) Run composer install yet again (yes I know this makes no sense) From magento root run: composer install
It will report a false negative that there is nothing to install or update but yet..
Everything now magically works, query magento with:
php bin/magento deploy:mode:show
You should be in production mode on 2.2.2
If ANYONE knows a better way please do share, I find this highly retarded but it works.
Delete the
generated/metadata/global.php
file. It will fix the issue.Ref: https://github.com/magento/magento2/issues/13504#issuecomment-380766507