无法将Drupal核心升级至10.2.4(安全更新)
Drupal 10.2.4核心升级失败问题排查与解决
问题概述
尝试将Drupal核心升级至包含重要安全更新的10.2.4版本,遵循常规更新流程后仍无法完成升级。
已执行的升级命令
composer create-project drupal/recommended-project:10.2.4 "install-dir" composer update "drupal/core-*" --with-all-dependencies composer require drupal/core-recommended:10.2.4 drupal/core-composer-scaffold:10.2.4 drupal/core-project-message:10.2.4 --update-with-all-dependencies
错误信息
问题1
- 根目录composer.json要求drush/drush ^9,找到drush/drush[9.0.0-alpha1, ..., 9.x-dev],但该包被部分更新固定为10.6.2(锁文件版本),版本不匹配,请确保将其列为更新命令的参数。
问题2
- 根目录composer.json要求drupal/core-dev ^10,找到drupal/core-dev[10.0.0-alpha1, ..., 10.3.x-dev],但该包被部分更新固定为9.5.9(锁文件版本),版本不匹配,请确保将其列为更新命令的参数。
问题3
Problem 3 - drupal/core-recommended 10.0.x-dev requires drupal/core 10.0.x-dev -> found drupal/core[10.0.x-dev] but these were not loaded, likely because it conflicts with another require. - drupal/core-recommended 10.1.x-dev requires drupal/core 10.1.x-dev -> found drupal/core[10.1.x-dev] but these were not loaded, likely because it conflicts with another require. - drupal/core-recommended 10.2.x-dev requires drupal/core 10.2.x-dev -> found drupal/core[10.2.x-dev] but these were not loaded, likely because it conflicts with another require.
当前composer.json内容
{ "name": "drupalcommerce/project-base", "description": "Commerce 2.x project template", "type": "project", "license": "GPL-2.0-or-later", "authors": [ { "name": "", "role": "" } ], "repositories": { "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" }, "commerce_base": { "type": "vcs", "url": "https://github.com/drupalcommerce/commerce_base" }, "asset-packagist": { "type": "composer", "url": "https://asset-packagist.org" }, "slick": { "type": "package", "package": { "name": "library-kenwheeler/slick", "version": "dev-master", "type": "drupal-library", "source": { "url": "https://git@github.com/kenwheeler/slick.git", "type": "git", "reference": "1.6.0" }, "require": { "composer/installers": "~1.0" } } }, "oauth2-server": { "type": "git", "url": "https://github.com/thephpleague/oauth2-server.git" } }, "config": { "bin-dir": "bin", "sort-packages": true, "allow-plugins": { "cweagans/composer-patches": true, "composer/installers": true, "drupal/core-composer-scaffold": true, "drupal/core-project-message": true, "drupal/console-extend-plugin": true, "dealerdirect/phpcodesniffer-composer-installer": true, "oomphinc/composer-installers-extender": true } }, "require": { "ext-curl": "*", "ext-soap": "*", "commerceguys/addressing": "^1.4.2", "commerceguys/intl": "^1.1", "composer/installers": "^1.2", "cweagans/composer-patches": "^1.6", "drupal/address": "^1.11", "drupal/admin_toolbar": "^3.4", "drupal/auto_entitylabel": "^3.0", "drupal/blazy": "^2.23", "drupal/block_class": "^2.0", "drupal/block_field": "^1.0@RC", "drupal/commerce": "^2.31", "drupal/commerce_cart_api": "^1.7", "drupal/components": "^3", "drupal/config_filter": "^1.12", "drupal/config_ignore": "^3.2", "drupal/config_split": "^1.9", "drupal/console": "~1.9", "drupal/consumers": "^1.17", "drupal/contact_block": "^1.7", "drupal/core-composer-scaffold": "^10", "drupal/core-project-message": "^10", "drupal/core-recommended": "^10", "drupal/ctools": "^3.13", "drupal/date_popup": "^1.3", "drupal/devel": "^5.1", "drupal/entity": "^1.4", "drupal/entity_reference_revisions": "^1.11", "drupal/field_group": "^3.4", "drupal/file_entity": "^2.0@RC", "drupal/honeypot": "^2.1", "drupal/inline_entity_form": "^1.0@RC", "drupal/key": "^1.17", "drupal/mailsystem": "^4.4", "drupal/maxlength": "^2.1", "drupal/menu_link_attributes": "^1.3", "drupal/module_filter": "^4.1", "drupal/neato": "^2.0", "drupal/paragraphs": "^1.17", "drupal/pathauto": "^1.12", "drupal/profile": "^1.10", "drupal/queue_ui": "^3.1", "drupal/recommended-project": "^10", "drupal/redirect": "^1.9", "drupal/rest_export_nested": "^1.2", "drupal/restui": "^1.21", "drupal/s3fs": "^3.4", "drupal/search_api": "~1.0", "drupal/seckit": "^2.0", "drupal/slick": "^2.10", "drupal/slick_views": "^2.8", "drupal/smtp": "^1.2", "drupal/stage_file_proxy": "^1.5", "drupal/state_machine": "^1.11", "drupal/swiftmailer": "^2.4", "drupal/token": "^1.13", "drupal/tokenuuid": "^2.0", "drupal/twig_tweak": "^3.3", "drupal/username_enumeration_prevention": "^1.3", "drupal/views_extras": "^3.0", "drupalcommerce/commerce_base": "dev-8.x-1.x", "drush/drush": "^9", "library-kenwheeler/slick": "dev-master", "oomphinc/composer-installers-extender": "^2.0", "phpseclib/phpseclib": "^2.0", "vinceg/usps-php-api": "^1.0", "webflo/drupal-finder": "^1.0", "webmozart/path-util": "^2.3" }, "require-dev": { "drupal/core-dev": "^10" }, "conflict": { "drupal/drupal": "*" }, "minimum-stability": "dev", "prefer-stable": true, "autoload": { "classmap": [ "scripts/composer/ScriptHandler.php" ] }, "scripts": { "pre-install-cmd": [ "DrupalProject\\composer\\ScriptHandler::checkComposerVersion" ], "pre-update-cmd": [ "DrupalProject\\composer\\ScriptHandler::checkComposerVersion" ], "post-install-cmd": [ "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" ], "post-update-cmd": [ "DrupalProject\\composer\\ScriptHandler::createRequiredFiles" ] }, "extra": { "drupal-scaffold": { "locations": { "web-root": "web/" } }, "installer-types": [ "bower-asset", "npm-asset" ], "installer-paths": { "web/core": [ "type:drupal-core" ], "web/libraries/{$name}": [ "type:drupal-library", "type:bower-asset", "type:npm-asset", "type:drupal-console-library" ], "web/modules/contrib/{$name}": [ "type:drupal-module" ], "web/profiles/contrib/{$name}": [ "type:drupal-profile" ], "web/themes/contrib/{$name}": [ "type:drupal-theme" ], "drush/contrib/{$name}": [ "type:drupal-drush" ] }, "patches": { "drupal/commerce_cart_api": { "cart-api-clear-cart": "https://www.drupal.org/files/issues/2018-08-30/2974429-3.patch" }, "drupal/field_encrypt": { "commerce-breaks-settings-page": "https://www.drupal.org/files/issues/field_encrypt-2897256-2-commerce.patch" } } } }
解决方案
1. 修复Drush版本冲突
Drupal 10需要Drush 11及以上版本,当前composer.json要求的drush/drush:^9不兼容。执行以下命令更新Drush到兼容版本:
composer require drush/drush:^12 --update-with-all-dependencies
2. 同步drupal/core-dev版本
当前锁文件中drupal/core-dev仍为9.5.9,需同步升级到10.2.4:
composer require drupal/core-dev:10.2.4 --update-with-all-dependencies
3. 重新执行核心升级命令
将所有相关依赖纳入更新范围,确保版本一致:
composer require drupal/core-recommended:10.2.4 drupal/core-composer-scaffold:10.2.4 drupal/core-project-message:10.2.4 drupal/core-dev:10.2.4 --update-with-all-dependencies
4. 检查Commerce Base兼容性
当前使用的drupalcommerce/commerce_base:dev-8.x-1.x是Drupal 8分支,需确认是否有Drupal 10兼容的分支(如dev-10.x-1.x),替换为兼容版本后重新执行更新。
5. 移除不必要的依赖
drupal/recommended-project是项目创建模板,不应作为项目依赖存在,从composer.json的require中移除该条目后执行composer update。
内容的提问来源于stack exchange,提问作者Ömer
相关产品推荐
相关产品推荐

