วิธีการเป็นแฮกเกอร์มีเดียวิกิ

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

บทความนี้เขียนขึ้นเพื่อช่วยให้นักพัฒนาได้เรียนรู้ทักษะพื้นฐานที่จำเป็นเพื่อนำไปสู่การพัฒนาแกนมีเดียวิกิ และส่วนขยายมีเดียวิกิ

เส้นทางหลักในการเริ่มต้นใช้งานกับการพัฒนาวิกิมีเดียคือการร่วมกับโครงการวิกิมีเดียที่ให้คำปรึกษา ทางเลือกหนึ่งที่ไม่มีการให้คำปรึกษาคือการแก้ไขบั๊กเล็กน้อยที่น่ารำคาญ

หากคุณเป็นนักพัฒนาที่มีประสบการณ์ที่มีความคุ้นเคยกับการใช้มีเดียวิกิอยู่แล้ว ให้เยี่ยมชมศูนย์กลางนักพัฒนา แทน

สำหรับวิธีการอื่น ๆ ที่จะได้มีส่วนร่วมในชุมชนวิกิมีเดีย ดู == วิธีการมีส่วนร่วม ==

ภาพรวม

มีเดียวิกิเป็นซอฟต์แวร์ที่ทรงอานุภาพของวิกิพีเดีย, โครงการพี่น้อง และวิกินับพันทั่วโลก

มีเดียวิกิได้รับการเขียนขึ้นในภาษาโปรแกรมพีเอชพี[1] 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.

มีเดียวิกิเขียนขึ้นเป็นหลักสำหรับแลมป์[2] และทำงานในระบบปฏิบัติการส่วนใหญ่ มีเดียวิกิใช้เซิร์ฟเวอร์ฐานข้อมูลมายเอสคิวเอล และมาเรียดีบีเป็นหลัก[3]

การพัฒนาเกิดขึ้นในรูปแบบโอเพนซอร์ส[4] โดยเป็นการประสานงานออนไลน์ส่วนใหญ่ และได้รับการสนับสนุนจากมูลนิธิวิกิมีเดีย แม้ว่าอาสาสมัครพัฒนาชุมชนจะมีส่วนสำคัญเช่นกัน

รายการผู้พัฒนาหลักคือ วิกิเทค-แอล ช่องนักพัฒนาซอฟต์แวร์หลักของไออาร์ซี คือ #mediawiki connect และ #wikimedia-dev connect

  • ซอร์สโค้ด มีการจัดการโดยใช้ระบบควบคุมการแก้ไขกิต[5]
  • รีวิวโค้ด จะดำเนินการใน Gerrit

ทำตามบทแนะนำนี้เพื่อตั้งค่ากิตและเกอร์ริต เพื่อที่จะส่งแพตช์

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.

ตั้งค่าสภาพแวดล้อมการพัฒนาของคุณ

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 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 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: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 .

Communication tips and guidelines

ดูในฐานะนักพัฒนาแก้ไขข้อผิดพลาดในส่วนขยายมีเดียวิกิ รวมทั้งการตรวจสอบ, มอบหมายซอฟต์แวร์กิต, ได้รับการตรวจทานและผสาน รวมถึงการปิดตั๋วบั๊กซิลลา (บัดนี้ถูกแทนที่โดย ฟาบริเคเตอร์ )

Follow these tips to communicate effectively and get help from community members.

Use Phabricator tasks effectively

When you plan to work on a ฟาบริเคเตอร์ 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 ฟาบริเคเตอร์ 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 การสื่อสาร .
    • 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

มีเดียวิกิได้รับการเขียนในภาษาพีเอชพี ดังนั้นคุณจะต้องได้รับความคุ้นเคยกับภาษาพีเอชพี เพื่อที่จะแฮกแกนของมีเดียวิกิ

เรียนรู้ภาษาพีเอชพี
  • สอนการใช้ภาษาพีเอชพี — ใช้ประโยชน์ได้ในภาษาที่ต่างกัน หากคุณไม่ได้มีความรู้เกี่ยวกับภาษาพีเอชพีแต่รู้วิธีการเขียนโปรแกรมในจุดหมายภาษาโปรแกรมอื่น ๆ ภาษาพีเอชพีก็จะเป็นเรื่องง่ายสำหรับคุณที่จะเรียนรู้
  • PHP Programming at Wikibooks.
  • PHP at Wikiversity.
ทรัพยากรภาษาพีเอชพี
สิ่งที่ต้องรู้
  • สคริปต์ maintenance/eval.php ในมีเดียวิกิ ได้เอื้ออำนวยตัวแปลภาษาพีเอชพีพื้นฐาน กับอ็อบเจ็คมีเดียวิกิ และประเภทที่ทำการโหลด
  • นอกจากนี้ สคริปต์ maintenance/shell.php ในมีเดียวิกิเปลี่ยนจาก maintenance/eval.php ที่อิงจากไซเอสเอช (PsySH) ดู Manual:Shell.php

ฐานข้อมูล

คุณสมบัติหลายอย่างจำเป็นต้องมีการจัดการฐานข้อมูลบางส่วน ดังนั้นคุณจึงต้องมีความคุ้นเคยกับมายเอสคิวแอล/มาเรียดีบี

เรียนรู้มายเอสคิวแอล/มาเรียดีบี
ทรัพยากรมายเอสคิวแอล/มาเรียดีบี
สิ่งที่ต้องรู้
  • ทดสอบโค้ดของคุณกับมายเอสคิวแอล/มาเรียดีบี
    • มีเดียวิกิในปัจจุบันใช้มายเอสคิวแอลและมาเรียดีบี เป็นระบบจัดการเว็บไซต์ของฐานข้อมูลหลัก นอกจากนี้ยังสนับสนุนดีบีเอ็มเอสอื่น ๆ เช่น โพสต์เกรสคิวเอล และเอสคิวไลท์ อย่างไรก็ตาม นักพัฒนาเกือบทั้งหมดใช้มายเอสคิวแอล/มาเรียดีบี และไม่ทดสอบดีบีเอ็มเอสอื่น ๆ ซึ่งส่งผลทำลายอยู่เป็นประจำ คุณจึงควรใช้มายเอสคิวแอล/มาเรียดีบีเมื่อทำการทดสอบแพตช์ หากคุณกำลังพยายามที่จะปรับปรุงการสนับสนุนสำหรับฐานข้อมูลอื่นโดยเฉพาะ ในกรณีหลัง ให้แน่ใจว่าคุณระมัดระวังที่จะไม่ทำลายมายเอสคิวแอล/มาเรียดีบี (หรือเขียนคำสั่งที่มีความน่ากลัวที่ไม่มีประสิทธิภาพในนั้น) ตั้งแต่มายเอสคิวแอล/มาเรียดีบีเป็นสิ่งที่คนอื่นใช้

จาวาสคริปต์และซีเอสเอส

จาวาสคริปต์และซีเอสเอส ได้กลายเป็นรหัสส่วนหน้าเว็บไซต์ที่สามารถมองเห็นได้ในบราวเซอร์ที่มีอยู่ทั่วไปทุกหนทุกแห่ง คุณไม่ต้องคุ้นเคยกับจาวาสคริปต์, เจเควียรี และซีเอสเอสในการทำงานกับมีเดียวิกิ แต่คุณอาจต้อง โดยขึ้นอยู่กับสิ่งที่คุณจะเลือกทำงาน

เรียนรู้เกี่ยวกับจาวาสคริปต์และซีเอสเอส
ทรัพยากรจาวาสคริปต์และซีเอสเอส

MediaWiki

ฐานรหัสมีเดียวิกิมีขนาดใหญ่ และมีบางส่วนที่น่าเกลียด ไม่ควรต้องถูกครอบงำโดยสิ่งดังกล่าว เมื่อคุณเริ่มต้นครั้งแรก โดยมุ่งมั่นที่จะเขียนคุณลักษณะหรือแก้ไขบั๊ก ซึ่งโดนเฉพาะอาณาบริเวณขนาดเล็กของรหัสเท่านั้น

ข้อมูลพื้นฐานของมีเดียวิกิและต้องอ่าน
  • สถาปัตยกรรมมีเดียวิกิ — ภาพรวมระดับสูงขององค์ประกอบหลักมีเดียวิกิ และวิธีที่พวกเขาทำงานด้วยกัน
  • Security for developers — ภาพรวมของสาเหตุและวิธีการเขียนโค้ดที่เชื่อถือได้
ทรัพยากรมีเดียวิกิ
  • Manual:Code — รายชื่อของไฟล์ที่สำคัญและเชื่อมโยงไปยังข้อมูลรายละเอียดเพิ่มเติม
  • Manual:Hooks — รายการของตะขอ หากคุณกำลังพยายามที่จะหาสิ่งที่เป็นส่วนหนึ่งของฐานรหัสทำอะไรบางอย่าง ก็มักจะเป็นตำแหน่งที่ดีที่จะเริ่มต้นด้วยการค้นหาตะขอที่เกี่ยวข้อง
  • Manual:Coding conventions — ภาพรวมของการประชุมการเข้ารหัสทั่วไปภายในชุมชนมีเดียวิกิ
  • รหัสเอกสาร (class reference) — สร้างเอกสารจากรหัส และแสดงความคิดเห็นรหัสโดยอัตโนมัติ
  • Manual:How to debug — คู่มือการแก้จุดบกพร่องมีเดียวิกิ
  • Manual:Eval.php — เครื่องมือในการโต้ตอบกับอ็อบเจ็ค ของมีเดียวิกิแบบสด ๆ

ส่วนขยายมีเดียวิกิ

หากคุณเลือกที่จะทำงานในรหัสส่วนขยายมีเดียวิกิ ลิงก์ต่อไปนี้จะให้ข้อมูลเพิ่มเติม

ข้อมูลพื้นฐานเกี่ยวกับส่วนขยายมีเดียวิกิ
ทรัพยากรส่วนขยายมีเดียวิกิ

MediaWiki skins

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

ดูเพิ่ม

Footnotes

  1. มีเดียวิกิทั้งหมดไม่ได้รับการเขียนขึ้นในภาษาพีเอชพี เครื่องมือสนับสนุนบางอย่างเขียนในภาษาอื่น ๆ รวมไปถึง แบทช์ไฟล์, เชลล์สคริปต์, เมคไฟล์ และภาษาไพทอน
  2. มีเดียวิกิทำงานบนแพลตฟอร์มส่วนใหญ่ที่สามารถรองรับพีเอชพีได้ อย่างไรก็ตาม การขาดคุณสมบัติหรือคุณลักษณะระบบปฏิบัติการบางอย่างอาจจำกัดการทำงานหรือประสิทธิภาพการทำงานของมีเดียวิกิบนแพลตฟอร์มที่ไม่ใช่แลมป์
  3. มีเดียวิกิมีการสนับสนุนฐานข้อมูลนอกเหนือจากมายเอสคิวเอล และมาเรียดีบี รวมไปถึงออราเคิล, โพสต์เกรสคิวเอล, เอสคิวแอลไลท์ และไมโครซอฟท์ เอสคิวแอลเซิร์ฟเวอร์
  4. นักพัฒนาซอฟต์แวร์เป็นกลุ่มอาสาสมัครและพนักงาน (หรือผู้รับเหมา) สำหรับองค์กรต่าง ๆ สำหรับรายชื่อผู้ที่ทำงานกับโค้ดมีเดียวิกิ อ่านบทความ ผู้พัฒนา
  5. เรียกดูซอร์สโค้ดและการแก้ไขที่เก็บรหัสที่ https://phabricator.wikimedia.org/diffusion/ หรือดาวน์โหลดซอร์สโค้ดไปยังระบบของคุณโดยใช้เกอร์ริต