Skip to content

./bin/magento config:show fails with a fatal error #17582

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

Closed
simonworkhouse opened this issue Aug 14, 2018 · 9 comments
Closed

./bin/magento config:show fails with a fatal error #17582

simonworkhouse opened this issue Aug 14, 2018 · 9 comments
Assignees
Labels
Component: Config Event: khcd2018 Event: mm18pl 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.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release up for grabs

Comments

@simonworkhouse
Copy link

simonworkhouse commented Aug 14, 2018

The ./bin/magento config:show command fails with a fatal error after running ./bin/magento app:config:dump
Similar issue reported previously #16654

Preconditions

  1. Magento 2.2.5
  2. PHP 7.1.20
  3. MySQL 5.7.23

Steps to reproduce

  1. composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition {install dir}
  2. cd {install dir}
  3. ./bin/magento setup:install --backend-frontname=? --db-host=? --db-name=? --db-user=? --db-password=? --base-url=? --admin-user=? --admin-password=? --admin-email=? --admin-firstname=? --admin-lastname=?
  4. ./bin/magento app:config:dump
  5. ./bin/magento config:show

Expected result

All config data output correctly without a fatal error.

Actual result

...
catalog/productalert_cron/error_email -
catalog/product_video/play_if_base - 0
catalog/product_video/show_related - 0
catalog/product_video/video_auto_restart - 0
catalog/review/allow_guest - 1
catalog/search/engine - mysql
catalog/search/min_query_length - 1
catalog/search/max_query_length - 128
catalog/search/max_count_cacheable_search_terms - 100
analytics/subscription/enabled - 1
PHP Fatal error: Uncaught Error: Call to undefined method Magento\Config\Model\Config\Structure\Element\Group\Interceptor::hasBackendModel() in /vendor/magento/module-config/Console/Command/ConfigShow/ValueProcessor.php:100
Stack trace:
#0 /vendor/magento/module-config/Console/Command/ConfigShowCommand.php(197): Magento\Config\Console\Command\ConfigShow\ValueProcessor->process('default', '', 'Magento Analyti...', 'analytics/integ...')
#1 /vendor/magento/module-config/Console/Command/ConfigShowCommand.php(202): Magento\Config\Console\Command\ConfigShowCommand->outputResult(Object(Symfony\Component\Console\Output\ConsoleOutput), 'Magento Analyti...', 'analytics/integ...')
#2 /vendor/magento/module-config/Console/Command/ConfigShowCommand.php(202): Magento\Config\Console\Command\ConfigShow in /vendor/magento/module-config/Console/Command/ConfigShow/ValueProcessor.php on line 100

@magento-engcom-team
Copy link
Contributor

Hi @simonworkhouse. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me {$VERSION} instance

where {$VERSION} is version tags (starting from 2.2.0+) or develop branches (2.2-develop +).
For more details, please, review the Magento Contributor Assistant documentation.

@simonworkhouse do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Aug 14, 2018
@ghost ghost self-assigned this Aug 14, 2018
@ghost ghost added 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 Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Component: Config labels Aug 14, 2018
@ghost
Copy link

ghost commented Aug 14, 2018

@simonworkhouse , thank you for your report.
We've acknowledged the issue and added to our backlog.

@ghost ghost removed their assignment Aug 14, 2018
@leoquijano
Copy link

leoquijano commented Aug 21, 2018

Hi,

I also encountered this issue. My Magento version is v2.2.5. In my case, this happens when config:show tries to display the value of dashboard/use_aggregated_data from app/etc/config.php:

'system' => [
  'default' => [
     // ...
     'dashboard' => [
        'use_aggregated_data' => '0',
     ],
     // ...
  ]
]

It seems that Magento\Config\Console\Command\ConfigShow::process is assuming that the Magento\Config\Model\Config\Structure::getElementByConfigPath method will always return an instance of Magento\Config\Model\Config\Structure\Element\Field:

public function process($scope, $scopeCode, $value, $path)
{
    // ...
    /** @var Field $field */
    $field = $configStructure->getElementByConfigPath($path);

    /** @var Value $backendModel */
    $backendModel = $field && $field->hasBackendModel()
        ? $field->getBackendModel()
        : $this->configValueFactory->create();

    // ...
}

However, it actually returns an instance of \Magento\Config\Model\Config\Structure\ElementInterface (note the @return PHPDoc tag):

/**
 * Find element by config path
 *
 * @param string $path The configuration path
 * @return \Magento\Config\Model\Config\Structure\ElementInterface|null
 * @since 100.2.0
 */
public function getElementByConfigPath($path)
{
    $allPaths = $this->getFieldPaths();

    if (isset($allPaths[$path])) {
        $path = array_shift($allPaths[$path]);
    }

    return $this->getElementByPathParts(explode('/', $path));
}

In the case of dashboard/use_aggregated_data, the returned element is actually an instance of Magento\Config\Model\Config\Structure\Element\Group, which doesn't have the hasBackendModel method. This triggers a fatal error by PHP.

A fix could be either adjusting the process field to handle group elements, or making getElementByConfigPath only return field elements. A quick workaround while the bug gets fixed is to remove the offending entry from app/etc/config:

 'dashboard' => [
    'use_aggregated_data' => '0',
 ],

If the entry is required to be there, then a temporary adjustment to the process method above might help.

@max-a-mdmitriev
Copy link

#khcd2018

@magento-engcom-team
Copy link
Contributor

@max-a-mdmitriev thank you for joining. Please accept team invitation here and self-assign the issue.

@keyurshah070
Copy link
Contributor

I am working on #mm18pl

@magento-engcom-team
Copy link
Contributor

@keyurshah070 thank you for joining. Please accept team invitation here and self-assign the issue.

@magento-engcom-team
Copy link
Contributor

Hi @simonworkhouse. Thank you for your report.
The issue has been fixed in #17993 by @keyurshah070 in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Sep 24, 2018
magento-engcom-team added a commit that referenced this issue Sep 24, 2018
…error #17993

 - Merge Pull Request #17993 from keyurshah070/magento2:fix-config-show
 - Merged commits:
   1. ae503f6
@slavvka
Copy link
Member

slavvka commented Oct 3, 2018

Hi @simonworkhouse. Thank you for your report.
The issue has been fixed in #18295 by @mage2pratik in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

@slavvka slavvka added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Oct 3, 2018
magento-engcom-team added a commit that referenced this issue Oct 3, 2018
… with a fatal error #18295

 - Merge Pull Request #18295 from mage2pratik/magento2:2.3-develop-PR-port-17993
 - Merged commits:
   1. 20af5a9
magento-engcom-team pushed a commit that referenced this issue Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Config Event: khcd2018 Event: mm18pl 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.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release up for grabs
Projects
None yet
Development

No branches or pull requests

6 participants