成为 MediaWiki 的贡献者

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page How to become a MediaWiki hacker and the translation is 64% complete.

Outdated translations are marked like this.
Other languages:
Bahasa Indonesia • ‎Deutsch • ‎English • ‎Nederlands • ‎Tiếng Việt • ‎Türkçe • ‎dansk • ‎español • ‎français • ‎interlingua • ‎italiano • ‎magyar • ‎occitan • ‎polski • ‎português • ‎português do Brasil • ‎română • ‎svenska • ‎Ελληνικά • ‎български • ‎русский • ‎српски / srpski • ‎українська • ‎العربية • ‎فارسی • ‎हिन्दी • ‎বাংলা • ‎ਪੰਜਾਬੀ • ‎ไทย • ‎中文 • ‎日本語 • ‎한국어

这篇文章用以帮助开发者学习开发MediaWik 内核和MediaWiki扩展的基础技能。 请注意,多数情况下,你并不想去随便删改MediaWiki的内核,除非你真的知道你在干什么!






MediaWiki由PHP语言编写。[1] 它使用jQuery作为JavaScript的客户端库。

MediaWiki首先是为LAMP平台编写[2] ,并且在多数操作系统中是可用的。 MediaWiki首要使用MySQL与MariaDB数据库服务器.[3]


本页可以帮助您成为MediaWiki的贡献者。 此入門教學,而是引導您至不同任何您覺得必要學習的內容。


大多数项目使用Git和Gerrit。按照Gerrit指南来创建您的开发者帐号。 然後你可以去下載我們的代碼,做出改變,測試他們,然後提交補丁。



  • 安裝Vagrant——這些步驟會安裝MediaWiki伺服器於所有符合需求的Linux虛擬機器(可用於Linux、Windows,或Mac hosts)

Docker development environment


  • 安裝需求 — 檢查硬體需求後,請安裝LAMP、MAMP或WAMP伺服器(Linux、Mac或Windows、plus Apache、MySQL/MariaDB與PHP)。
  • 从Git下载 — 於Git下載最新版的原始碼。
  • 手册:安装指南 — 繼續安裝與初始化設定。
  • 架設不同的偵錯模式於您的環境,以提早顯示警告與錯誤。

您不必下載維基百科數據庫資料即可開發MediaWiki功能。 實際上,大部分情況下使用一個幾乎為空的數據庫,裡面只有一些特定的測試頁,會更簡單。 然而,如果由於某種原因你仍想複製維基百科,你可以下載資料


当一个开发者修复MediaWiki的漏洞时,你可以观察他,包括他如何开展调查,执行git commit命令,如何使漏洞被再查以及修复,如何关闭Bugzilla表单或者现在取代Bugzilla的Phabricator


  • You are expected to do some basic research yourself first: Look at the code, try to get some understanding what it is supposed to do, read related documentation, try to find the probable place(s) where you need to make changes in order to fix the bug.
  • If you have general questions which are not tied to the specific task that you want to work on, use generic channels like Wikimedia Developer Support, IRC or mailing lists but not the specific task.
  • If you have a specific question about the bug itself, comment in the corresponding bug report (normally a task in Phabricator ). "Can you give me more info how to fix this bug?" is not a good question to start with: The more specific your questions are, the more likely somebody can answer them quickly. If you have no idea at all how to fix the bug, maybe that bug is not (yet) for you - please consider finding an easier one first.
  • When asking, explain what you have tried and found out already, so others can help at the right level. Be specific - for example, copy and paste your commands and their output (if not too long) instead of paraphrasing in your own words. 这避免了误解。


  • Be patient when seeking input and comments. 在IRC上, 有什么问题直接问,无须问有没有人在: 在IRC上的多数问题通常也可以被其他社区成员解决(即使有人不在)。 如果没人回答,请基于漏洞报告与问题相关的维基页面继续提问,不要放弃。
  • 聯繫交流 了解更多。
  • 你也可以在Freenode IRC下#wikimedia-tech channel中的每周技术建议IRC会议上提出任何问题。


You do not need to ask if you can work on a task. You do not need to announce your plans before you start working on a bug, but it would be welcome. You are welcome to set yourself as the assignee in a task: Use the dropdown Add Action… → Assign/Claim in Phabricator. At the latest when you are close to proposing a patch for the task, it is good to announce in a comment that you are working on it. Your announcement helps others to not work on the bug at the same time and to not duplicate work.

Also note that if a task already has a recent link to a patch in Gerrit and has the project "Patch-For-Review" associated in Phabricator, choose a different task to work on instead - avoid duplicating work. If an existing patch in Gerrit has not been merged and has not seen any changes for a long time, you could also pick up that existing patch and improve it, based on the feedback in Gerrit and in the task.

If you stop working on a task, remove yourself as the assignee of the task, so others know that they can work on the task and don't expect you to still work on it.

By communicating early you will get more attention, feedback and help from community members.





  • PHP指导 — 在许多不同语言中都可用。 如果你不会用PHP且也不会用其他对象导向语言,PHP会这些语言中你容易学的。
  • PHP Programming at Wikibooks.
  • PHP topic at Wikiversity.
  • MediaWiki中的脚本maintenance/eval.php提供了一个基本的包含MediaWiki对象与分级的PHP编译器。
  • Also, the script maintenance/shell.php in MediaWiki is a replacement of maintenance/eval.php based on PsySH, see Manual:Shell.php.



  • 用MySQL/MariaDB測試你的代碼。
    • MediaWiki currently uses MySQL and MariaDB as the primary database back-end. 它同样支持其他DBMS,例如PostgreSQLSQLite。 However, almost all developers use MySQL/MariaDB and don't test other DBs, which consequently break on a regular basis. You're therefore advised to use MySQL/MariaDB when testing patches, unless you're specifically trying to improve support for another DB. In the latter case, make sure you're careful not to break MySQL/MariaDB (or write queries that are horribly inefficient in it), since MySQL/MariaDB is what everybody else uses.


JavaScript and CSS have become omnipresent in front-end code. You don't have to be familiar with JavaScript, jQuery and CSS to work on MediaWiki, but you might need to, depending on what you choose to work on.



The MediaWiki code base is large and some parts are ugly; don't be overwhelmed by it. When you're first starting off, aim to write features or fix bugs which only touch a small region of code.

MediaWiki basics and must-reads
  • Manual:Code — A list of important files and links to more detailed information.
  • 手册:钩子 — A list of hooks. If you're trying to find what part of the codebase does something, often a good place to start is by searching for the related hooks.
  • 手册:代码编写约定 — An overview of general coding conventions within the MediaWiki community.
  • 代码文档 — Automatically generated documentation from the code and code comments.
  • 手册:如何调试 — A guide to debugging MediaWiki.
  • Manual:Eval.php — A tool to interact with MediaWiki objects live.


If you choose to work on MediaWiki extensions code, the following links provide more information.

MediaWiki extensions basics


  1. 但并不是所有Mediawiki内容都是如此。有些支持性工具由其他语言编写,他们包括batch files, shell scripts, makefiles还有Python.
  2. MediaWiki在多数支持PHP的平台上都能运行,但在非LAMP上,MediaWiki的表现与功能可能会因为特定操作系统属性与特定实用工具的缺失大打折扣。
  3. MediaWiki此外支持DBMS,包括OraclePostgreSQL, SQLite,以及微软SQL服务等。
  4. 开发者中既有志愿者,也有如承包商之类各行各业的工薪者。他们的全部姓名被列在了Developers
  5. 可以在https://phabricator.wikimedia.org/diffusion/浏览源代码,修改代码库,或者你也可以用Gerrit下载源代码到你的电脑。