dependency-updates
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDependency Updates for Drupal with Composer
使用Composer进行Drupal依赖更新
Use when:
- Checking which packages are outdated
- Updating Drupal core to a newer minor or patch release
- Updating contrib modules or libraries
- Resolving composer version conflicts after an update
适用场景:
- 检查哪些包已过时
- 将Drupal核心更新至较新的次要版本或补丁版本
- 更新contrib模块或库
- 更新后解决Composer版本冲突
Before You Start — Create a Branch
开始之前——创建分支
This step is mandatory. Do not run any composer commands until a new branch is created and confirmed. Never update packages directly onormain.master
Check the current branch first:
bash
git branch --show-currentIf the user is on , , or any protected branch, stop and ask: "What would you like to name the new branch for these updates?"
mainmasterSuggest a default if they are unsure (e.g., ).
deps/drupal-updates-YYYY-MM-DDbash
git checkout -b <branch-name>Confirm the new branch is active before proceeding:
bash
git branch --show-currentOnly continue to the next step once the output confirms a non-protected branch.
此步骤为必填项。在创建并确认新分支之前,请勿运行任何Composer命令。 切勿直接在或main分支上更新包。master
首先检查当前分支:
bash
git branch --show-current如果用户处于、或任何受保护分支,请停止操作并询问:"您希望为这些更新命名新分支的名称是什么?"
mainmaster如果用户不确定,可提供默认建议(例如:)。
deps/drupal-updates-YYYY-MM-DDbash
git checkout -b <branch-name>继续下一步之前,请确认新分支已激活:
bash
git branch --show-current只有当输出确认当前为非受保护分支时,才可继续。
Check for Outdated Packages
检查过时包
bash
composer outdatedShows all packages with newer versions available. Columns: current version → latest available.
bash
composer outdated显示所有有可用新版本的包。列内容为:当前版本 → 最新可用版本。
Check only direct dependencies
仅检查直接依赖
bash
composer outdated --directbash
composer outdated --directCheck a specific package
检查特定包
bash
composer outdated drupal/core-recommendedbash
composer outdated drupal/core-recommendedUpdate a Specific Package
更新特定包
bash
composer update drupal/package --with-all-dependenciesbash
composer update drupal/package --with-all-dependenciesUpdate multiple packages at once
同时更新多个包
bash
composer update drupal/package1 drupal/package2 --with-all-dependenciesbash
composer update drupal/package1 drupal/package2 --with-all-dependenciesUpdate Drupal Core (Minor or Patch)
更新Drupal核心(次要版本或补丁)
Drupal core is split across multiple packages. Update all together:
bash
composer update drupal/core-recommended drupal/core-composer-scaffold drupal/core-project-message --with-all-dependenciesNote: Minor upgrades (e.g., 10.2 → 10.3) may require relaxing the version constraint infirst:composer.jsonjson"drupal/core-recommended": "^10.3"Then run the update command above.
Drupal核心分为多个包,需一起更新:
bash
composer update drupal/core-recommended drupal/core-composer-scaffold drupal/core-project-message --with-all-dependencies注意: 次要版本升级(例如:10.2 → 10.3)可能需要先放宽中的版本约束:composer.jsonjson"drupal/core-recommended": "^10.3"然后运行上述更新命令。
Verify the installed version
验证已安装版本
bash
composer show drupal/core | grep versionsbash
composer show drupal/core | grep versionsUpdate All Packages
更新所有包
Update everything within existing constraints:
composer.jsonbash
composer updateThis updatesbut will not change version constraints incomposer.lock. Packages pinned to an older major will not cross that boundary.composer.json
在现有约束范围内更新所有内容:
composer.jsonbash
composer update此命令会更新,但不会修改composer.lock中的版本约束。固定为旧主版本的包不会跨版本更新。composer.json
Update All Drupal Contrib Modules
更新所有Drupal Contrib模块
bash
composer update "drupal/*" --with-all-dependenciesbash
composer update "drupal/*" --with-all-dependenciesResolving Conflicts
解决冲突
"Your requirements could not be resolved"
"无法满足您的需求"
Find what is blocking the update:
bash
undefined查找阻碍更新的因素:
bash
undefinedWhat requires the package you're trying to update?
哪些包依赖您尝试更新的包?
composer why drupal/package
composer why drupal/package
What prevents the target version?
哪些因素阻止目标版本的安装?
composer why-not drupal/package 2.x
Adjust the conflicting constraint in `composer.json` and retry.composer why-not drupal/package 2.x
调整`composer.json`中的冲突约束后重试。Conflict between two contrib modules
两个contrib模块之间的冲突
bash
undefinedbash
undefinedCheck full dependency chain
检查完整依赖链
composer depends drupal/module-a
composer depends drupal/module-b
Update both together to let composer find a compatible set:
```bash
composer update drupal/module-a drupal/module-b --with-all-dependenciescomposer depends drupal/module-a
composer depends drupal/module-b
同时更新两个模块,让Composer找到兼容的版本组合:
```bash
composer update drupal/module-a drupal/module-b --with-all-dependenciesRevert a bad update
回滚错误更新
If introduced a regression, restore the previous lock file from version control and reinstall:
composer updatebash
git checkout composer.lock
composer install如果引入了问题,从版本控制中恢复之前的锁文件并重新安装:
composer updatebash
git checkout composer.lock
composer installVerify the Update
验证更新
bash
undefinedbash
undefinedConfirm installed versions
确认已安装版本
composer show drupal/core-recommended
composer show --outdated
Run `composer audit` after any update to confirm no new advisories were introduced:
```bash
composer auditAfter verification, always ask the user these questions in order:1. "Do you want to commit these changes?"
- If yes:
bashgit add composer.json composer.lock git commit -m "Update Drupal dependencies"- If no → remind the user that
andcomposer.jsonare uncommitted before proceeding.composer.lock2. "Do you want to deploy these changes to an Acquia environment?"
- If yes → follow the Drupal Update and Deploy playbook to push code, switch the environment, and optionally trigger a pipeline build.
- If no → done.
composer show drupal/core-recommended
composer show --outdated
更新后运行`composer audit`,确认未引入新的安全警告:
```bash
composer audit验证完成后,请按顺序询问用户以下问题:1. "您是否要提交这些更改?"
- 如果是:
bashgit add composer.json composer.lock git commit -m "Update Drupal dependencies"- 如果否 → 在继续操作前提醒用户
和composer.json存在未提交更改。composer.lock2. "您是否要将这些更改部署到Acquia环境?"
- 如果是 → 遵循**Drupal更新与部署手册**推送代码、切换环境,并可选择触发流水线构建。
- 如果否 → 操作完成。
Troubleshooting
故障排除
| Problem | Command |
|---|---|
| Update ignored — package still old | Check constraint in |
| Run |
| Unexpected packages changed | Review |
| Memory limit error | |
| 问题 | 解决命令/方法 |
|---|---|
| 更新被忽略——包版本仍为旧版 | 检查 |
更新后 | 运行 |
| 出现意外的包变更 | 提交前查看 |
| 内存限制错误 | |
Related
相关内容
- Security Updates — Fix specific vulnerability advisories
- 安全更新 — 修复特定漏洞警告