How to become a MediaWiki hacker

This article is written to help novice developers learn the skills needed to contribute to MediaWiki development.

If you are an experienced developer, visit the developer hub instead.

Overview
MediaWiki is the software that powers Wikipedia, its sister projects and thousands of wikis all over the world. It runs on most operating systems, is written in PHP, primarily uses the MySQL database server and uses jQuery as the client Javascript library. Development of MediaWiki is primarily supported by the Wikimedia Foundation, though volunteer community developers play a huge part as well.

This page should help you get started on the path to becoming a contributor to MediaWiki. It is not a tutorial; it just points you to various places where you can go learn whatever is necessary.

PHP
MediaWiki is written in PHP, so it's pretty much mandatory to be familiar with PHP if you intend to do any kind of coding on MediaWiki.


 * Learn PHP
 * PHP tutorial — Available in many different languages. If you have no knowledge of PHP but know how to program in other object-oriented programming languages, PHP will be easy for you to learn.
 * PHP Programming at Wikibooks.


 * PHP resources:
 * The PHP manual — Available in many different languages.
 * PHP coding conventions within the MediaWiki community.


 * Stuff to know:
 * The script maintenance/eval.php in MediaWiki provides a basic PHP interpreter with MediaWiki objects and classes loaded.

Database
Many features require some amount of database manipulation, so you'll often need to be familiar with MySQL.


 * Learn MySQL
 * MySQL tutorial — From the MySQL 5.0 reference manual.
 * MySQL at Wikibooks.


 * MySQL resources
 * MySQL Reference Manuals — Available in many different languages.
 * Database coding conventions within the MediaWiki community.


 * Stuff to know:
 * Test your code with MySQL.
 * MediaWiki currently uses MySQL as the primary database back-end. It also supports other DBMSes, such as PostgreSQL and SQLite. However, almost all developers use MySQL and don't test other DBs, which consequently break on a regular basis. You're therefore advised to use MySQL 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 (or write queries that are horribly inefficient in it), since that's what everybody else uses.
 * Preserve MySQL 4.0 support when possible.
 * Although the Wikimedia Foundation has now moved on from MySQL 4.0, it's important to not intentionally break MySQL 4.0 support. MySQL 4.0 is missing a lot of features of later MySQL versions (never mind other DBMSes): if you aren't sure, double-check in the manual first! The most commonly used feature missing from MySQL 4.0 is subqueries; don't use those outside of code specific to a non-MySQL DBMS.

JavaScript and CSS
JavaScript and CSS have become omnipresent in front-end code. 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.


 * Learn JavaScript and CSS
 * JavaScript and CSS at Wikibooks.
 * Getting Started with jQuery — A jQuery tutorial.


 * JavaScript and CSS resources
 * JavaScript coding conventions within the MediaWiki community.
 * CSS coding conventions within the MediaWiki community.

MediaWiki
The MediaWiki code base is large and ugly; don't be overwhelmed by it. When you're first starting off, aim to write features or fix bugs which are constrained to a small region of code.


 * MediaWiki primers and must-reads:
 * MediaWiki architecture — 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 resources:
 * Manual:Code — A list of important files and links to more detailed information.
 * Coding conventions — An overview of general coding conventions within the MediaWiki community.
 * Complete documentation (warning: huge page) — Automatically generated documentation from the code and code comments.

Install MediaWiki
Get the latest sources from Subversion, our source control system, before creating patches. See Download from SVN for how to get the sources from SVN.

Follow the instructions in the INSTALL file in the source. You could also read the installation guide.

It's not necessary to download Wikipedia database dumps in order to develop MediaWiki features. In fact, in many cases it's easier to use a near-empty database with a few specially-crafted test pages. However, if for some reason you want to have a copy of Wikipedia, you can get a dump from data dumps.

You may also find that you get an error complaining that access was denied to the wiki database. Make sure that you have created a file AdminSettings.php in your top-level MediaWiki install directory (the same place as LocalSettings.php is found). An AdminSettings.sample file is provided for you to customise - make sure your MySQL administration username and password is set correctly. See Manual:Upgrading for more details.

Rebuilding the link tables may take a long time, particularly if you've installed the English Wikipedia database, which is quite big. (Note also that you can skip the old table if you wish.) See Manual:Database layout on what rebuildall.php is good for.

Note that if you want to create a public mirror of Wikipedia, this probably isn't the best way to go about it. If you do set up a mirror this way, please tweak the code to note that you're looking at a mirror and include links back to the main site. See Forks and Mirrors for more info.

Your first feature
Here are some ideas:
 * Code something that interests you;
 * Write a simple special page to provide some handy information;
 * Write a simple extension (intro video tutorial);
 * Write a parser hook;
 * Fix an annoying little bug.

For more specific suggestions, please come and talk to the developers on. If you already have an idea for a feature you want to implement, it's also a good idea to talk to a senior developer before you start, especially if you're not sure how your feature will affect other parts of the code.

Make your changes against the trunk in Subversion, not a branch, and try to follow the coding standards (if you're writing a brand-new file, stylize.php can help).

When you have a feature ready to go, post a patch in Bugzilla, mark it with the "patch" and "need-review" keywords, and ping the Bugmeister to have it reviewed and committed. This can be a slower process than just committing it yourself, but by doing it once or twice you demonstrate your good faith, and your ability to write reasonably stable code. Relatedly, before you commit your feature, make sure it can be disabled easily.

When you are ready to write a new MediaWiki extension and you'd like to get it deployed on Wikimedia project servers, read Writing an extension for deployment.

Testing
Use E_STRICT in your php.ini to have unnecessary warnings and notices reported early.

When adding features, it's vital to verify you didn't break existing functionality. The usual tool for this is automated testing frameworks. MediaWiki's test suite is still relatively sparse. We have three kinds of tests:


 * Parser tests (see tests/parserTests.php), which only test the parser. Try running  to see how those work.  Everything should pass, in theory.  You can add new tests or fix existing ones by editing tests/parserTests.txt.
 * PHPUnit-based unit tests in the tests/phpunit directory. They are typically run through the phpunit.php script invoked from the aforementioned directory. These tests also include ordinary parser tests, though parserTests.php probably works faster. See Manual:PHP unit testing for PHPUnit setup instructions and further details.
 * Selenium tests are in directory tests/selenium</tt>.

Anyway, if you can't write an automatic test, do manual testing. If you cause breakage too often, people will get annoyed at you, especially if it isn't caught until it goes live on Wikipedia. Revocation of commit access has been threatened in the past occasionally. At the very least, expect serious indignation if you check in syntax errors – try at least loading your wiki, or php maintenance/checkSyntax.php --modified</tt>.

Turning display_startup_errors on
display_startup_errors is off by default on the toolserver. Turning it on within the program under test is too late! So create the following stub and execute that instead.

Posting a patch
If you have created and tested a patch (for example to fix an annoying little bug), get a unified diff of the modified file by using:

svn diff path/to/modified_file.php > my.patch

Then post the patch as an attachment to the appropriate bug report in Bugzilla, and add the  and   keywords to it so developers know to review it and respond to you.

Get help
MediaWiki has a very friendly, large and diverse community. There are multiple places to get help:


 * IRC — Specifically, the channel. The MediaWiki developer community is distributed around the world, and there most likely is someone awake, no matter what your timezone is. Hop in and start talking.
 * Mailing Lists — Since you are looking to be a developer, wikitech-l is where you should be at. You can also browse through the archives to get a feel of how the community operates.