MediaWikiハッカーになる方法

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

この記事は開発者を対象に、MediaWiki core と MediaWiki 拡張機能の開発に貢献するために欠かせないスキルの習得を支援する目的で執筆されました。

ウィキメディアの開発を始めるなら、まずメンターを付けてくれるウィキメディアで貢献することから入りましょう。メンターなしでする他の開発としては、既存のコードにあるgood first bugの修正があります。

あなたが既にMediaWikiの使用に慣れ親しんだ経験を積んだ開発者である場合は、代わりに 開発者ハブ を参照してください。

ウィキメディアのコミュニティに参加するその他の方法は、貢献する方法 を参照してください。

概要

MediaWiki は、ウィキペディアとその姉妹プロジェクト群や世界中の数多くのウィキを支えるソフトウェアです。

MediaWikiおよび拡張機能のほとんどはPHPプログラミング言語で書かれています。 対話式のインターフェース要素を提供するためにJavaScriptがクライアントJavaScriptライブラリとしてのjQueryおよびVue.jsと共に使用されています。

一部の補助ツールは他の言語で書かれています。バッチ ファイルMakefilePython などがその例です。

MediaWiki は主に LAMP プラットフォーム向けに書かれており[1]、ほとんどの OS で実行可能です。 MediaWiki は主に MySQL または MariaDBデータベース サーバーを使用しています[2]

開発はオープンソーススタイルで行われており[3]、大部分のコミュニケーションはオンライン上で行われています。開発はウィキメディア財団による支援もありますが、ボランティアコミュニティの開発者によるものがかなりの部分を占めています。

タスクを探す、もしくは新設

今まで、 MediaWiki プロジェクトのどれかで実際に機能を開発したとかバグ修正をしたことがなくても、始めるからには下調べが重要です。 具体的にいうと次のことを考えましょう。

  1. Phabricator を検索し、未解決またはすでに処理済みのタスク(文書の種別欄)がないか探ること。 もしないなら、新しく項目を立てます。 ただしごく小さな変更なら、タスクは作りません。
  2. 指定の機能を展開するには、どのコードを修正するか探してじっくり検討すること。 Phabricator のタスクにコメントして、自分が発見したことで他の人の助けになりそうな点を記入し、変更点の査読を待つ、あるいは展開する人が現れるのを待つこと。
  3. 調査したコードのどこをどう変更するか理解できるなら、自力でバグ修正する技能があるかどうか、あるいは機能そのものを追加できるかどうか、見きわめます。 タスクが長大もしくは複雑そうな場合には、もう少し難易度が低いタスクに取り組んでみて、少しずつ難し目のタスクへと技能を上げていくと、当初は長大だと判断した規模でも扱えるように努力します。 自力で完結できるという自信がある場合は、あなた自身をそのタスクに割り当てて、作業を始めてください。

開発環境のセットアップ

Once you have found something you can work on, the next step to developing MediaWiki or an extension is creating an environment to run MediaWiki, its database, and any other external features so that you can develop and test them.

You can install and develop MediaWiki on Linux, Windows, or macOS using any of the three solutions below.

Docker

Docker is a good option if you want to setup a MediaWiki installation quickly and are not planning on installing many extensions.

You can also try the mwcli tool which sets up Docker with a few simple commands and provides basic orchestration functionality between MediaWiki, MySQL, ElasticSearch, Memcached, and other types of containers.

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 adding extensions in a Docker or local installation, but it runs a bit slower than the other two options.

ローカルインストール

Local installation is a good option if you want to set up a simple development environment quickly without using Docker.

Open a code editor

The two recommended code editors for editing MediaWiki are VSCode and PhpStorm. VSCode is free and PhpStorm is paid, however, you can acquire a PhpStorm license for free if you are a student by linking your GitHub Education account to your JetBrains account, or by requesting a license granted to Wikimedia.

To determine which editor you should install and use, know that all-around, PhpStorm has more and more-powerful features than VSCode. However, PhpStorm takes significantly longer to load on start than VSCode as it builds an index of the entire repository whereas VSCode progressively loads. Therefore, VSCode is typically useful for file-viewing sessions or small changes and PhpStorm for larger changes. It makes sense to have both installed for these reasons.

To develop the MediaWiki codebase that is inside a Docker container you can establish a remote connection to it and open the MediaWiki folder inside it using VSCode or PhpStorm.

Change and test the code

Change the code and view your changes by reloading your MediaWiki browser tab. Make sure to follow Manual:コーディング規約 . Write and run tests on your code to make sure it works and is formatted properly.

Note, you can save time by ensuring your changes will be accepted before taking the time to write tests. Create a patch without needed tests and ask for someone to review it stating that you will add tests after they review it.

Create a patch

Finally, to submit your code to be reviewed and added to the repository you are contributing to, follow Gerrit/チュートリアル .

コミュニケーションのヒントとガイドライン

MediaWiki 拡張機能を修正する手順の解説。調査からコミットの獲得、査読を受けたりマージが発生した後、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

  • 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で書かれています。ですから、MediaWikiのコアをハックするためにPHPに精通する必要があります。

PHPを学ぶ
  • PHP のチュートリアル — 様々な言語で利用できます。 PHPについて全く知らなくても、他のオブジェクト指向プログラミング言語の経験があれば、PHPを学ぶのは簡単です。
  • PHP Programming at Wikibooks.
  • PHP at Wikiversity.
PHPに関するリソース
知っておくべきこと
  • MediaWikiのmaintenance/eval.phpスクリプトが、基本のPHPインタープリタにMediaWikiのオブジェクトとクラスをロードします。
  • また、MediaWiki のスクリプト maintenance/shell.php の書き換えも必要。maintenance/eval.php がベースです。Manual:shell.php も参照してください。

データベース

多くの機能がある程度のデータベース操作を必要とするため、MySQL/MariaDBに精通している必要がある場合が多いでしょう。

MySQL/MariaDBについて学ぶ
MySQL/MariaDB リソース
知っておくべきこと
  • MySQL/MariaDBでコードをテストしてください。
    • MediaWiki は現在、主要なデータベースバックエンドとして MySQLMariaDB を使用しています。 また、PostgreSQLSQLiteなどの他のDBMSもサポートしています。 しかし、ほとんどすべての開発者はMySQL/MariaDBを使用しており、他のDBをテストしていないため、結果として定期的に動かなくなっていまいます。 そのため、パッチのテストには、特に他のDBのサポートを改善する場合を除き、MySQL/MariaDBを使用することをお勧めします。 後者の場合、MySQL/MariaDB を壊さないように(あるいは、MySQL/MariaDB において恐ろしく非効率なクエリを書かないように)注意してください。

JavaScript と CSS

JavaScriptとCSSは、フロントエンドのコードのいたるところに現れます。 MediaWikiで作業するためにJavaScript、jQuery、CSSに精通する必要はありませんが、作業する内容によっては必要かもしれません。

JavaScriptとCSSについて学習する
JavaScript と CSS のリソース

MediaWiki

MediaWikiのコードベースは大きな部分もあります; それに圧倒されないでください。 最初のうちは、コードの小さな領域にしか触れないような機能を書いたり、バグを修正したりすることを目標にしましょう。

MediaWiki の基本と必読ページ
MediaWiki のリソース

MediaWiki 拡張機能

MediaWikiの拡張機能のコードを動かす事を選んだなら、以下のリンクから詳細をご覧いただけます。

MediaWiki 拡張機能のリソース
MediaWiki 拡張機能のリソース

MediaWiki 外装

Manual:MediaWiki外装を作る方法 is helpful if you choose to work on MediaWiki skins.

関連項目

脚注

  1. MediaWikiはPHPをサポートする殆どのプラットフォームで実行可能ですが、LAMP以外のプラットフォーム上では、特定のユーティリティやOSの機能がないために機能や性能が制限される場合があります。
  2. MediaWiki は MySQLMariaDB 以外の DBMS もサポートします。例えば、PostgreSQLSQLite です。
  3. 開発者は、ボランティアや様々な組織で働いているスタッフ(あるいは契約者)の集団からなります。MediaWikiのコードに取り組んでいる開発者の全リストについては、開発者 の記事をご覧ください。
  4. ソースコードを閲覧したり、コードリポジトリを更新するには http://phabricator.wikimedia.org/diffusion/ を訪問してください。Gerritを用いてシステムにソースコードをダウンロードすることもできます。