MediaWikiハッカーになる方法
この記事は開発者を対象に、MediaWiki core と MediaWiki 拡張機能の開発に貢献するために欠かせないスキルの習得を支援する目的で執筆されました。
ウィキメディアの開発を始めるなら、まずメンターを付けてくれるウィキメディアで貢献することから入りましょう。メンターなしでする他の開発としては、既存のコードにあるgood first bugの修正があります。
あなたが既にMediaWikiの使用に慣れ親しんだ経験を積んだ開発者である場合は、代わりに 開発者ハブ を参照してください。
ウィキメディアのコミュニティに参加するその他の方法は、貢献する方法 を参照してください。
概要
MediaWiki は、ウィキペディアとその姉妹プロジェクト群や世界中の数多くのウィキを支えるソフトウェアです。
MediaWiki は PHP プログラミング言語で書かれていますが、一部の補助ツールは他の言語で書かれています。バッチ ファイル、Makefile、Python などがその例です。 また、クライアントのJavaScript ライブラリとしては jQuery を使用しています。
MediaWiki は主に LAMP プラットフォーム向けに書かれており[1]、ほとんどの OS で実行可能です。 MediaWiki は主に MySQL または MariaDBデータベース サーバーを使用しています[2]
開発はオープンソーススタイルで行われており[3]、大部分のコミュニケーションはオンライン上で行われています。開発はウィキメディア財団による支援もありますが、ボランティアコミュニティの開発者によるものがかなりの部分を占めています。
- 開発についての議論がPhabricator 、メーリングリスト 、およびIRC チャンネルで行われています。 メインの開発者メーリング リストは wikitech-l です。 メインの開発者 IRC チャンネルは #mediawiki 接続 と #wikimedia-dev 接続 です。
- ソースコードは Gerrit で保管され、 Git リビジョン管理システムで管理されています。[4]
- コードレビューは、Gerrit で行われます。こちらで閲覧できます。 パッチを投稿するために Git や Gerrit をセットアップするには、こちらのチュートリアルに従ってください。
- バグ報告、機能リクエスト、およびプロジェクトが Phabricator で整理保存、および調整されており、こちらで閲覧できます。
開発環境のセットアップ
You can install and develop MediaWiki on Linux, Windows, or macOS using any of the three solutions below.
ほとんどのプロジェクトでは Git と Gerrit を使用します。Gerrit のチュートリアルにしたがって開発者アカウントを登録してください。 その後に、コードをダウンロードしたり変更、テスト、パッチの送信が可能になります。 開発環境を準備するには、あらかじめ設定された仮想マシン (Docker または Vagrant) を使用する方法と手作業で行う設定の 2 通りがあります。
Docker
- MediaWiki Docker – Dockerを使用してMediaWikiを実行します。
You can also try the experimental mwcli tool which sets up Docker with a few simple commands and provides basic orchestration functionality for MediaWiki Docker containers. With this you can easily add extensions and features to your container.
If you run it from Windows, Docker shares files between your Windows filesystem and the container filesystem. This can cause MediaWiki to be very slow if you are using WSL2 based engine, due to the poor performance of its shared directory implementation. If you have Windows Pro, you can switch to the Hyper-V backend in the settings of Docker Desktop for better filesystem performance.
An even faster way to run MediaWiki using Docker in Windows (speeds comparable to manually installing) is to clone MediaWiki and run Docker inside WSL (or install and run mwcli
inside of WSL).
That way there is no shared filesystem overhead.
To develop the MediaWiki codebase that is inside the Docker container you can establish a remote connection to it and open the MediaWiki WSL folder in that is in the container using VSCode or PhpStorm.
Vagrant
- MediaWiki Vagrant – Run MediaWiki on a Linux virtual machine using Vagrant.
Vagrant allows you start a MediaWiki instance you can develop as well as allowing you to add and develop any of 250+ extensions - all with a single command. This saves you installation and configuration time compared to manually installing. It runs faster than Docker on Windows, however slower than Docker on WSL or manually installing.
手動インストール
MediaWiki can be developed by installing it natively on your system and editing its code. Installing it natively means it will run faster than Docker or Vagrant, but it will take more time to configure.
- インストール要件 — Check hardware requirements and install dependencies
- Git からのダウンロード — Git から最新のソースコードをダウンロードします。
- インストール ガイド — 引き続きインストールと初期設定をします。
- 早期に警告やエラーを表示するためにさまざまなデバッグ手段を準備します。
コミュニケーションのヒントとガイドライン
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
- 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:
- Read and follow the code of conduct for Wikimedia technical spaces.
- Use 包括的言語 : Instead of using terms that assume a gender identity (like "guys", "madam", or "sir") use the name of the person instead.
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.
付録
PHP
MediaWikiはPHPで書かれています。ですから、MediaWikiのコアをハックするためにPHPに精通する必要があります。
- PHPを学ぶ
-
- PHP のチュートリアル — 様々な言語で利用できます。 PHPについて全く知らなくても、他のオブジェクト指向プログラミング言語の経験があれば、PHPを学ぶのは簡単です。
- PHP Programming at Wikibooks.
- PHP at Wikiversity.
- PHPに関するリソース
-
- PHPマニュアル — 様々な言語で利用できます。
- MediaWiki コミュニティ内の PHPコーディング規約
- 知っておくべきこと
-
- MediaWikiの
maintenance/eval.php
スクリプトが、基本のPHPインタープリタにMediaWikiのオブジェクトとクラスをロードします。 - また、MediaWiki のスクリプト
maintenance/shell.php
の書き換えも必要。maintenance/eval.php
がベースです。Manual:shell.php も参照してください。
- MediaWikiの
データベース
多くの機能がある程度のデータベース操作を必要とするため、MySQL/MariaDBに精通している必要がある場合が多いでしょう。
- MySQL/MariaDBについて学ぶ
-
- MySQL のチュートリアル — MySQL リファレンス マニュアルより。
- MySQL at Wikibooks.
- MySQL/MariaDB リソース
-
- MySQL のリファレンス マニュアル — 様々な言語で利用できます。
- MariaDB ナレッジ ベース
- MediaWiki コミュニティ内のデータベース コーディング規約
- データベースへのアクセス
- 知っておくべきこと
-
- MySQL/MariaDBでコードをテストしてください。
- MediaWiki は現在、主要なデータベースバックエンドとして MySQL と MariaDB を使用しています。 また、PostgreSQLやSQLiteなどの他のDBMSもサポートしています。 しかし、ほとんどすべての開発者はMySQL/MariaDBを使用しており、他のDBをテストしていないため、結果として定期的に動かなくなっていまいます。 そのため、パッチのテストには、特に他のDBのサポートを改善する場合を除き、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の主な構成要素と、それらがどのように相互に作用するかについての高レベルな概要です。
- 開発者向けセキュリティ — 安全なコードを書く理由と方法についての概要です。
- MediaWiki のリソース
-
- Manual:コード — 重要なリストとリンクのより詳細な情報です。
- Manual:フック — フックの一覧です。コードベースのどの部分が何かをするのか見つけようとする場合、多くの場合、関連するフックを検索することから始めるのがよいでしょう。
- Manual:コーディング規約 — MediaWikiコミュニティ内の一般的なコーディング規約の概要です。
- コードの説明文書 (出典の追加) — ソースコードとそれのコメントによって自動生成されています。
- Manual:デバッグの方法 — MediaWikiデバッグの手引。
- Manual:eval.php — MediaWikiのオブジェクトをライブで操作するためのツールです。
MediaWiki 拡張機能
MediaWikiの拡張機能のコードを動かす事を選んだなら、以下のリンクから詳細をご覧いただけます。
- MediaWiki 拡張機能のリソース
-
- 拡張機能の開発 — MediaWikiでの拡張機能のコードの書き方
- 拡張機能の書き方のチュートリアル
- MediaWiki 拡張機能のリソース
-
- 拡張機能に関する最善の手法
- A brief introduction to MediaWiki extension development — MediaWikiの拡張機能の作り方に関するプレゼンの動画。(slides).
- MediaWikiの拡張機能の作り方 — MediaWikiの拡張機能を開発する方法、ベストプラクティス、MediaWikiコミュニティへの参加方法について説明します。 2011年2月からです。
- Help for extension developers on the Developer Hub
MediaWiki 外装
Manual:How to make a MediaWiki skin is helpful if you choose to work on MediaWiki skins.
関連項目
- リポジトリを横断してコードを検索
- 開発者ハブ – この記事にかかれていることをを精読したら、今度は開発者ハブの情報に移りましょう。
- 行動規範
- ↑ MediaWikiはPHPをサポートする殆どのプラットフォームで実行可能ですが、LAMP以外のプラットフォーム上では、特定のユーティリティやOSの機能がないために機能や性能が制限される場合があります。
- ↑ MediaWiki は MySQL とMariaDB 以外の DBMS もサポートします。例えば、PostgreSQL、SQLite です。
- ↑ 開発者は、ボランティアや様々な組織で働いているスタッフ(あるいは契約者)の集団からなります。MediaWikiのコードに取り組んでいる開発者の全リストについては、開発者 の記事をご覧ください。
- ↑ ソースコードを閲覧したり、コードリポジトリを更新するには http://phabricator.wikimedia.org/diffusion/ を訪問してください。Gerritを用いてシステムにソースコードをダウンロードすることもできます。