大家好,我的 Magento 2 Store 出现错误。例如 API 请求失败,Swagger 给出 500,样式表和 JS 文件无法加载等。
最后,我找到了使用新主题文件创建新 Magento 安装的最佳解决方案,只需复制 pub/media
从文件并使用维护模式删除所有以 customers_
为前缀的表, catalog_
, sales_
和 eav_
这一步使我的新商店工作得很好,但我遇到了新的错误..我无法运行 setup:upgrade
它显示一条消息:
[PDOException] SQLSTATE[HY000]: General error: 1823 Failed to add the foreign key constraint 'porosec_pororom/CAT_CTGR_PRD_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID' to system tables
运行时出错
php -f bin/magento setup:db-schema:upgrade
上一条消息发生的命令
也当我跑
composer update
它更新了许多依赖项,但它需要运行 setup:upgrade
.Swagger 错误 500
{"0":"Please upgrade your database: Run \"bin/magento setup:upgrade\" from the Magento root directory.\nThe following modules are outdated:\nKlarna_Core data: current version - 4.1.5, required version - 4.2.3\nKlarna_Ordermanagement data: current version - 4.1.2, required version - 4.1.3","1":"#0 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(121): Magento\Framework\Module\Plugin\DbStatusValidator->beforeDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Magento\Framework\App\Request\Http))\n#1 /home/porosec/public_html/test/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#2 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))\n#3 /home/porosec/public_html/test/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#4 /home/porosec/public_html/test/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)\n#5 /home/porosec/public_html/test/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#6 /home/porosec/public_html/test/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()\n#7 /home/porosec/public_html/test/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()\n#8 /home/porosec/public_html/test/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#9 {main}","url":"/test/swagger","script_name":"/test/index.php"}
Swagger 错误日志
这也是我在管理仪表板中得到的
管理面板错误
[2018-06-04 23:18:09] main.CRITICAL: Report ID: webapi-5b15c8b17792e; Message: Class "array" does not exist. Please note that namespace must be specified. {"exception":"[object] (Exception(code: 0): Report ID: webapi-5b15c8b17792e; Message: Class \"array\" does not exist. Please note that namespace must be specified. at /home/porosec/public_html/test/vendor/magento/framework/Webapi/ErrorProcessor.php:205, LogicException(code: 0): Class \"array\" does not exist. Please note that namespace must be specified. at /home/porosec/public_html/test/vendor/magento/framework/Reflection/TypeProcessor.php:139)"} []
管理面板错误日志
最佳答案
如果你备份了同一张表,如果外键约束和bkp表一样,当前表mysql会抛出异常,那么修改约束名或者删除现有的约束。
约束名称不应相同。
关于Magento 2 SQLSTATE [HY000] : General error: 1823 Failed to add the foreign key constraint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50690185/