成为 MediaWiki 的贡献者
这篇文章用以帮助开发者学习开发MediaWik 内核和MediaWiki扩展的基础技能。 请注意,多数情况下,你并不想去随便删改MediaWiki的内核,除非你真的知道你在干什么!
入门Wikimedia开发的主要方式就是给那些有新手指导的Wikimedia项目做贡献。另一种毋须指导的替代方案则是去debug。
如果你是一个有经验的开发者,已经熟悉了使用MediaWiki,请访问开发人员中心 。
对于其他的方式涉足维基媒体社区,参见如何貢獻 。
概覽
MediaWiki是维基百科,與其姐妹项目,还有世界各地数以千计的维基网站使用的软件。
MediaWiki由PHP语言编写。[1] 它使用jQuery作为JavaScript的客户端库。
MediaWiki首先是为LAMP平台编写[2] ,并且在多数操作系统中是可用的。 MediaWiki首要使用MySQL与MariaDB数据库服务器.[3]
MediaWiki在开源环境下开发[4]。代码的调整大多在网上完成,并受到维基媒体基金会的支持,不过志愿者为之付出甚多。
- 开发讨论可以在各种邮件列表和IRC 频道中进行。 主要开发者名单在此:wikitech-l。 主要的开发者IRC频道为#mediawiki和#wikimedia-dev。
- 源代码是使用Git修改控制系统管理的。[5]
- 代码复审可以在Gerrit 中进行。 遵守教程来创立Git与Gerrit以提交补丁。
- 漏洞报告与任务是在Phabricator中管理的。
本页可以帮助您成为MediaWiki的贡献者。 此非入門教學,而是引導您至不同任何您覺得必要學習的內容。
配置您的开发环境
大多数项目使用Git和Gerrit。按照Gerrit指南来创建您的开发者帐号。 然後你可以去下載我們的代碼,做出改變,測試他們,然後提交補丁。 有两种方法配置您的开发环境:使用预配置的虚拟机安装(Vagrant或Docker),或手动配置途径。
虛擬機器與Vargant
- 安裝Vagrant——這些步驟會安裝MediaWiki伺服器於所有符合需求的Linux虛擬機器(可用於Linux、Windows,或Mac hosts)
Docker开发环境
- MediaWiki Docker:利用Docker运行MediaWiki(支持Linux、Windows和macOS主机)。
手动安装
- 安裝需求 — 檢查硬體需求後,請安裝LAMP、MAMP或WAMP伺服器(Linux、Mac或Windows、plus Apache、MySQL/MariaDB與PHP)。
您不必下載維基百科數據庫資料即可開發MediaWiki功能。 實際上,大部分情況下使用一個幾乎為空的數據庫,裡面只有一些特定的測試頁,會更簡單。 然而,如果由於某種原因你仍想複製維基百科,你可以下載資料。
Communication tips and guidelines
- Do your research first: When you decide to work on a task, 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 code changes. For a general overview, please read the Basics to know.
- In a Phabricator task, see the project tags in the side bar to find out which code repository a task is about.
- Ask and discuss in the best place:
- In Phabricator tasks, discuss only specific questions about the topic of that very Phabricator task. General technical questions (e.g. how to set up a development environment or problems with Gerrit) are off-topic in Phabricator tasks.
- For general technical questions, ask the broader Wikimedia community and use generic channels like IRC chat or mailing lists. (If you take part in an outreach program, then you can also use Zulip's technical-support stream.)
- If you take part in an outreach program, then Zulip is for discussing questions about the outreach programs themselves.
- Ask good questions: "Can you give me more info?", "Please guide me", "Please tell me how to start" are not good comments 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 – consider finding an easier one first.
- Provide context: When asking, explain what you want to achieve, and 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. This avoids misunderstandings.
- Ask in public: Do not send private messages if your conversation topic is not secret. Private messages do not help others.
- Be patient when seeking input and comments, especially during weekends and holidays.
- 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 try again at a different time; don't just give up.
- Do not ask people immediately for code review in a separate message. People receive Gerrit and Phabricator notifications.
- Keep conversations readable: When you reply in Zulip, in Phabricator tasks, or on mailing lists, please avoid unneeded quoting of a complete previous comment. Provide sufficient context and keep threads readable.
- Follow the code of conduct for Wikimedia technical spaces.
- When you plan to work on a Phabricator task:
- No need to ask for permission: Usually there is no reason to ask if you can work on something or if somebody could assign a task to you. There is no authority who assigns tasks or who needs to be asked first.
- You do not need to announce your plans before you start working on a task but it would be welcome. At the latest when you are close to proposing a patch for a task, it is good to announce that you are working on it, so that others don't duplicate work: If nobody else is already assigned, set yourself as task assignee by using the Add Action… → Assign/Claim dropdown.
- Tasks with existing patches:
- If a task already has a recent patch in Gerrit, 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 improve that existing patch, based on the feedback in Gerrit and in the task.
- When your plans or interests change: If you don't work on a task anymore, please 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 clearly and early you get attention, feedback and help from community members.
附录
PHP
MediaWiki由PHP编写,所以你需要了解并熟悉PHP才可以熟练使用MediaWiki的核心代码。
- 學習PHP
-
- PHP指导 — 在许多不同语言中都可用。 如果你不会用PHP且也不会用其他对象导向语言,PHP会这些语言中你容易学的。
- PHP Programming at Wikibooks.
- PHP topic at Wikiversity.
- 需要知道的东西
-
- MediaWiki中的脚本
maintenance/eval.php
提供了一个基本的包含MediaWiki对象与分级的PHP编译器。 - 此外,MediaWiki中的脚本
maintenance/shell.php
是基于PsySH的maintenance/eval.php
的替代,参见Manual:Shell.php.
- MediaWiki中的脚本
数据库
许多特性需要对数据库做出一定程度的修改,所以你常常需要熟悉MySQL/MariaDB。
- MySQL/MariaDB资源
-
- MySQL参考手册 — 在许多不同语言里可用。
- MariaDB知识库
- MediaWiki社区内部的数据库编码条例。
- 存取資料庫
- 要知道的东西
-
- 用MySQL/MariaDB測試你的代碼。
- MediaWiki目前使用MySQL和MariaDB作为主数据库后端。 它同样支持其他DBMS,例如PostgreSQL和SQLite。 但是,几乎所有开发人员都使用MySQL/MariaDB而不测试其他数据库,因此会定期中断。 因此,建议您在测试补丁时使用MySQL/MariaDB,除非您专门尝试改进对其他数据库的支持。 在后一种情况下,请确保您小心不要破坏MySQL/MariaDB(或编写非常低效的查询),因为MySQL/MariaDB是其他人使用的。
- 用MySQL/MariaDB測試你的代碼。
JavaScript和CSS
JavaScript和CSS在前端代码中无处不在。 您不必熟悉使用MediaWiki的JavaScript、jQuery和CSS,但您可能需要,具体取决于您选择的工作方式。
- 学习JavaScript和CSS
-
- JavaScript and CSS at Wikibooks.
- 入门jQuery — jQuery指导
- Learning JavaScript — references and sources.
- JavaScript和CSS资源
-
- MediaWiki社区中的JavaScript编码约定。
- MediaWiki社区中的CSS编码约定。
MediaWiki
MediaWiki代码库很大,有些部分很难看,不要被它淹没。 当您第一次开始时,目标是编写功能或修复只触及一小部分代码的错误。
- MediaWiki基礎知識和必讀內容
-
- MediaWiki體系結構 — MediaWiki的主要元件及它們之間如何相互配合的高級概述。
- Security for developers — 為何要以及如何編寫安全代碼的概述。
- MediaWiki资源
-
- 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.
- 手册:Eval.php — 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扩展手册:
-
- 最佳实践活动
- 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月开始。
- 开发者小屋中的开发者帮助
參見
- Search for code across repositories
- 开发人员中心 – 如果你已经把这篇文章读完了,是时候去看看开发者小屋了。
- MediaWiki开发者手册 – 相关页面的集合
- 行为准则
- ↑ 但并不是所有Mediawiki内容都是如此。有些支持性工具由其他语言编写,他们包括批处理文件、shell脚本、makefiles和Python。
- ↑ MediaWiki在多数支持PHP的平台上都能运行,但在非LAMP上,MediaWiki的表现与功能可能会因为特定操作系统属性与特定实用工具的缺失大打折扣。
- ↑ MediaWiki此外支持DBMS,包括Oracle、PostgreSQL、SQLite以及MSSQL等。
- ↑ 开发者中既有志愿者,也有如承包商之类各行各业的工薪者。他们的全部姓名被列在了开发者 。
- ↑ 可以在https://phabricator.wikimedia.org/diffusion/ 浏览源代码,修改代码库,或者你也可以用Gerrit下载源代码到你的电脑。