Phabricator/Code

This document describes the development process for 1>phab:|Wikimedia's Phabricator instance. Phabricator is written in PHP, just like MediaWiki, which should help in getting started with development. In this document, we will first take a look at how Wikimedia is using Phabricator, and what to expect during development. Afterwards, there are a few notes on how to get started with the actual development.

Phabricator at Wikimedia
Wikimedia uses a Phabricator instance with minimal changes from upstream. The reason for this is the high development pace of the upstream developers – maintaining local patches is cumbersome. The exceptions to this are extensions, which live in a 1>phab:source/phab-extensions/|separate repository and thus do not need regular merges. Any other changes thus have to pass through upstream. This sounds like a major obstacle, but in practice, the upstream maintainers are very prompt in responding to suggestions.

Wikimedia Phabricator bug workflow
It is helpful to understand the life cycle of a bug before taking on one of the tasks. There are two projects: #phabricator for WMF-specific bugs and #phabricator-upstream for general Phabricator bugs. Software bugs and enhancement requests will typically fall in this second category.

The Phabricator-upstream workboard shows the process that tasks go through before being created upstream:


 * Backlog: this is where new tasks land by default. Stalled tasks can also be found here.


 * Need discussion: sometimes a task will benefit from a discussion, making sure that more Wikimedia contributors are on the same page and the report or the proposal are well argumented.


 * Ready to go: tasks in this column are waiting for someone to copy them to the upstream bug tracker.


 * Upstreamed: this column is where tasks are moved as soon as they have been reported upstream.


 * Wikimedia requests: a few requests reported upstream are made in the name of Wikimedia and get marked with the #wikimedia tag, because we consider that they have a higher relevance.

Once a task has been upstreamed, upstream developers respond with their assessment, and suggestions for how the feature should be implemented. '' At this point a developer can start with the implementation. ''

In some cases, the upstream developers will decide a feature does not fit into their plans. In this case, the task in Wikimedia Phabricator is moved from the #phabricator-upstream project to the #phabricator project, and ends up back into the discussion stage: is this feature important enough to maintain local patches? Once this has been decided, the patch will move to 'Ready to go', and one can start with the implementation.

To prevent disappointment, please do not start with the implementation until it's clear either upstream or the WMF maintainers will accept your patch.

How fast a task is reported upstream may depend of how uncontroversial is (going through the Need Discussion column) and how high is its priority, but it ultimately depends on who takes the time to report it upstream. This is an opt-in process aimed to check the appropriateness and relevance of a task before being created upstream. Anyone with permissions in upstream can create tasks upstream bypassing this process, however, before submitting an upstream task, please read Introduction to contributing to Phabricator, Arcanist and libphutil.

Anyone can discuss upstream bugs and features in https://discourse.phabricator-community.org/ - see https://discourse.phabricator-community.org/t/guide-reporting-a-bug/938 and https://secure.phabricator.com/book/phabcontrib/article/feature_requests/ for more information.

Local changes
As mentioned in the previous section, we try to keep local patches to a minimum. There are limited resources available to maintain patches, and to merge them with changes from upstream. Any local patches therefore have to be discussed within the #phabricator project. It's significantly less work to maintain a phabricator extension, as long as care is taken in avoiding the use of particularly new / unstable APIs from phabricator's core. Although extensions don't require merging and potential code conflicts, they do require testing each time we pull in upstream changes. Phabricator is a very fast moving project and they don't have any frozen APIs which are deemed safe to depend on. At this time we have virtually no modifications to the phabricator core, with the exception of changing the favicon.ico to use Wikimedia colors.

The current code of the Wikimedia Phabricator instance itself:


 * phabricator/phabricator
 * phabricator/arcanist
 * phabricator/libphutil

The current locally-maintained extensions are:

Sprint extension ] -->
 * 1>phab:diffusion/PHEX/|Several customizations in one code repository, such as the MediaWiki OAuth extension (not upstreamed; see the Differential revisions and commits at https://secure.phabricator.com/T5096), Security related code, the MediaWiki Userpage field on Phabricator user pages, etc.

There is also a [https://github.com/wikimedia/phlogiston set of custom scripts to generate Phabricator-derived visual reports]. They are not part of the Wikimedia Phabricator production codebase. See Phlogiston for more information.

Site configuration
Most of the configuration is set through the web interface. Defaults (shared between https://phabricator.wikimedia.org and e.g. https://phab.wmflabs.org) are set using the 1>phab:diffusion/OPUP/browse/production/modules/phabricator/data/fixed_settings.yaml|puppet maniphest.

Setting up
The easiest way to get set up is by using MediaWiki-Vagrant using the 'phabricator' role. Follow the steps on MediaWiki-Vagrant to install MediaWiki-Vagrant, then enable the phabricator role using


 * Access the Phabricator instance at URL: http://phabricator.local.wmftest.net:8080/


 * The Phabricator install is located in `/srv/phabricator/` (?) on the VM. To edit and submit a patch:

Congratulations, you have submitted your first patch!

Using a Labs VM
If you know how to spin up a VM on Labs, and have the rights to do so, you can create an instance with the `phabricator::labs` role. This should give you a basic setup with the same configuration as <tvar|wmflabs>https://phab.wmflabs.org</>.

Migration code from Bugzilla, RT, Mingle, Trello to Phabricator
The 1>phab:diffusion/PHTO/browse/</>|scripts that Wikimedia used for migrating its Bugzilla and RT data to Phabricator are available. Note that the migration code is [<tvar|blogs>https://blogs.gnome.org/aklapper/2014/12/17/welcome-phabricator/</> not bug-free] and that it was only written and used for the specific configurations of Wikimedia's tools. Also note other migration scripts, e.g. the GStreamer project used a phill script by Emanuele Aina to import their data from Bugzilla into Phabricator in 2015.

Data was migrated from Mingle to Phabricator via a script available in <tvar|phab>P129</>.

The scripts to migrate data from Trello to Phabricator are available. See <tvar|1>T821</> for more information.