成为 MediaWiki 的贡献者

This page is a translated version of the page How to become a MediaWiki hacker and the translation is 86% complete.
Outdated translations are marked like this.

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

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

如果你是一个有经验的开发者,已经熟悉了使用MediaWiki,请访问开发人员中心

对于其他的方式涉足维基媒体社区,参见如何貢獻

概覽

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

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

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

MediaWiki在开源环境下开发[4]。代码的调整大多在网上完成,并受到维基媒体基金会的支持,不过志愿者为之付出甚多。

  • 源代码是由Git版本控制系统管理的。[5]

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

配置您的开发环境

大多数项目使用Git和Gerrit。按照Gerrit指南来创建您的开发者帐号。 然後你可以去下載我們的代碼,做出改變,測試他們,然後提交補丁。 有两种方法配置您的开发环境:使用预配置的虚拟机安装(Docker或Vagrant),或手动配置。

Docker开发环境

  • MediaWiki Docker:利用Docker运行MediaWiki(支持Linux、Windows和macOS主机)。 This is the recommended method.

You can also try the experimental mwcli tool which provides basic orchestration functionality for MediaWiki docker containers.

虛擬機器與Vargant

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

Vagrant is a powerful tool, but it is more complex and less robust than Docker, and significantly more resource-intensive. It is mainly aimed at developers who need to set up complex, flexible environments, e.g. for testing the interaction of multiple extensions.

手动安装

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

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

沟通技巧和准则

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

Follow these tips to communicate effectively and get help from community members.

Use Phabricator tasks effectively

When you plan to work on a Phabricator task:

  • No need to ask for permission: You can work on unassigned tasks without asking someone to assign them to you. There is no authority who assigns tasks or who needs to be asked first.
    • If a task already has a recent patch in Gerrit, choose a different task to work on instead.
    • If an existing patch in Gerrit has not been merged and has not seen any changes for a long time, you could improve that existing patch, based on the feedback in Gerrit and in the task.
  • Do your research: When you consider working on a task, do research before you start coding. Look at the code, try to understand what it is supposed to do, read related documentation, and try to find the places where you need to make code changes.
    • In a Phabricator task, use the project tags in the side bar to find the code repository for the task.
    • If you have no idea at all how to fix the bug, consider finding an easier one first.
  • You do not need to announce your plans before you start working on a task, but you should communicate that you are working on the task.
    • When you start work, set yourself as task assignee by clicking Edit Task… in Phabricator, and set your Phabricator username in the Assigned To field. This communicates to others that you are working on it, so they don't duplicate work.
    • When your plans or interests change: If you are no longer working on a task, remove yourself as the assignee of the task. This tells others that they can work on the task, and they won't expect you to still work on it.
  • Follow Phabricator etiquette.
    • In Phabricator tasks, discuss only specific questions about the topic of that task. Don't use Phabricator to ask general questions, like how to set up a development environment or how to fix problems with Gerrit.

Compose good questions

  • Don't ask to ask...just ask!.
  • Be specific and provide context: Instead of simply asking "Can you give me more info?", "Please guide me", or "Please tell me how to start", include the following information in your question:
    • What are you trying to achieve?
    • What have you already tried? Copy and paste your commands and their output (if not too long) instead of paraphrasing in your own words.
    • What have you found out already during your research? Include links to code, documentation, or other resources you already consulted.
  • Use specific titles and subject lines in your communication. "Proposal draft" or "Need help" is not specific.
  • Keep conversations readable: When you reply in Zulip, in Phabricator tasks, or on mailing lists, only quote sections of previous comments that are relevant to your response. If you quote a complete previous comment, it makes threads hard to read.

Follow communication policies and best practices

Before you send or post your question:

Ask in the right place

  • Ask in public: Do not send private messages if your conversation topic is not secret. Private messages don't help others.
  • Ask and discuss in the best place:
    • In Phabricator tasks, discuss only specific questions about the topic of that task.
    • Ask general technical questions, like how to set up a development environment or how to fix problems with Gerrit, in the places listed on 聯繫交流 .
    • If you take part in an outreach program, then Zulip is for discussing questions about the outreach programs themselves.

Be patient

After you post your question:

  • Do not ask people for code review in a separate message. People receive Gerrit and Phabricator notifications and will respond when they can.
  • When seeking input and comments, especially during weekends and holidays, you may need to wait until business hours resume. On chat channels like IRC: if nobody answers, try again at a different time; don't just give up!
  • If you don't get an answer even after waiting and being patient, consider if other Communication channels might be a better place to ask your question.

附录

 
MediaWiki贡献者在印度班加罗尔办公。

PHP

MediaWiki由PHP编写,所以你需要了解并熟悉PHP才可以熟练使用MediaWiki的核心代码。

學習PHP
  • PHP指导 — 在许多不同语言中都可用。 如果你不会用PHP且也不会用其他对象导向语言,PHP会这些语言中你容易学的。
  • PHP Programming at Wikibooks.
  • PHP at Wikiversity.
PHP资源
需要知道的东西
  • MediaWiki中的脚本maintenance/eval.php提供了一个基本的包含MediaWiki对象与分级的PHP编译器。
  • 此外,MediaWiki中的脚本maintenance/shell.php是基于PsySH的maintenance/eval.php的替代,参见Manual:Shell.php


数据库

许多特性需要对数据库做出一定程度的修改,所以你常常需要熟悉MySQL/MariaDB。

学习MySQL或MariaDB
MySQL/MariaDB资源
要知道的东西
  • 用MySQL/MariaDB測試你的代碼。
    • MediaWiki目前使用MySQLMariaDB作为主数据库后端。 它同样支持其他DBMS,例如PostgreSQLSQLite。 但是,几乎所有开发人员都使用MySQL/MariaDB而不测试其他数据库,因此会定期中断。 因此,建议您在测试补丁时使用MySQL/MariaDB,除非您专门尝试改进对其他数据库的支持。 在后一种情况下,请确保您小心不要破坏MySQL/MariaDB(或编写非常低效的查询),因为MySQL/MariaDB是其他人使用的。

JavaScript和CSS

JavaScript和CSS在前端代码中无处不在。 您不必熟悉使用MediaWiki的JavaScript、jQuery和CSS,但您可能需要,具体取决于您选择的工作方式。

学习JavaScript和CSS
JavaScript和CSS资源

MediaWiki

MediaWiki代码库很大,有些部分很难看,不要被它淹没。 当您第一次开始时,目标是编写功能或修复只触及一小部分代码的错误。

MediaWiki基礎知識和必讀內容
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擴充功能基礎知識:
MediaWiki扩展手册:

參見

  1. 但并不是所有Mediawiki内容都是如此。有些支持性工具由其他语言编写,他们包括批处理文件shell脚本makefilesPython
  2. MediaWiki在多数支持PHP的平台上都能运行,但在非LAMP上,MediaWiki的表现与功能可能会因为特定操作系统属性与特定实用工具的缺失大打折扣。
  3. MediaWiki此外支持DBMS,包括PostgreSQLSQLite
  4. 开发者中既有志愿者,也有如承包商之类各行各业的工薪者。他们的全部姓名被列在了开发者
  5. 可以在此处浏览源代码、修改代码库,或者你也可以用Gerrit下载源代码到你的电脑。