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

Fix start errors without database connection #125

Conversation

fredden
Copy link
Contributor

@fredden fredden commented Jan 4, 2024

Summary

While working on a website which has this module installed, I was unable to import a database with n98-magerun2. Steps to reproduce are as follows:

  1. Start with a running / confirmed-working Magento2 instance
  2. Install this extension via Composer: composer require justbetter/magento2-sentry && bin/magento setup:upgrade
  3. Confirm that Magento still works.
  4. Print out database connection details: n98-magerun2 db:info
  5. Drop the database: n98-magerun2 db:drop Note that this will destroy data; ensure you have a back-up of any valuable information. An alternative here would be to change some database connection details in app/etc/env.php.
  6. Print out database connection details: n98-magerun2 db:info

The actual steps which lead to this discovery are to get a Magento code-base installed, and run n98-magerun2 db:import ... in a fresh / blank environment (in order to create a new staging website). The above steps are enough to show the problem.

Result

Before the changes in this pull request, an exception is thrown.

Exception details including stack trace
app@7f7f0307c964:~/html$ vendor/bin/n98-magerun2 db:info -v
Magento Core Commands cannot be loaded. Please verify if "bin/magento" is running.
Only n98-magerun2 commands are available until the issue is fixed.

In Mysql.php line 603:
                                                                                                                                                                                                                                   
  [Magento\Framework\DB\Adapter\TableNotFoundException (1146)]                                                                                                                                                                     
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2.mag_theme' doesn't exist, query was: SELECT `main_table`.* FROM `mag_theme` AS `main_table` WHERE (`area` = 'frontend') AND (`theme_path` = 'OnTap/burton')  
                                                                                                                                                                                                                                   

Exception trace:
  at /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:603
 Magento\Framework\DB\Adapter\Pdo\Mysql->_query() at /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:634
 Magento\Framework\DB\Adapter\Pdo\Mysql->query() at /var/www/html/generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php:95
 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->query() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:737
 Zend_Db_Adapter_Abstract->fetchAll() at /var/www/html/generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php:1085
 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/Db/FetchStrategy/Query.php:21
 Magento\Framework\Data\Collection\Db\FetchStrategy\Query->fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:782
 Magento\Framework\Data\Collection\AbstractDb->_fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:677
 Magento\Framework\Data\Collection\AbstractDb->getData() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:446
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getData() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:580
 Magento\Framework\Data\Collection\AbstractDb->loadWithFilter() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:428
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->loadWithFilter() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:565
 Magento\Framework\Data\Collection\AbstractDb->load() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:419
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->load() at /var/www/html/vendor/magento/framework/Data/Collection.php:300
 Magento\Framework\Data\Collection->getFirstItem() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:563
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getFirstItem() at /var/www/html/vendor/magento/module-theme/Model/ResourceModel/Theme/Collection.php:146
 Magento\Theme\Model\ResourceModel\Theme\Collection->getThemeByFullPath() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:86
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getThemeByFullPath() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Proxy.php:151
 Magento\Theme\Model\ResourceModel\Theme\Collection\Proxy->getThemeByFullPath() at /var/www/html/vendor/magento/module-theme/Model/Config/Processor/DesignTheme.php:80
 Magento\Theme\Model\Config\Processor\DesignTheme->changeThemeFullPathToIdentifier() at /var/www/html/vendor/magento/module-theme/Model/Config/Processor/DesignTheme.php:54
 Magento\Theme\Model\Config\Processor\DesignTheme->process() at /var/www/html/generated/code/Magento/Theme/Model/Config/Processor/DesignTheme/Proxy.php:95
 Magento\Theme\Model\Config\Processor\DesignTheme\Proxy->process() at /var/www/html/vendor/magento/framework/App/Config/PreProcessorComposite.php:35
 Magento\Framework\App\Config\PreProcessorComposite->process() at /var/www/html/vendor/magento/module-config/App/Config/Type/System/Reader.php:60
 Magento\Config\App\Config\Type\System\Reader->read() at /var/www/html/generated/code/Magento/Config/App/Config/Type/System/Reader/Proxy.php:95
 Magento\Config\App\Config\Type\System\Reader\Proxy->read() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:395
 Magento\Config\App\Config\Type\System->readData() at /var/www/html/vendor/magento/framework/Cache/LockGuardedCacheLoader.php:136
 Magento\Framework\Cache\LockGuardedCacheLoader->lockedLoadData() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:281
 Magento\Config\App\Config\Type\System->loadDefaultScopeData() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:207
 Magento\Config\App\Config\Type\System->getWithParts() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:181
 Magento\Config\App\Config\Type\System->get() at /var/www/html/vendor/magento/framework/App/Config.php:132
 Magento\Framework\App\Config->get() at /var/www/html/generated/code/Magento/Framework/App/Config/Interceptor.php:50
 Magento\Framework\App\Config\Interceptor->get() at /var/www/html/vendor/magento/framework/App/Config.php:80
 Magento\Framework\App\Config->getValue() at /var/www/html/generated/code/Magento/Framework/App/Config/Interceptor.php:23
 Magento\Framework\App\Config\Interceptor->getValue() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:198
 JustBetter\Sentry\Helper\Data->collectModuleConfig() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:102
 JustBetter\Sentry\Helper\Data->__construct() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:170
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:276
 Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:239
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/Interception/PluginList/PluginList.php:174
 Magento\Framework\Interception\PluginList\PluginList->getPlugin() at /var/www/html/vendor/magento/framework/Interception/Interceptor.php:133
 N98\Magento\Framework\App\Magerun\Interceptor->Magento\Framework\Interception\{closure}() at /var/www/html/vendor/magento/framework/Interception/Interceptor.php:153
 N98\Magento\Framework\App\Magerun\Interceptor->___callPlugins() at /var/www/html/generated/code/N98/Magento/Framework/App/Magerun/Interceptor.php:23
 N98\Magento\Framework\App\Magerun\Interceptor->launch() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application/Magento2Initializer.php:63
 N98\Magento\Application\Magento2Initializer->init() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:278
 N98\Magento\Application->initMagento() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/MagentoHelper.php:401
 N98\Util\Console\Helper\MagentoHelper->initBaseConfig() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/MagentoHelper.php:385
 N98\Util\Console\Helper\MagentoHelper->getBaseConfig() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/DatabaseHelper.php:71
 N98\Util\Console\Helper\DatabaseHelper->detectDbSettings() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php:63
 N98\Magento\Command\Database\AbstractDatabaseCommand->detectDbSettings() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/Database/InfoCommand.php:52
 N98\Magento\Command\Database\InfoCommand->execute() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/AbstractMagentoCommand.php:249
 N98\Magento\Command\AbstractMagentoCommand->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:254
 N98\Magento\Application->doRun() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:363
 N98\Magento\Application->run() at /var/www/html/vendor/n98/magerun2-dist/n98-magerun2:8
 include() at /var/www/html/vendor/bin/n98-magerun2:119

In Mysql.php line 109:
                                                                                                                                                                                                                                   
  [Zend_Db_Statement_Exception (42)]                                                                                                                                                                                               
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2.mag_theme' doesn't exist, query was: SELECT `main_table`.* FROM `mag_theme` AS `main_table` WHERE (`area` = 'frontend') AND (`theme_path` = 'OnTap/burton')  
                                                                                                                                                                                                                                   

Exception trace:
  at /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:109
 Magento\Framework\DB\Statement\Pdo\Mysql->tryExecute() at /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91
 Magento\Framework\DB\Statement\Pdo\Mysql->_execute() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement.php:313
 Zend_Db_Statement->execute() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:480
 Zend_Db_Adapter_Abstract->query() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:238
 Zend_Db_Adapter_Pdo_Abstract->query() at /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:564
 Magento\Framework\DB\Adapter\Pdo\Mysql->_query() at /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:634
 Magento\Framework\DB\Adapter\Pdo\Mysql->query() at /var/www/html/generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php:95
 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->query() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:737
 Zend_Db_Adapter_Abstract->fetchAll() at /var/www/html/generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php:1085
 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/Db/FetchStrategy/Query.php:21
 Magento\Framework\Data\Collection\Db\FetchStrategy\Query->fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:782
 Magento\Framework\Data\Collection\AbstractDb->_fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:677
 Magento\Framework\Data\Collection\AbstractDb->getData() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:446
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getData() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:580
 Magento\Framework\Data\Collection\AbstractDb->loadWithFilter() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:428
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->loadWithFilter() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:565
 Magento\Framework\Data\Collection\AbstractDb->load() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:419
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->load() at /var/www/html/vendor/magento/framework/Data/Collection.php:300
 Magento\Framework\Data\Collection->getFirstItem() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:563
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getFirstItem() at /var/www/html/vendor/magento/module-theme/Model/ResourceModel/Theme/Collection.php:146
 Magento\Theme\Model\ResourceModel\Theme\Collection->getThemeByFullPath() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:86
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getThemeByFullPath() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Proxy.php:151
 Magento\Theme\Model\ResourceModel\Theme\Collection\Proxy->getThemeByFullPath() at /var/www/html/vendor/magento/module-theme/Model/Config/Processor/DesignTheme.php:80
 Magento\Theme\Model\Config\Processor\DesignTheme->changeThemeFullPathToIdentifier() at /var/www/html/vendor/magento/module-theme/Model/Config/Processor/DesignTheme.php:54
 Magento\Theme\Model\Config\Processor\DesignTheme->process() at /var/www/html/generated/code/Magento/Theme/Model/Config/Processor/DesignTheme/Proxy.php:95
 Magento\Theme\Model\Config\Processor\DesignTheme\Proxy->process() at /var/www/html/vendor/magento/framework/App/Config/PreProcessorComposite.php:35
 Magento\Framework\App\Config\PreProcessorComposite->process() at /var/www/html/vendor/magento/module-config/App/Config/Type/System/Reader.php:60
 Magento\Config\App\Config\Type\System\Reader->read() at /var/www/html/generated/code/Magento/Config/App/Config/Type/System/Reader/Proxy.php:95
 Magento\Config\App\Config\Type\System\Reader\Proxy->read() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:395
 Magento\Config\App\Config\Type\System->readData() at /var/www/html/vendor/magento/framework/Cache/LockGuardedCacheLoader.php:136
 Magento\Framework\Cache\LockGuardedCacheLoader->lockedLoadData() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:281
 Magento\Config\App\Config\Type\System->loadDefaultScopeData() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:207
 Magento\Config\App\Config\Type\System->getWithParts() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:181
 Magento\Config\App\Config\Type\System->get() at /var/www/html/vendor/magento/framework/App/Config.php:132
 Magento\Framework\App\Config->get() at /var/www/html/generated/code/Magento/Framework/App/Config/Interceptor.php:50
 Magento\Framework\App\Config\Interceptor->get() at /var/www/html/vendor/magento/framework/App/Config.php:80
 Magento\Framework\App\Config->getValue() at /var/www/html/generated/code/Magento/Framework/App/Config/Interceptor.php:23
 Magento\Framework\App\Config\Interceptor->getValue() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:198
 JustBetter\Sentry\Helper\Data->collectModuleConfig() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:102
 JustBetter\Sentry\Helper\Data->__construct() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:170
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:276
 Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:239
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/Interception/PluginList/PluginList.php:174
 Magento\Framework\Interception\PluginList\PluginList->getPlugin() at /var/www/html/vendor/magento/framework/Interception/Interceptor.php:133
 N98\Magento\Framework\App\Magerun\Interceptor->Magento\Framework\Interception\{closure}() at /var/www/html/vendor/magento/framework/Interception/Interceptor.php:153
 N98\Magento\Framework\App\Magerun\Interceptor->___callPlugins() at /var/www/html/generated/code/N98/Magento/Framework/App/Magerun/Interceptor.php:23
 N98\Magento\Framework\App\Magerun\Interceptor->launch() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application/Magento2Initializer.php:63
 N98\Magento\Application\Magento2Initializer->init() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:278
 N98\Magento\Application->initMagento() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/MagentoHelper.php:401
 N98\Util\Console\Helper\MagentoHelper->initBaseConfig() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/MagentoHelper.php:385
 N98\Util\Console\Helper\MagentoHelper->getBaseConfig() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/DatabaseHelper.php:71
 N98\Util\Console\Helper\DatabaseHelper->detectDbSettings() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php:63
 N98\Magento\Command\Database\AbstractDatabaseCommand->detectDbSettings() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/Database/InfoCommand.php:52
 N98\Magento\Command\Database\InfoCommand->execute() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/AbstractMagentoCommand.php:249
 N98\Magento\Command\AbstractMagentoCommand->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:254
 N98\Magento\Application->doRun() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:363
 N98\Magento\Application->run() at /var/www/html/vendor/n98/magerun2-dist/n98-magerun2:8
 include() at /var/www/html/vendor/bin/n98-magerun2:119

In Mysql.php line 90:
                                                                                                
  [PDOException (42S02)]                                                                        
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2.mag_theme' doesn't exist  
                                                                                                

Exception trace:
  at /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:90
 PDOStatement->execute() at /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:90
 Magento\Framework\DB\Statement\Pdo\Mysql->Magento\Framework\DB\Statement\Pdo\{closure}() at /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:106
 Magento\Framework\DB\Statement\Pdo\Mysql->tryExecute() at /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91
 Magento\Framework\DB\Statement\Pdo\Mysql->_execute() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement.php:313
 Zend_Db_Statement->execute() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:480
 Zend_Db_Adapter_Abstract->query() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:238
 Zend_Db_Adapter_Pdo_Abstract->query() at /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:564
 Magento\Framework\DB\Adapter\Pdo\Mysql->_query() at /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:634
 Magento\Framework\DB\Adapter\Pdo\Mysql->query() at /var/www/html/generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php:95
 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->query() at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:737
 Zend_Db_Adapter_Abstract->fetchAll() at /var/www/html/generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php:1085
 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/Db/FetchStrategy/Query.php:21
 Magento\Framework\Data\Collection\Db\FetchStrategy\Query->fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:782
 Magento\Framework\Data\Collection\AbstractDb->_fetchAll() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:677
 Magento\Framework\Data\Collection\AbstractDb->getData() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:446
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getData() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:580
 Magento\Framework\Data\Collection\AbstractDb->loadWithFilter() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:428
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->loadWithFilter() at /var/www/html/vendor/magento/framework/Data/Collection/AbstractDb.php:565
 Magento\Framework\Data\Collection\AbstractDb->load() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:419
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->load() at /var/www/html/vendor/magento/framework/Data/Collection.php:300
 Magento\Framework\Data\Collection->getFirstItem() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:563
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getFirstItem() at /var/www/html/vendor/magento/module-theme/Model/ResourceModel/Theme/Collection.php:146
 Magento\Theme\Model\ResourceModel\Theme\Collection->getThemeByFullPath() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Interceptor.php:86
 Magento\Theme\Model\ResourceModel\Theme\Collection\Interceptor->getThemeByFullPath() at /var/www/html/generated/code/Magento/Theme/Model/ResourceModel/Theme/Collection/Proxy.php:151
 Magento\Theme\Model\ResourceModel\Theme\Collection\Proxy->getThemeByFullPath() at /var/www/html/vendor/magento/module-theme/Model/Config/Processor/DesignTheme.php:80
 Magento\Theme\Model\Config\Processor\DesignTheme->changeThemeFullPathToIdentifier() at /var/www/html/vendor/magento/module-theme/Model/Config/Processor/DesignTheme.php:54
 Magento\Theme\Model\Config\Processor\DesignTheme->process() at /var/www/html/generated/code/Magento/Theme/Model/Config/Processor/DesignTheme/Proxy.php:95
 Magento\Theme\Model\Config\Processor\DesignTheme\Proxy->process() at /var/www/html/vendor/magento/framework/App/Config/PreProcessorComposite.php:35
 Magento\Framework\App\Config\PreProcessorComposite->process() at /var/www/html/vendor/magento/module-config/App/Config/Type/System/Reader.php:60
 Magento\Config\App\Config\Type\System\Reader->read() at /var/www/html/generated/code/Magento/Config/App/Config/Type/System/Reader/Proxy.php:95
 Magento\Config\App\Config\Type\System\Reader\Proxy->read() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:395
 Magento\Config\App\Config\Type\System->readData() at /var/www/html/vendor/magento/framework/Cache/LockGuardedCacheLoader.php:136
 Magento\Framework\Cache\LockGuardedCacheLoader->lockedLoadData() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:281
 Magento\Config\App\Config\Type\System->loadDefaultScopeData() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:207
 Magento\Config\App\Config\Type\System->getWithParts() at /var/www/html/vendor/magento/module-config/App/Config/Type/System.php:181
 Magento\Config\App\Config\Type\System->get() at /var/www/html/vendor/magento/framework/App/Config.php:132
 Magento\Framework\App\Config->get() at /var/www/html/generated/code/Magento/Framework/App/Config/Interceptor.php:50
 Magento\Framework\App\Config\Interceptor->get() at /var/www/html/vendor/magento/framework/App/Config.php:80
 Magento\Framework\App\Config->getValue() at /var/www/html/generated/code/Magento/Framework/App/Config/Interceptor.php:23
 Magento\Framework\App\Config\Interceptor->getValue() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:198
 JustBetter\Sentry\Helper\Data->collectModuleConfig() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:102
 JustBetter\Sentry\Helper\Data->__construct() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:170
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:276
 Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:239
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/Interception/PluginList/PluginList.php:174
 Magento\Framework\Interception\PluginList\PluginList->getPlugin() at /var/www/html/vendor/magento/framework/Interception/Interceptor.php:133
 N98\Magento\Framework\App\Magerun\Interceptor->Magento\Framework\Interception\{closure}() at /var/www/html/vendor/magento/framework/Interception/Interceptor.php:153
 N98\Magento\Framework\App\Magerun\Interceptor->___callPlugins() at /var/www/html/generated/code/N98/Magento/Framework/App/Magerun/Interceptor.php:23
 N98\Magento\Framework\App\Magerun\Interceptor->launch() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application/Magento2Initializer.php:63
 N98\Magento\Application\Magento2Initializer->init() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:278
 N98\Magento\Application->initMagento() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/MagentoHelper.php:401
 N98\Util\Console\Helper\MagentoHelper->initBaseConfig() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/MagentoHelper.php:385
 N98\Util\Console\Helper\MagentoHelper->getBaseConfig() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Util/Console/Helper/DatabaseHelper.php:71
 N98\Util\Console\Helper\DatabaseHelper->detectDbSettings() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/Database/AbstractDatabaseCommand.php:63
 N98\Magento\Command\Database\AbstractDatabaseCommand->detectDbSettings() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/Database/InfoCommand.php:52
 N98\Magento\Command\Database\InfoCommand->execute() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/AbstractMagentoCommand.php:249
 N98\Magento\Command\AbstractMagentoCommand->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:1058
 Symfony\Component\Console\Application->doRunCommand() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:254
 N98\Magento\Application->doRun() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Application.php:363
 N98\Magento\Application->run() at /var/www/html/vendor/n98/magerun2-dist/n98-magerun2:8
 include() at /var/www/html/vendor/bin/n98-magerun2:119

db:info [--connection CONNECTION] [--format [FORMAT]] [--] [<setting>]

app@7f7f0307c964:~/html$ 

With the changes in this pull request, we can successfully import a database with n98-magerun2.

The changes here include:

  • Only load configuration (successfully) once. If the initial load fails, it will be re-tried as per existing behaviour. This is a performance improvement.
  • Catch Magento\Framework\DB\Adapter\TableNotFoundException when attempting to load configuration values. This is the bug-fix / reason for this pull request.

The changes in this pull request are best viewed with "ignore white-space" enabled as the indentation of some lines has changes, but their content has not.

@fredden fredden force-pushed the hotfix/unable-to-load-database-with-n98-magerun2 branch from 9522302 to e0efd41 Compare January 4, 2024 15:39
@royduin
Copy link
Member

royduin commented Mar 13, 2024

@indykoning

Copy link
Member

@indykoning indykoning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I can't wait to get this merged in.
I think this suggestion might help with readability a little bit as it reduces the nesting

Helper/Data.php Outdated Show resolved Hide resolved
Helper/Data.php Outdated Show resolved Hide resolved
@fredden fredden force-pushed the hotfix/unable-to-load-database-with-n98-magerun2 branch from 3f5ec2a to e4295a3 Compare March 18, 2024 12:24
@fredden fredden force-pushed the hotfix/unable-to-load-database-with-n98-magerun2 branch from e4295a3 to cb88741 Compare March 18, 2024 12:33
@indykoning indykoning changed the title Allow initial import of database with n98-magerun2 Fix start errors without database connection Mar 18, 2024
@indykoning indykoning merged commit 5783bbe into justbetter:master Mar 18, 2024
2 checks passed
@indykoning
Copy link
Member

We've released it under 3.5.2 🚀
Thank you for this fix!

@fredden fredden deleted the hotfix/unable-to-load-database-with-n98-magerun2 branch March 18, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants