每次我尝试启用或禁用任何模块时,Magento 2 都会崩溃

Magento 2 crashes every time I try to Enable or Disable any modules

我有 Magento 2.3.3,它托管在 MageMojo Stratus 上。

每次我尝试安装、启用或禁用任何模块时,前端都可以正常工作,但我在管理面板中收到无法恢复的错误:

<b>Fatal error</b>:  Uncaught Error: Call to a member function getNext() on null in /srv/public_html/generated/code/Magento/User/Model/User/Interceptor.php:529
Stack trace:
#0 /srv/public_html/vendor/magento/module-backend/Model/Locale/Manager.php(96): Magento\User\Model\User\Interceptor-&gt;getInterfaceLocale()
#1 /srv/public_html/vendor/magento/module-backend/Model/Locale/Resolver.php(77): Magento\Backend\Model\Locale\Manager-&gt;getUserInterfaceLocale()
#2 /srv/public_html/vendor/magento/framework/Locale/Resolver.php(83): Magento\Backend\Model\Locale\Resolver-&gt;setLocale(NULL)
#3 /srv/public_html/vendor/magento/module-backend/Model/Locale/Resolver.php(60): Magento\Framework\Locale\Resolver-&gt;__construct(Object(Magento\Framework\App\Config), 'general/locale/...', 'store', NULL)
#4 /srv/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(116): Magento\Backend\Model\Locale\Resolver-&gt;__construct(Object(Magento\Framework\App\Config), 'general/locale/...', 'store', Object(Magento\Backend\Model\Session\Interceptor) in <b>/srv/public_html/generated/code/Magento/User/Model/User/Interceptor.php</b> on line <b>529</b><br />

我已经尝试了众所周知的以下步骤以及我能想到的所有可能的变体:

magento maintenance:enable
magento cache:disable
rm -rf generated/ var/view_preprocessed/ var/composer_home/cache/ var/cache/ var/page_cache/
magento setup:upgrade
composer install
magento setup:di:compile
magento setup:static-content:deploy -f
magento indexer:reindex
magento cache:flush
magento cache:enable
magento maintenance:disable

看来这个问题有两个方面:

  1. 要正确删除所有生成的内容,命令应该是:
rm -rf generated/* var/di/* var/cache/* var/page_cache/* var/view_preprocessed/* var/composer_home/cache/* pub/static/*
  1. 在 MageMojo 的 Mojo Stratus 托管上,您需要同时清除 Varnish 缓存、Redis 缓存、PHP OP-Cache 和 AWS CloudFront 存储。服务器上有一个帮助程序 cli 工具,您可以使用:
...
php bin/magento cache:flush
/usr/share/stratus/cli cache.all.clear