返回博客

如何卸载 Drupal 8.7 或更高版本中的 contrib 模块 multiversion

2021-11-092 分钟阅读

如果您计划从 Drupal 8 升级到 Drupal 9,我强烈建议您在将核心更新到最新的 9.x 版本之前,卸载 contrib 模块 multiversion

一些需要 multiversion 模块的 contrib 模块包括:DeployWorkspaceReplication。这些模块也将在此过程中自动卸载。

1. 安装 Multiversion Remover。

模块 Multiversion Remover 在此过程中起着重要作用,因此我们需要安装它:

composer require 'drupal/multiversion_remover:1.0.x-dev@dev'
drush en multiversion_remover -y

2. 删除 replication、replication_log 和 workspace 实体。
访问以下 URL 并删除所有实体:
* https://YOUR-SITE_URL/admin/modules/uninstall/entity/replication
* https://YOUR-SITE-URL/admin/modules/uninstall/entity/replication_log
* https://YOUR-SITE-URL/admin/modules/uninstall/entity/workspace

3. 实现一个 hook update。
从这个 repo 复制代码,并将其粘贴到您自定义模块的 hook update 中。

从后端清除缓存 https://YOUR-SITE-URL/admin/config/development/performance 或使用终端 drush cr

4. 运行 Drupal 更新
我们需要执行上一步中实现的 hook update,因此我们必须从浏览器 https://YOUR-SITE-URL/update.php 或使用终端 drush updb -y 运行 drupal 更新

重要提示:在更新运行时,我们需要检查之前删除的实体是否未被重新创建,否则,我们将不得不重新删除它们。

请记住,这必须在更新过程结束之前完成。
检查实体在更新运行时未被重新创建的 URL:
* https://YOUR-SITE_URL/admin/modules/uninstall/entity/replication
* https://YOUR-SITE-URL/admin/modules/uninstall/entity/replication_log
* https://YOUR-SITE-URL/admin/modules/uninstall/entity/workspace

很可能,您会收到一个错误,这是正常的。

5. 执行 multiversion remover 函数。
您需要执行以下命令来完成移除过程:

drush php-eval "multiversion_remover_uninstall_multiversion_suite()"
drush php-eval "_multiversion_remover_purge_multiversion_kvp()"

6. 卸载 Multiversion Remover 模块。
此时,Multiversion Remover 模块已完成其工作,我们可以将其从项目中移除。

drush pmu multiversion_remover -y
composer remove drupal/multiversion_remover