MediaWikiハッカーになる方法
この記事は開発者を対象に、MediaWiki core と MediaWiki 拡張機能の開発に貢献するために欠かせないスキルの習得を支援する目的で執筆されました。 MediaWiki で活動中、ほんとうに自信があって責任を持てないなら、ほとんどの場合MediaWiki coreをいじらないように注意してください。
ウィキメディアの開発を始めるなら、まずメンターを付けてくれるウィキメディアで貢献することから入りましょう。メンターなしでする他の開発としては、既存のコードにあるgood first bugの修正があります。
あなたが経験を積んだ開発者である場合は、代わりに 開発者ハブ を参照してください。
ウィキメディアのコミュニティに参加するその他の方法は、貢献するには を参照してください。
概要
MediaWiki は、ウィキペディアとその姉妹プロジェクト群や世界中の数多くのウィキを支えるソフトウェアです。
MediaWikiはPHPプログラミング言語により書かれています[1]。 また、クライアントのJavaScript libraryとしてはjQueryを使用しています。
MediaWikiは主にLAMP platform向けに書かれており[2]、ほとんどのOSで実行可能です。 MediaWikiは主にMySQLとMariaDBデータベースサーバを使用しています[3]
開発オープンソーススタイルで行われており[4]、大部分のコミュニケーションはオンライン上で行われています。開発はウィキメディア財団による支援もありますが、ボランティアコミュニティの開発者によるものがかなりの部分を占めています。
- 開発についての議論がさまざまなメーリング リストや IRC チャンネルで行われています。 主要開発者リストはwikitech-lにてご確認ください。 主要開発者IRCチャンネルはMediaWikiやWikimedia-devにてご確認ください。
- ソースコードはw:Gitリビジョン管理システムで管理されています。[5]
- コードレビューは、Gerrit で行われます。 GitやGerritをセットアップしてパッチを送信するには、こちらのチュートリアルをご確認ください。
- バグ報告やタスクは、ファブリケーターで管理されています。
このページは、MediaWikiのコントリビュータになる助けになるはずです。 これはチュートリアルではありません。単に必要なことを学べる場所へのポインタを示しているに過ぎません。
開発環境のセットアップ
ほとんどのプロジェクトでは Git と Gerrit を使用します。Gerrit のチュートリアルにしたがって開発者アカウントを登録してください。 その後に、コードをダウンロードしたり変更、テスト、パッチの送信が可能になります。 開発環境を準備するには、あらかじめ設定された仮想マシン(VagrantもしくはDocker)を使用する方法とマニュアルで行う設定の2通りがあります。
Vagrantを使用した仮想マシン
- Vagrantのインストール - ここに書かれた手順に従えば、Linux仮想マシン内で、MediaWikiサーバーとそれに必要なすべてのプログラムのインストールができます。ホストには、Linux、Windows、Macのいずれも使用可能です。
Docker development environment
- MediaWiki Docker – Run MediaWiki using Docker (can be used on Linux, Windows or macOS hosts).
手動インストール
- インストール要件 - ハードウェア要件を確認し、LAMP、MAMP、WAMP のいずれかのサーバー (Linux、Mac、Windows のいずれかとApache、MySQL/MariaDB、PHP) をインストールします。
- Git からのダウンロード — Git から最新のソースコードをダウンロードします。
- インストール ガイド — 引き続きインストールと初期設定をします。
- 早期に警告やエラーを表示するためにさまざまなデバッグ手段準備します。
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 is written in PHP, so you'll need to get familiar with PHP to hack MediaWiki's core.
- Learn PHP
-
- PHP のチュートリアル — 様々な言語で利用できます。 PHPについて全く知らなくても、他のオブジェクト指向プログラミング言語の経験があれば、PHPを学ぶのは簡単です。
- PHP Programming at Wikibooks.
- PHP topic at Wikiversity.
- PHPに関するリソース
-
- PHPマニュアル — 様々な言語で利用できます。
- MediaWiki コミュニティ内の PHPコーディング規約
- 知っておくべきこと
-
- MediaWikiの
maintenance/eval.php
が、基本のPHPインタープリタにMediaWikiのオブジェクトとクラスをロードします。
- Also, the script
maintenance/shell.php
in MediaWiki is a replacement ofmaintenance/eval.php
based on PsySH, see Manual:Shell.php.
- Also, the script
データベース
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 リソース
-
- MySQL のリファレンス マニュアル — 様々な言語で利用できます。
- MariaDB ナレッジ ベース
- MediaWiki コミュニティ内のデータベース コーディング規約
- Accessing the database
- 知っておくべきこと
-
- Test your code with 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.
- Test your code with MySQL/MariaDB.
JavaScript と CSS
JavaScriptとCSSは、フロントエンドのコードのいたるところに現れます。 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.
- jQueryをはじめる — jQuery のチュートリアルです。
- Learning JavaScript — references and sources.
- JavaScript と CSS のリソース
-
- MediaWiki コミュニティ内の JavaScript コーディング規約
- MediaWiki コミュニティ内の CSS コーディング規約
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 の基本と必読ページ
-
- MediaWiki のアーキテクチャ — A high-level overview of the main components of MediaWiki and how they work with each other.
- Security for developers — An overview of why and how to write secure code.
- MediaWiki のリソース
-
- Manual:コード — A list of important files and links to more detailed information.
- Manual:フック — 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.
- Manual:コーディング規約 — An overview of general coding conventions within the MediaWiki community.
- コードの説明文書 (class reference) — ソースコードとそれのコメントによって自動生成されています。
- Manual:デバッグの方法 — MediaWikiデバッグの手引。
- Manual: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 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
関連項目
- Search for code across repositories
- 開発者ハブ – この記事にかかれていることをを精読したら、今度は開発者ハブの情報に移りましょう。
- MediaWiki Developers Guide – a collection of related pages
- 行動規範
- ↑ MediaWikiの全部がPHPで書かれている訳ではありません。多少の補助ツールはまた他の言語で書かれており、batch files,Makefile,Pythonも含まれます。
- ↑ MediaWikiはPHPをサポートする殆どのプラットフォームで実行可能ですが、LAMP以外のプラットフォーム上では、特定のユーティリティやOSの機能がないために機能や性能が制限される場合があります。
- ↑ MediaWikiはMySQLとMariaDB以外のDBMSもサポートします。たとえば、Oracle、PostgreSQL、SQLite、そしてMicrosoft SQL Serverなどです。
- ↑ 開発者は、ボランティアや様々な組織で働いているスタッフ(あるいは契約者)の集団からなります。MediaWikiのコードに対してコントリビュートしている開発者の全リストについては、開発者 の記事をご覧ください。
- ↑ ソースコードを閲覧したり、コードリポジトリを更新するには http://phabricator.wikimedia.org/diffusion/ を訪問してください。Gerritを用いてシステムにソースコードをダウンロードすることもできます。