How to become a MediaWiki hacker/zh

这篇文章用以帮助开发者学习开发MediaWik 内核和MediaWiki扩展的基础技能. 请注意，多数情况下，你并不想去黑掉Media的核心，除非你真的知道你在干什么！

入门Wikimedia开发的主要方式就是给那些有新手指导的Wikimedia项目做贡献. 另一种毋须指导的替代方案则是去debug.

如果你是一个有经验的开发者，请访问.

对于其他的方式涉足维基媒体社区，参见.

概覽
MediaWiki是维基百科，與其姐妹项目，还有世界各地数以千计的维基网站使用的软件.

MediaWiki由PHP语言编写. 它使用jQuery作为JavaScript的客户端库.

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

MediaWiki在开源环境下开发 ,代码的调整大多在网上完成，并受到Wikimedia基金会的支持，不过志愿者为之付出甚多.

源代码是使用Git修改控制系统管理的. 代码回顾可以在中进行. 遵守教程来创立Git与Gerrit以提交补丁. 漏洞报告与任务是在Phabricator中管理的. 本页可以帮助您成为MediaWiki的贡献者. 此非入門教學，而是引導您至不同任何您覺得必要學習的內容.
 * 开发讨论可以在各种邮件列表和IRC 频道中进行. 主要开发者名单在此：wikitech-l.  主要开发者列表为wikitech-l，主要的开发者 IRC 频道为#mediawiki和#wikimedia-dev.

配置您的开发环境
大多数项目使用Git和Gerrit. 按照Gerrit指南来创建您的开发者帐号. 然後你可以去下載我們的代碼，做出改變，測試他們，然後提交補丁. 共有兩種方法架設您的開發環境：使用預設虛擬機器（vagrant），或手動.

虛擬機器與Vargant

 * 安裝Vagrant - 這些步驟會安裝MediaWiki伺服器於所有符合需求的Linux虛擬機器（可用於Linux、Windows，或Mac hosts）

手动安装

 * 安裝需求 — 檢查硬體需求後，請安裝LAMP、MAMP或WAMP伺服器（Linux、Mac或Windows、plus Apache、MySQL/MariaDB與PHP）.
 * — 於Git下載最新版的原始碼.
 * — 繼續安裝與初始化設定.
 * 架設不同的偵錯模式於您的環境，以提早顯示警告與錯誤.

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

推荐阅读




回饋、問題與支援
不要在我们的社交频道使用私人电子邮件或者发布支持请求. 
 * 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 about infrastructure (Git, Gerrit, Vagrant), the software architecture or workflows which are not tied to the specific task that you want to work on, use generic channels like, mailing lists, or wiki discussion pages but not the specific task. For example, if you have a problem with Gerrit, the Gerrit discussion page could be a good place to ask.
 * If you have a specific question about the bug itself, comment in the corresponding bug report (normally a task in ). "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. On IRC, don't ask to ask, just ask: most questions can be answered by other community members too if you ask on an IRC channel. If nobody answers, please ask on the bug report or wiki page related to the problem; don't just give up.
 * 在了解更多.
 * 你也可以在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
MediaWiki is written in PHP, so you'll need to get familiar with PHP to hack MediaWiki's core.


 * 學習PHP
 * PHP指导 — 在许多不同语言中都可用. 如果你不会用PHP且也不会用其他对象导向语言，PHP会这些语言中你容易学的.
 * PHP Programming at Wikibooks.
 * PHP topic at Wikiversity.


 * PHP资源:
 * PHP手册 — 在许多不同语言里可用.
 * MediaWiki社区内部的PHP编程条例


 * 需要知道的员工:
 * The script  in MediaWiki provides a basic PHP interpreter with MediaWiki objects and classes loaded.

数据库
Many features require some amount of database manipulation, so you'll often need to be familiar with MySQL/MariaDB.


 * 学习MySQL或MariaDB
 * MySQL指导 — From the MySQL 5.0 reference manual.
 * MySQL at Wikibooks.


 * MySQL/MariaDB resources
 * MySQL Reference Manuals — Available in many different languages.
 * MariaDB知识库
 * Database coding conventions within the MediaWiki community.
 * Accessing the database


 * 要知道的东西:
 * 用MySQL/MariaDB測試你的代碼.
 * MediaWiki currently uses MySQL and MariaDB as the primary database back-end. It also supports other DBMSes, such as PostgreSQL and SQLite. 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和CSS
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.


 * 学习JavaScript和CSS
 * JavaScript and CSS at Wikibooks.
 * Getting Started with jQuery — jQuery指导.
 * Learning JavaScript — references and sources


 * JavaScript and CSS resources
 * JavaScript coding conventions within the MediaWiki community.
 * CSS coding conventions within the MediaWiki community.

MediaWiki
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:
 *  — A high-level overview of the main components of MediaWiki and how they work with each other.
 *  — An overview of why and how to write secure code.


 * MediaWiki resources:
 * — 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.
 * — A tool to interact with MediaWiki objects live.

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


 * MediaWiki extensions basics:
 * Developing extensions — How to write an extension for MediaWiki.
 * 扩展写作教程


 * MediaWiki扩展手册：
 * Best practices for extensions
 * A brief introduction to MediaWiki extension development — A video presentation about how to create a MediaWiki extension (slides).
 * Making a MediaWiki extension — Covers how to develop an extension for Mediawiki, best practices, and how to engage the Mediawiki community. 从2011年2月开始.
 * Help for extension developers on the Developer Hub

參見

 * – When you've thoroughly read the information in this article, it's time to move on to the information in the developer hub.
 * MediaWiki Developers Guide – a collection of related pages