baldwin-agency / magento2-module-url-data-integrity-checker

Magento 2 module which can find potential url related problems in your catalog data
MIT License
262 stars 28 forks source link

Area code is already set #34

Closed IlliaGoldin closed 2 years ago

IlliaGoldin commented 2 years ago

Magento Version: 2.2.1

Reproduce Run any of the CLI commands provided in the README.md of the module.

Result Screenshot

image

Output in text format `application@f38ef7308717:/app$ bin/magento catalog:category:integrity:urlpath An unexpected exception occured: 'Area code is already set'

0 /app/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\State->setAreaCode('crontab')

1 /app/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\State\Interceptor->___callParent('setAreaCode', Array)

2 /app/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\State\Interceptor->Magento\Framework\Interception{closure}('crontab')

3 /app/generated/code/Magento/Framework/App/State/Interceptor.php(52): Magento\Framework\App\State\Interceptor->___callPlugins('setAreaCode', Array, Array)

4 /app/app/code/Baldwin/UrlDataIntegrityChecker/Console/Command/CheckCategoryUrlPaths.php(57): Magento\Framework\App\State\Interceptor->setAreaCode('crontab')

5 /app/vendor/symfony/console/Command/Command.php(245): Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlPaths->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

6 /app/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

7 /app/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Baldwin\UrlDataIntegrityChecker\Console\Command\CheckCategoryUrlPaths), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

8 /app/vendor/magento/framework/Console/Cli.php(102): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

9 /app/vendor/symfony/console/Application.php(117): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

10 /app/bin/magento(23): Symfony\Component\Console\Application->run()

11 {main}`

Expected result List of URL path / URL key issues.

Note Admin panel version of the module works.

hostep commented 2 years ago

Hi @IlliaGoldin

We've had a report like this before and based on my earlier research, can I ask you to try to run bin/magento catalog:images:resize and see if this give you the same error or not? if you don't get an error, you can cancel this process after some seconds by pressing the ctrl+c combination on your keyboard. The reason I'm asking to run this command is because it uses similar code as in this module here where we try to set the areaCode while executing this module.

If it doesn't give you an error, I'll try it as well over here on Magento 2.2.1 first and see if I can reproduce this.

If it does give you an error, that means that the bug is most likely located in a different place. If I have to guess, you'll probably have a 3rd party module, or some custom code that tries to call setAreaCode in one of the constructors of the php classes in those modules or custom code (which is really bad). In that case try to find this and temporarily comment out that line and then try to use this module again, it should start working. Then figure out a solution for that other code to see how that can properly be handled.

Thanks!

IlliaGoldin commented 2 years ago

Hi @hostep

I have run bin/magento catalog:images:resize and it resulted in the same error "Area code is already set"

image

I also found the module responsible for this. Will be looking into how to handle this.

Thank you very much!

IlliaGoldin commented 2 years ago

Problem solved.