跳转到主要内容
你行网

Main navigation

  • 首页
  • Drupal
  • 编程与开发
  • 数据库
  • 操作系统与应用
  • 服务器与运维
  • 社区
User account menu
  • 登录

面包屑

  1. 首页

如何使用composer在drupal 8中应用补丁

由 hrs, 16 五月, 2022

Sometimes, when we use a contrib module in Drupal, we encounter a bug. Chances are that someone has already fixed it and contributed a patch to the Drupal community.

有时,当我们在Drupal中使用contrib模块时,会遇到一个错误。 很有可能有人已经修复它并为Drupal社区贡献了补丁。

First, let’s assume our site root folder is /var/www/public/drupal_site.

首先,假设我们的站点根文件夹为/ var / www / public / drupal_site 。

This example will patch the module Scroll to destination anchors (https://www.drupal.org/project/scroll_to_destination_anchors)

此示例将修补模块滚动到目标锚点 ( https://www.drupal.org/project/scroll_to_destination_anchors )

These are the steps to apply a patch to a module using Composer:

这些是使用Composer将补丁应用到模块的步骤:

使用Composer添加模块 (Add the module with Composer)

To download the module to our site, all we have to do is run this command in a terminal while being in the site root folder:

要将模块下载到我们的站点,我们要做的就是在站点根目录中的终端中运行以下命令:

composer require drupal/scroll_to_destination_anchors

作曲家需要drupal / scroll_to_destination_anchors

This command will download the module to /var/www/public/drupal_site/modules or /var/www/public/drupal_site/modules/contrib (if we have created this directory, which is recommended).

此命令会将模块下载到/ var / www / public / drupal_site / modules或/ var / www / public / drupal_site / modules / contrib (如果我们已创建此目录,建议使用)。

查找补丁 (Find a patch)

Finding a patch for the module is easy. It can be done from the module page (see example link above). There’s a column that says: “Issues for XXX”, in my example case “Issues for Scroll to destination anchors”.

查找模块的补丁很容易。 可以从模块页面完成(请参见上面的示例链接)。 有一列显示为:“ XXX的问题”,在我的示例中为“滚动到目标锚点的问题”。

This is the issue I was having:

这是我遇到的问题:

https://www.drupal.org/project/scroll_to_destination_anchors/issues/2916996

https://www.drupal.org/project/scroll_to_destination_anchors/issues/2916996

And there’s a patch for it already:

并且已经有一个补丁:

https://www.drupal.org/files/issues/2018-04-18/stda-working_for_84-2916996-8_0.patch

https://www.drupal.org/files/issues/2018-04-18/stda-working_for_84-2916996-8_0.patch

应用补丁 (Apply the patch)

To apply the patch to the contrib module, we have to edit the composer.json file in the site root folder.

要将补丁应用到contrib模块,我们必须在站点根文件夹中编辑composer.json文件。

Then look for this line: “enable-patching”: “true”,

然后查找以下行: “ enable-patching”:“ true”,

Then add something like this after it:

然后在其后添加如下内容:

"patches": {    "drupal/scroll_to_destination_anchors": {        "Working for 8.4?": "https://www.drupal.org/files/issues/2018-04-18/stda-working_for_84-2916996-8_0.patch"    }}

This is the structure:

结构如下:

"patches": {    "drupal/module_machine_name": {        "Description of the issue": "Path to patch in Drupal.org"    }}

And you will end up with something like this:

您将得到如下结果:

"extra": {    "drupal-scaffold": {        "locations": {            "web-root": "./"        }    },    "installer-paths": {        "core": [            "type:drupal-core"        ],        "libraries/{$name}": [            "type:drupal-library",            "type:bower-asset",            "type:npm-asset"        ],        "modules/contrib/{$name}": [            "type:drupal-module"        ],        "profiles/contrib/{$name}": [            "type:drupal-profile"        ],        "themes/contrib/{$name}": [            "type:drupal-theme"        ],        "drush/Commands/contrib/{$name}": [            "type:drupal-drush"        ],        "modules/custom/{$name}": [            "type:drupal-custom-module"        ],        "themes/custom/{$name}": [            "type:drupal-custom-theme"        ]    },    "drupal-core-project-message": {        "include-keys": [            "homepage",            "support"        ],        "post-create-project-cmd-message": [            "<bg=blue;fg=white>                                                         </>",            "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",            "<bg=blue;fg=white>  from the drupal/legacy-project template!               </>",            "<bg=blue;fg=white>                                                         </>",            "",            "<bg=yellow;fg=black>Next steps</>:",            "  * Install the site: https://www.drupal.org/docs/8/install",            "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",            "  * Get support: https://www.drupal.org/support",            "  * Get involved with the Drupal community:",            "      https://www.drupal.org/getting-involved",            "  * Remove the plugin that prints this message:",            "      composer remove drupal/core-project-message"        ]    },    "installer-types": [        "bower-asset",        "npm-asset"    ],    "patchLevel": {        "drupal/core": "-p2"    },    "enable-patching": "true","patches": {        "drupal/scroll_to_destination_anchors": {            "Working for 8.4?": "https://www.drupal.org/files/issues/2018-04-18/stda-working_for_84-2916996-8_0.patch"        }    }}

Then, all we have to do is run:

然后,我们要做的就是运行:

composer update

作曲家更新

And that’s it. The module will be downloaded and the patch automatically applied.

就是这样。 该模块将被下载并自动应用补丁。

  • 登录或注册以发表评论

文章标签

  • drupal 8

评论

文章标签

CSS
Excel
ubuntu
php
五笔
vim
Linux
VPN
command
HTML
drupal 8
drupal 7
centos
composer
Mysql
drush
Drupal
模块(module)
JavaSrcipt
apache
drupal 9
英语
nerdtree
SEO
network
果树种植
surround
drupal10
主题(theme)
ssh
phpmyadmin
yum
二进制
权限
声音
ssl
selinux
HTML5
password
Dreamweaver
flameshot
翻译
颜色
DDEV
uploadprogress
WireGuard
kernel
firewalld
视图(views)
快捷键
gzip
xdebug
错误
邮件验证
电脑基础
ckeditor
简介
mbstring
源地址
C语言
certbot
php扩展
git
httpd
apt
压缩解压
电子秤
表单
breadcrumb
AI
csharp
短信验证
superfish
摄影
重定向
diff
网站备份
tagclouds
docker
java
drupal 11
adsense
版本号
电脑技巧
RSS
simple_adsense
算法
端口
youtube
JavaScript
cookie
badblocks
计算机基础
网站运营
RFID
VUE
gimp
form
zip
dns
标签优化
mod_expires 模块
赚钱
ip
http验证
curl
重定向,301
netstat
字段
maven
input
npm
nginx
哈希值
wps
KVM
更多

相关文章

drupal8 配置cron任务
迁移到您的搜索引擎优化的Drupal 8网站
Drupal 8的https域名重定向优化301重定向
如何给drupal 8 修复打补丁
drupal 8 网站遇到意外错误,请稍后再试。
drupal 8 使用flippy模块实现文章上一篇下一篇功能解决方案
drupal 8 安装提示未启用php apcu 和 PECL uploadprogress 插件
drupal 8 安装提示信任主机设置
drupal 8 安装提示权限安全风险
drupal 8 安装提示缺少php opcode 缓存插件
drupal 8 安装提示配置文件不存在
drupal 8 安装提示没有files 文件
drupal 8 可信主机设置
Drupal 8.7.6 安装详解图文教程
如何Drupal 8 修改上传文件限制
drupal 8 如何发布一篇文章
drupal8 HTTPS - 其他设置/修改
drupal8 simple xml sitemap配置和使用
drupal8 安装扩展出现上传错误
drupal8 升级后出现下列错误,提示模组丢失。
RSS源

友情链接 网站地图 版权信息 联系我们 网址导航 & 社交媒体链接

Copyright © 2019 - 2021 你行网 版权所有  粤ICP备19072650号