Làm thế nào để trở thành một MediaWiki hacker

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

Mục này được viết nhằm giúp những nhà phát triển tìm hiểu những kỹ năng cần thiết để góp phần vào sự phát triển của Những phần quan trọng nhất của MediaWiki và phần mở rộng của MediaWiki.

Con đường chính để bắt đầu với Wikimedia phát triển là để đóng góp cho Các dự án Wikimedia cung cấp cố vấn. Một cách khác mà không cần cố vấn là sửa một lỗi đầu tiên.

Nếu bạn là nhà phát triển có kinh nghiệm, xin mời chuyển sang Developer hub instead.

Các cách khác để tham gia vào cộng đồng Wikimedia, xem mục Làm thế nào để đóng góp

Giới thiệu

MediaWiki là phần mềm cung cấp Wikipedia, các dự án liên quan và hàng ngàn wikis trên toàn thế giới.

Most of MediaWiki and extensions are written in the PHP programming language. JavaScript is used for providing interactive interface elements along with jQuery and Vue.js as client JavaScript libraries.

Some supporting tools are written in other languages, including batch files, shell scripts, makefiles and Python.

MediaWiki chủ yếu được viết cho nền tảng LAMP[1] và chạy trên hầu hết các hệ điều hành. MediaWiki chủ yếu sử dụng các máy chủ cơ sở dữ liệu MySQL hoặc MariaDB. [2]

Sự phát triển xảy ra theo phong cách mã nguồn[3], phần lớn được điều phối trực tuyến và được hỗ trợ bởi Wikimedia Foundation, mặc dù các nhà phát triển cộng đồng tình nguyện cũng đóng một vai trò rất lớn.

The main developer list is wikitech-l. The main developer IRC channels are #mediawiki connect and #wikimedia-dev connect.

Follow this tutorial to set up Git and Gerrit in order to submit patches.

Find or create a task

Before you ever develop a feature or fix a bug in a MediaWiki project, it is important that you do your research about it. This includes:

  1. Search Phabricator if an open or closed Task (Document Types field) already exists. If it doesn't, create one. If this is a very small change, don't create one.
  2. Find and investigate the code that needs to be changed to implement the feature. Comment your findings on the Phabricator Task if they might be helpful to others who implement it or review your changes.
  3. Determine if you can likely add the feature or fix the bug based the code you investigated and the changes needed. If the task is large or complex, you should find something easier and work your way up to eventually be able to handle tasks of that size. If you believe you can complete it, assign yourself to the Task and begin working on it.

Set up your development environment

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.

Bạn cũng có thể dùng thử nghiệm công cụ mwcli để thiết lập Docker bằng một vài lệnh đơn giản và cung cấp chức năng điều phối cơ bản cho bộ chứa Docker của MediaWiki.

Vagrant

  • Vagrant installation - Bước này sẽ cài đặt máy chủ MediaWiki với tất cả yêu cầu bên trong một máy ảo Linux (có thể dùng trên các host Linux, Windows hoặc Mac)

Vagrant cho phép bạn bắt đầu một phiên bản MediaWiki mà bạn có thể phát triển cũng như cho phép bạn thêm và phát triển bất kỳ tiện ích mở rộng nào trong số hơn 250 tiện ích mở rộng - tất cả chỉ bằng một lệnh.

Điều này giúp bạn tiết kiệm thời gian cài đặt và cấu hình so với cài đặt thủ công.

Cài đặt thủ công

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:Coding conventions . 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/Tutorial .

Những mẹo giao tiếp và hướng dẫn

Một nhà phát triển sửa lỗi trong tiện ích mở rộng MediaWiki, bao gồm phân tích, cam kết git, xem xét và hợp nhất tiện ích này cũng như đóng thẻ Bugzilla (hiện được thay thế bằng 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

  • Don't ask to ask...just ask!.
  • 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 Liên lạc .
    • 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.

Phụ lục

Những người đóng góp cho MediaWiki tại nơi làm việc ở Bangalore, Ấn Độ.

PHP

MediaWiki được viết bằng PHP, vì vậy bạn sẽ cần làm quen với PHP để hack lõi của MediaWiki.

Học PHP
  • PHP hướng dẫn — Có sẵn trong nhiều ngôn ngữ khác nhau. Nếu bạn không có kiến ​​thức về PHP nhưng biết cách lập trình bằng các ngôn ngữ lập trình hướng đối tượng khác, PHP sẽ rất dễ dàng để bạn học.
  • Lập trình PHP tại Wikibooks.
  • PHP tại Wikiversity.
PHP tài nguyên
Những điều cần biết
  • Tập lệnh maintenance/eval.php trong MediaWiki cung cấp một trình thông dịch PHP cơ bản với các đối tượng và lớp MediaWiki được tải.
  • Ngoài ra, tập lệnh maintenance/shell.php trong MediaWiki là sự thay thế của maintenance/eval.php dựa trên PsySH, xem Manual:Shell.php

Cơ sở dữ liệu

Nhiều tính năng yêu cầu một số lượng thao tác với cơ sở dữ liệu, vì vậy bạn thường cần phải làm quen với MySQL/MariaDB.

Tìm hiểu MySQL/MariaDB
MySQL/MariaDB tài nguyên
Những điều cần biết
  • Kiểm tra mã của bạn với MySQL/MariaDB.
    • MediaWiki hiện đang sử dụng MySQLMariaDB làm nền tảng cơ sở dữ liệu chính. Nó cũng hỗ trợ các DBMS khác, chẳng hạn như PostgreSQLSQLite. Tuy nhiên, hầu hết tất cả các nhà phát triển đều sử dụng MySQL/MariaDB và không kiểm tra các DB khác, do đó thường xuyên bị hỏng. Do đó, bạn nên sử dụng MySQL/MariaDB khi kiểm tra các bản vá, trừ khi bạn đang cố gắng cải thiện hỗ trợ cho một DB khác. Trong trường hợp sau, hãy đảm bảo rằng bạn cẩn thận để không phá vỡ MySQL/MariaDB (hoặc viết các truy vấn cực kỳ kém hiệu quả trong đó), vì MySQL/MariaDB là thứ mà mọi người khác sử dụng.

JavaScript và CSS

JavaScript và CSS đã trở nên phổ biến trong mã giao diện người dùng. Bạn không phải quen thuộc với JavaScript, jQuery và CSS để làm việc trên MediaWiki, nhưng bạn có thể cần, tùy thuộc vào những gì bạn chọn để làm việc.

Learn JavaScript and CSS
JavaScript and CSS resources

MediaWiki

Introduction to MediaWiki core concepts

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 basics and must-reads
MediaWiki resources

MediaWiki extensions

Introduction to MediaWiki extensions

If you choose to work on MediaWiki extensions code, the following links provide more information.

MediaWiki extensions basics:
MediaWiki extensions resources:

MediaWiki skins

Manual:How to make a MediaWiki skin is helpful if you choose to work on MediaWiki skins.

See also

Footnotes

  1. MediaWiki chạy trên hầu hết các nền tảng có thể hỗ trợ PHP, tuy nhiên, việc thiếu một số tiện ích hoặc tính năng hệ điều hành nhất định có thể hạn chế chức năng hoặc hiệu suất của MediaWiki trên các nền tảng không phải LAMP.
  2. MediaWiki có hỗ trợ cho DBMS ngoài MySQL MariaDB, bao gồm PostgreSQL, SQLite
  3. Phát triển là sự kết hợp của các tình nguyện viên và nhân viên được trả lương (hoặc nhà thầu) cho các tổ chức khác nhau. Để biết danh sách đầy đủ những người làm việc trên mã MediaWiki, hãy đọc bài viết Nhà phát triển .
  4. Browse the source code and revisions of code repositories at https://phabricator.wikimedia.org/diffusion/ or download the source code to your system by using Gerrit.