Manual:How to debug/pt-br

Esta página fornece uma introdução básica à depuração do software MediaWiki.

Uma das primeiras coisas que você vai notar é que o "eco" geralmente não funciona; isso é parte do projeto geral.

Erros do PHP
Para visualizar os erros de PHP, cole o seguinte código na parte inferior do arquivo |LocalSettings.php

Ou defina no arquivo |php.ini:

Or set in .htaccess:

This will cause PHP errors to be shown on-page. This might make it easier for attackers to find a way into your server, so disable it again when you have found the problem.

Note that fatal PHP errors may happen before the lines above are ever executed, or may prevent them from being shown. Fatal PHP errors are usually logged to Apache's error log – check the  setting in   (or use  )

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.

Turning display_startup_errors 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:

Em outros ambientes:

Erros de SQL
To display SQL errors in error messages instead of "(SQL query hidden)", add the following to :

You can also enable backtrace on SQL error by setting :

Logging
Para maiores detalhes, você precisa criar um perfil e registrar erros.

Criação de um arquivo de log de debug
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 to capture their output.

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

Criação de um arquivo de log personalizado
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:

Criação de grupos de log personalizados
If you're debugging several different components, it may be useful to direct certain log groups to write to a separate file.

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

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

Enviar dados de depuração em um comentário HTML na saída
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.


 * Manual:$wgDebugComments

Trabalhando com objetos do MediaWiki
eval.php é um script interativo para avaliar e interagir com objetos e funções do MediaWiki em um ambiente totalmente inicializado.

 $ php maintenance/eval.php > print wfMessage("Recentchanges")->plain; Recent changes A máquina virtual portátil MediaWiki-Vagrant integra o shell interativo PHP.

Ver também

 * Manual:Profiling
 * ResourceLoader: ResourceLoader/Developing with ResourceLoader
 * All configuration variables related to debugging/logging: Manual:Configuration settings#Debug/logging
 * Useful debugging tip:  (dies with the given message and prints the callstack)
 * Manual:Errors and Symptoms
 * Category:Debug variables