You are here

Drupal专业开发指南 第21章 创建和应用补丁

g089h515r806 的头像
Submitted by g089h515r806 on 星期四, 2009-09-03 13:44

Think in Drupal

如果你想修正bug,或者想测试一下他人的潜在的bug修正,或者由于这个或者那个原因需要修改核心代码,那么此时你就开始需要创建或者应用一个补丁了。一个补丁就是用户和计算机都可读的一个文本文件,它根据对Drupal代码资源库所做修改,为用户显示逐行的报告。补丁是由diff(或 cvs diff)程序生成的,我们在前面的“追踪Drupal代码变更”一节中,已经看到了一个例子。
 
创建一个补丁
    下面是补丁的示例,它用来整理includes/common.inc中t()函数的文档:
 
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.591
diff -u -r1.591 common.inc
--- includes/common.inc 28 Mar 2007 07:03:33 -0000 1.591
+++ includes/common.inc 28 Mar 2007 18:43:18 -0000
@@ -639,7 +639,7 @@
 *
 * Special variables called "placeholders" are used to signal dynamic
  * information in a string, which should not be translated. Placeholders
- * can also be used for text that that may change from time to time
+ * can also be used for text that may change from time to time
 * (such as link paths) to be changed without requiring updates to translations.
 *
 * For example:
 
    在对includes/common.inc文件做了修改以后,开发者在Drupal根路径下运行下面的命令:
 
cvs diff -up > common.inc_50.patch
 
    这个命令获得cvs diff的输出,并将其放到名为common.inc_50.patch的新文件中。接着开发者访问drupal.org,并在这里报告bug:http://drupal.org/node/100232
 

Drupal版本: