Manual:How to debug/id

Halaman ini memberikan pengantar dasar untuk mengawakutu perangkat lunak MediaWiki.

Salah satu hal pertama yang akan Anda sadari adalah "echo" biasanya tidak bekerja; ini merupakan bagian dari desain umumnya.



Galat PHP
Untuk melihat galat PHP, tambahkan ini ke baris kedua dari atas (tepat di bawah ) di :

Atau tetapkan di :

Atau tetapkan di .htaccess:

Ini akan menyebabkan galat PHP ditampilkan di halaman. Ini bisa mempermudah penyerang mencari cara masuk ke peladen Anda, jadi matikanlah ketika Anda telah menemukan masalahnya.

Ingatlah bahwa galat PHP yang fatal mungkin terjadi sebelum baris di atas dieksekusi, atau mungkin menyebabkan baris tersebut tidak bisa ditampilkan. Galat PHP fatal biasanya dicatat di log galat Apache – periksa pengaturan  di   (atau gunakan  ).

There are several configuration options to aid debugging. The following are all  by default. Enable them by setting them to  in your :


 * Enable more details (like a stack trace) to be shown on the "Fatal error" page.
 * Shows a toolbar on the page with profiling, log messages and more.
 * Adds the "log messages" part of wgDebugToolbar as a raw list to the page.
 * MediaWiki will throw notices for some possible error conditions and for deprecated functions.



Mengubah display_startup_errors ke on
Some providers turn  off, which hides the errors even if you raise the   level. Turning it on within the program is too late! Instead you'll have to create a wrapper file around your file. In the case of MediaWiki you can just add this on top of mediawiki/index.php:

Pada lingkungan lain:



Galat SQL
To log all SQL queries, rather than just the one that raised the exception, set in  :

Prior to MediaWiki 1.32, you needed to set and  to see details of database exceptions in the HTML output:



Pengawakekutu
For the most common setup (using MediaWiki-Vagrant and PhpStorm) see.

Zend
If you are using the Zend PHP interpreter, you can debug your code with XDebug. MediaWiki-Vagrant has built in settings for this. If you're not using MediaWiki-Vagrant, but your setup is similar, you can reuse those values. In some cases (e.g. due to a firewall), you may have to use the IDE on the same machine as the web server. In this case, you can simply set:

See the XDebug documentation for more information.

To debug a command-line script (e.g. PHPUnit, or a maintenance script) on MediaWiki-Vagrant, use:

Adjust the script, parameters, and remote host (it should be the IP of the computer where your IP is, 10.0.2.2 should work for MediaWiki-Vagrant) as needed.

Pengelogan
For much greater detail, you need to profile and log errors.



Mempersiapkan berkas log awakekutu
To save errors and debugging information to a log, add  to the   file. Change the value to a text file where you want to save the debug trace output.

The MediaWiki software must have permissions from your operating system to create and write to this file, for example in a default Ubuntu install it runs as user & group :. Here's a sample setting:

This file will contain much debug information from MediaWiki core and extensions. Some subsystems write to custom logs, see #Creating a custom log file to capture their output.

Database transaction lifecycle debugging can be enabled for some databases with.



Menciptakan berkas log ubahsuaian
Prior to MediaWiki 1.32, to create a custom log file that only holds your specific debug statements, use the  function. This function takes two arguments, the text string to log and the path to the log file:



Menciptakan kelompok log ubahsuaian
If you're debugging several different components, it may be useful to direct certain log groups to write to a separate file. See for more information.

To set up custom log groups, use the following to LocalSettings.php:

To log to one of these groups, call  like this:



Pengelogan terstruktur
Structured logging allows you to include fields in your log records. See for more information.

Statistik
Advanced client-side logging can be performed with, which requires a complex setup and careful inspection of privacy issues.

Simple counting of certain kind of events is possible (since MediaWiki 1.25) using StatsD. StatsD offers meters, gauges, counters, and timing metrics.

Contoh penggunaan:

The metrics can be sent to a StatsD server, which may be specified via the  configuration variable. (If not set, the metrics are discarded.) You can work with StatsD locally (without needing a Graphite server) by starting a StatsD server and configuring it with the "backends/console" backend, which will output metrics to the console.

As of MediaWiki 1.25,  is a shortcut for the   method on the main   instance.



Mengirimkan data awakekutu ke sebuah komentar HTML pada keluaran
This may occasionally be useful when supporting a non-technical end-user. It's more secure than exposing the debug log file to the web, since the output only contains private data for the current user. But it's not ideal for development use since data is lost on fatal errors and redirects. Use on production sites is not recommended. Debug comments reveal information in page views which could potentially expose security risks.





Bekerja secara langsung dengan objek MediaWiki
is an interactive script to evaluate and interact with MediaWiki objects and functions in a fully initialized environment.

$ php maintenance/eval.php > print wfMessage("Recentchanges")->plain; Recent changes

The portable virtual machine integrates the interactive PHP shell   (when using Zend).



Pembaruan yang dapat dipanggil
Code embedded in the  function, such as   in , is not executed during the web request, so no error message will be displayed if it fails. For debugging, it may be helpful to temporarily remove the code from within the function so that it is executed live.



Pengawakutuan sisi klien (JavaScript)
Wikipedia menyediakan beragam peralatan untuk mengawakutu JavaScript sisi klien. Selain peralatan MediaWiki, tersedia pula teknik-teknik lain untuk membantu mendiagnosis interaksi klien.

Perkakas:


 * ResourceLoader menawarkan cara memastikan JavaScript bisa dibaca dengan mudah oleh peralatan sisi klien.
 * Bukan konsol penjelajah Anda. Banyak skrip mediawiki sisi klien mencatat pesan galat di konsol menggunakan ResourceLoader, yang menyediakan cara berorientasi keamanan untuk mencatat ke konsol klien. Selain fungsi log JavaScript bawaan, ResourceLoader menyediakan pemeriksaan apakah konsol tersedia dan proses log tidak menyebabkan galat juga. ResourceLoader/Arsitektur#Debug_mode juga menjelaskan fitur ini.
 * Peralatan penjelajah mungkin menyediakan fungsionalitas bawaan untuk mengawakutu skrip sisi klien.
 * Network tracers, like Wireshark can provide insight into the script that is being provided by a page.
 * You can add  to your URL as in https://www.mediawiki.org/wiki/MediaWiki?debug=true to get more detailed information for debugging via your browser's console



Lihat pula

 * ResourceLoader: ResourceLoader/Mengembangkan dengan ResourceLoader#Pengawakutuan
 * Semua variabel konfigurasi yang berhubungan dengan pengawakutuan/pengelogan: Manual:Pengaturan konfigurasi#Debug/logging
 * Kiat pengawakutuan berguna:  (berakhir dengan pesan yang diberikan dan mencetak tumpukan pemanggilan)
 * wikitech:Debugging in production - pengawakekutuan di kluster produksi Wikimedia
 * Kiat pengawakutuan berguna:  (berakhir dengan pesan yang diberikan dan mencetak tumpukan pemanggilan)
 * wikitech:Debugging in production - pengawakekutuan di kluster produksi Wikimedia
 * wikitech:Debugging in production - pengawakekutuan di kluster produksi Wikimedia
 * wikitech:Debugging in production - pengawakekutuan di kluster produksi Wikimedia