Magento2: Website broken when enable custom module in magento 2.2.2 CLI

Created on 8 Mar 2018  Â·  14Comments  Â·  Source: magento/magento2


Preconditions


  1. Magento Version 2.2.2
  2. PHP 7.0.25
  3. Ubuntu 16.04 server at DigitalOcean.
  4. MySQL 14.14

Steps to reproduce

  1. I follow this instruction to create simple module https://www.mageplaza.com/magento-2-module-development/
  2. After I run this command php bin/magento module:enable Mageplaza_HelloWorld then I reload my browser and get the error: "An error happened during application run. Check exception log"
  3. Then I comment out this line in .htaccess "SetEnv MAGE_MODE developer" then I get this error on browser:
    Exception: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 in /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61 Stack trace: #0 /var/www/html/vendor/magento/module-config/App/Config/Type/System.php(248): MagentoFrameworkAppErrorHandler->handler(8, 'Undefined index...', '/var/www/html/v...', 248, Array) #1 /var/www/html/vendor/magento/module-config/App/Config/Type/System.php(192): MagentoConfigAppConfigTypeSystem->cacheData(Array) #2 /var/www/html/vendor/magento/module-config/App/Config/Type/System.php(152): MagentoConfigAppConfigTypeSystem->loadDefaultScopeData('default') #3 /var/www/html/vendor/magento/framework/App/Config.php(131): MagentoConfigAppConfigTypeSystem->get('default/newreli...') #4 /var/www/html/vendor/magento/framework/App/Config.php(80): MagentoFrameworkAppConfig->get('system', 'default/newreli...') #5 /var/www/html/vendor/magento/module-new-relic-reporting/Model/Config.php(91): MagentoFrameworkAppConfig->getValue('newrelicreporti...') #6 /var/www/html/vendor/magento/module-new-relic-reporting/Plugin/HttpPlugin.php(49): MagentoNewRelicReportingModelConfig->isNewRelicEnabled() #7 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(121): MagentoNewRelicReportingPluginHttpPlugin->beforeCatchException(Object(MagentoFrameworkAppHttpInterceptor), Object(MagentoFrameworkAppBootstrap), Object(Exception)) #8 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppHttpInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppBootstrap), Object(Exception)) #9 /var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php(39): MagentoFrameworkAppHttpInterceptor->___callPlugins('catchException', Array, Array) #10 /var/www/html/vendor/magento/framework/App/Bootstrap.php(261): MagentoFrameworkAppHttpInterceptor->catchException(Object(MagentoFrameworkAppBootstrap), Object(Exception)) #11 /var/www/html/index.php(39): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor)) #12 {main}
  4. Now I already removed module folder and files app/code/* but still get that error.

Actual result

  1. [Screenshot, logs]
    In var/log/exception.log
    [2018-03-08 08:08:59] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:09:06] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:09:14] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:09:19] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:11:37] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:11:42] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:14:25] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:22:58] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:23:04] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:23:11] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:23:16] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:23:48] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:23:53] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:26:29] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:26:33] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:26:37] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 08:26:40] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 19:13:39] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []
    [2018-03-08 19:13:42] main.CRITICAL: Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: websites in /var/www/html/vendor/magento/module-config/App/Config/Type/System.php on line 248 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []

    Any ideas ?
Cannot Reproduce Format is not valid

Most helpful comment

Hi,
I fixed this issue. Somehow when I install custom module It overwrites my app/etc/env.php file to
return 1
=> solution I copied the sample env.php then modify some info to match with the server including: admin url, database name, database username, password
then It worked.

All 14 comments

Hi,
I fixed this issue. Somehow when I install custom module It overwrites my app/etc/env.php file to
return 1
=> solution I copied the sample env.php then modify some info to match with the server including: admin url, database name, database username, password
then It worked.

@duytran21
Can you please help me with a bit more detail, I am running in the exact same error when I run magento setup:upgrade:
Notice: Undefined index: websites in /home/playsports/public_html/magento2/vendor/magento/module-config/App/Config/Type/System.php on line 248

after I did:
magento module:disable Dotdigitalgroup_Email
From your resolution I can't follow exactly how to fix my issue. Thank you.

I am also getting this when i compile:
Then I ran:
magento setup:di:compile

And now I am getting

Compilation was started.
Interceptors generation... 4/7 [================>-----------]  57% 6 secs 188.0 MiB

  [Exception]
  Warning: array_replace_recursive(): Argument #1 is not an array in /home/playsports/public_html/magento2/vendor/magento/framework/App/DeploymentConfig/Writer.php on line 135


setup:di:compile

hi @mikeguy,
Did you check your env.php in app/etc/ yet? How does it look like? Can you post it ?
Usually we messed up with module installation somehow magento overwrite it with without any configuration. IMO you should check env.php first. Are you able to run php bin/magento in your terminal?

@duytran21
/home/playsports/public_html/magento2/app/etc
env.php
this is all there is in it:

<?phpreturn 1;

Here is my solution:

  1. You need to completely remove that module file and folder from your system if that your custome module. Then let check in app/etc/config.php to see does it exist in the file if exist then remove that line.
  2. Next step you should run php bin/magento setup:upgrade.
  3. Check your env.php in app/etc/. if you don't see any configuration info such as db, admin, url ... that's mean there is something wrong with your env.php file you need to copy it from another site then config it match with your database and url.

yup that's mean it has wrong info. Here is sample:
copy it to env.php file and set the info match with your system.

<?php return array ( 'backend' => array ( 'frontName' => 'admin_abc', ), 'crypt' => array ( 'key' => '1e78289eec442c6b6afc044ac75a07e5', ), 'db' => array ( 'table_prefix' => '', 'connection' => array ( 'default' => array ( 'host' => 'localhost', 'dbname' => 'magento', 'username' => 'magento', 'password' => '', 'active' => '1', ), ), ), 'resource' => array ( 'default_setup' => array ( 'connection' => 'default', ), ), 'x-frame-options' => 'SAMEORIGIN', 'MAGE_MODE' => 'developer', 'session' => array ( 'save' => 'files', ), 'cache_types' => array ( 'config' => 1, 'layout' => 1, 'block_html' => 1, 'collections' => 1, 'reflection' => 1, 'db_ddl' => 1, 'eav' => 1, 'customer_notification' => 1, 'config_integration' => 1, 'config_integration_api' => 1, 'full_page' => 1, 'translate' => 1, 'config_webservice' => 1, ), 'install' => array ( 'date' => 'Thu, 08 Feb 2018 01:52:53 +0000', ), );

@duytran21
thank you so much for the reply

I will try the above and let you know.

Username and password for your phpadmin database.

2018-03-20 18:13 GMT-07:00 Mike notifications@github.com:

@duytran21 https://github.com/duytran21
the username and password is for what ? the admin backend?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/magento/magento2/issues/14018#issuecomment-374809054,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKW6_LvarQCtofunvUqi5Coz-71I6mwuks5tgak0gaJpZM4SjPlS
.

--

Yours sincerely,

Duy Tran

@duytran21

yes it was the env.php file that was corrupted.
I have re-built it and now everything seems fine.
Somehow the env.php got corrupted when I disabled a module or added another one as I was building my store.

Thank you very much.

It's may by retailed with NewRelicReporting configuration, in my trace i see too NewRelicReporting:

Exception: Notice: Undefined index: websites in vendor/magento/module-config/App/Config/Type/System.php on line 248 in vendor/magento/framework/App/ErrorHandler.php:61
        Stack trace:
#0 vendor/magento/module-config/App/Config/Type/System.php(248): Magento\Framework\App\ErrorHandler-&gt;handler(8, 'Undefined index...', '/home/veluvia/w...', 248, Array)
#1 vendor/magento/module-config/App/Config/Type/System.php(192): Magento\Config\App\Config\Type\System-&gt;cacheData(Array)
#2 vendor/magento/module-config/App/Config/Type/System.php(152): Magento\Config\App\Config\Type\System-&gt;loadDefaultScopeData('default')
#3 vendor/magento/framework/App/Config.php(131): Magento\Config\App\Config\Type\System->get('default/newreli...')
#4 vendor/magento/framework/App/Config.php(80): Magento\Framework\App\Config->get('system', 'default/newreli...')
#5 vendor/magento/module-new-relic-reporting/Model/Config.php(91): Magento\Framework\App\Config->getValue('newrelicreporti...')
#6 vendor/magento/module-new-relic-reporting/Plugin/HttpPlugin.php(49): Magento\**NewRelicReporting**\Model\Config->isNewRelicEnabled()
#7 vendor/magento/framework/Interception/Interceptor.php(121): Magento\NewRelicReporting\Plugin\HttpPlugin->beforeCatchException(Object(Magento\Framework\App\Http\Interceptor), Object(Magento\Framework\App\Bootstrap), Object(Exception))
#8 vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Bootstrap), Object(Exception))
#9 generated/code/Magento/Framework/App/Http/Interceptor.php(39): Magento\Framework\App\Http\Interceptor->___callPlugins('catchException', Array, Array)
#10 vendor/magento/framework/App/Bootstrap.php(261): Magento\Framework\App\Http\Interceptor->(Object(Magento\Framework\App\Bootstrap), Object(Exception))
#11 index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#12 {main}

@chrom Unfortunately this stack trace doesn't seem to be indicating the problem. It would be great if you included steps to reproduce and preconditions as well.

It seems that this is not related to NewRelicReporting, I'm not sure I can reproduce this error now. But I guess there is a problem and the reason is not clear yet.

@duytran21, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.

Was this page helpful?
0 / 5 - 0 ratings