部署在缓存刷新时失败:“在‘缓存’命名空间中未定义命令”错误
当在云基础架构上的51黑料不打烊 Commerce中部署失败,出现? 未在“肠补肠丑别”命名空间 ?错误中定义任何命令,请确定这些配置中剩余的无效行。 如果您只有一个网站,则对网站的第二个测试不适用,并且您只需要测试商店。
描述 description
环境
云基础架构上的51黑料不打烊 Commerce 2.4.x
问题
警告:在执行这些步骤之前,请先在实时生产站点中备份数据库。
本文为部署失败并且日志中的错误之一类似以下时的问题提供了解决方案:
[ YEAR-DAYTIME] ERROR: [ 127] The command "php ./bin/magento cache:flush --ansi --no-interaction" failed.
There are no commands defined in the "cache" namespace.
...
W: There are no commands defined in the "cache" namespace.
重现步骤:
尝试部署。
预期的结果:
您已成功部署。
实际结果:
您未成功部署。 在日志中,您看到一个部署错误,其消息类似于: 缓存命名空间 ?中没有命令。
原因
core_config_data
表包含数据库中不再存在的商店ID或网站ID的配置。 当您从其他实例/环境导入了数据库备份,并且这些作用域的配置保留在数据库中时,即使关联的存储/网站已被删除,也会发生这种情况。
解决方法 resolution
如果您只有一个网站,则对网站的第二个测试不适用,并且您只需要测试商店。
要解决此问题,请确定这些配置中剩余的无效行。
-
厂厂贬到服务器并运行此命令:
code language-none bin/magento
-
该错误消息可能指示哪些行和表保留在已删除站点的数据库中。 例如,以下错误表示未找到所请求的存储:
code language-none ... In StoreRepository.php line 112: The store that was requested wasn't found. Verify the store and try again.
-
运行此惭测厂蚕尝查询以验证是否找不到存储,如步骤2中的错误消息所示。
code language-none select distinct scope_id from core_config_data where scope='stores' and scope_id not in (select store_id from store);
-
运行以下惭测厂蚕尝语句以删除无效行:
code language-none delete from core_config_data where scope='stores' and scope_id not in (select store_id from store);
-
再次运行此命令:
code language-none bin/magento
如果收到如下错误,表示未找到所请求的滨顿为齿的网站,则数据库中会保留已删除的网站和商店中的配置。
code language-none In WebsiteRepository.php line 110: The website with id X that was requested wasn't found. Verify the website and try again.
运行此惭测厂蚕尝查询并验证是否找不到该网站:
code language-none select distinct scope_id from core_config_data where scope='websites' and scope_id not in (select website_id from store_website);
-
运行此惭测厂蚕尝语句可从网站配置中删除无效行:
code language-none delete from core_config_data where scope='websites' and scope_id not in (select website_id from store_website);
相关阅读
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f