User:DanielRenfro/Debugging

From mediawiki.org

A bunch of useful debugging options all in one place:

//---- Extensions currently being developed/tested. ---------------------------------

// require_once( ... );


//---- Database admin stuff ---------------------------------------------------
// 
// These credentials are sometimes needed to run database-dependent unit tests.
// Otherwise they generally kill the wiki -- use at your own risk.
//

#$wgDBuser = 'root';
#$wgDBpassword = trim( `/path/to/secret/file` );




//---- General debugging directives. -------------------------------------------------
//
// See also:
//  * https://www.mediawiki.org/wiki/Category:Debug_variables
//  * https://www.mediawiki.org/wiki/Manual:How_to_debug
//  * https://www.mediawiki.org/wiki/Debugging_toolbar
//

// Tell PHP to report all errors - might be a little late for some errors, but 
// will help find errors after this directive is set.
error_reporting( E_ALL & ~E_STRICT ); 

// Calling this function will turn off the call-stacks that are output by the 
// xdebug php-module/extension thing.
#xdebug_disable();

// Displays the debugging toolbar; also enables profiling on database queries and
// other useful output. New in 1.19.0
$wgDebugToolbar             = false;

// color the errors
$wgColorErrors				= true;

// show some log stuff in HTML comments on error
$wgDebugComments			= true;

// Whether to generate a debug message for every call to wfProfileIn/Out()
$wgDebugFunctionEntry       = false;

// Print HTTP headers in debugging info - defaults to true
$wgDebugPrintHttpHeaders    = true;

// dump SQL along with errors
$wgDebugDumpSql  			= true;

// Whether to throw PHP notices for some possible error conditions and for 
// deprecated functions.
$wgDevelopmentWarnings		= true;

// If true, show a backtrace for database errors.
$wgShowDBErrorBacktrace		= true;

// Display debug data at the bottom of the main content area; this makes the page 
// long and messy.
$wgShowDebug				= false;

// Whether to show "We're sorry, but there has been a database error." pages.
$wgShowSQLErrors 			= true;

// tell the wiki to show details
$wgShowExceptionDetails		= true;

// help debug the Resource Loader
$wgResourceLoaderDebug 		= true;

// Make all database connections secretly go to localhost
$wgAllDBsAreLocalhost 		= true;


//----Logging ----------------------------------------------------------------------
//
// The debug log file should be not be publicly accessible if it is used, as it
// may contain private data. But it must be in a directory to which PHP run
// within your Web server can write.
//

function barf( /* $args1, $arg2, ...*/ ) {
	foreach ( func_get_args() as $arg ) {
		print_r( $arg );
	}
}

function sbarf( /* $args1, $arg2, ...*/ ) {
	$stringToBarf = "";
	foreach ( func_get_args() as $arg ) {
		$stringToBarf .= print_r( $arg, true ) . "\n";
	}
	return $stringToBarf;
}

// This is to avoid a "bug"/caveat in logging where wfDebugLog looks for a hostname,
// but can't find one because we're accessing things via CLI
putenv( 'COMPUTERNAME=' . getenv('HOSTNAME') );


// When this value is set to a valid path to a file, any calls to wfDebug() 
// will log to this file, along with a lot of other stuff (request, response, etc.)
//
// !!! ---- WARNING - this fill gets big FAST ----- !!!
//
#$wgDebugLogFile = 'logs/debug.log';
 
// These files are for logging specific things. 
// Use wfDebugLog(), located in GlobalSettings.php
#$wgDebugLogGroups = array(
#	'unit-testing' => getenv('HOME') . '/unit-testing.log',
#);

// Use this file to log database errors.
#wgDBerrorLog = $pathToFile;


//----Profiling -------------------------------------------------------------------
// 
// To enable profiling, make sure you have a ./StartProfiler.php in the root of the 
// installation directory. You can look at the StartProfiler.sample file for a sample.
//
// If you are going to store the profiling data to the database (and view it using the
// profileinfo.php script,) then you'll need to apply the appropriate patch like so:
//
//    php maintenance/patchSql.php profiling
// 
// See also: 
//   * http://www.mediawiki.org/wiki/Manual:How_to_debug
//

// Enable looking at the data through profileinfo.php
$wgEnableProfileInfo = false;

//  Only record profiling info for pages that took longer than this 
$wgProfileLimit = 0.1;

//  Don't put non-profiling info into log file 
$wgProfileOnly = false;

//  Log sums from profiling into "profiling" table in db. 
//  If this is 'true', then $wgProfileCallTree MUST be false.
$wgProfileToDatabase = true;

//  If true, print a raw call tree instead of per-function report 
//  If this is 'true', then $wgProfileToDatabase MUST be false.
$wgProfileCallTree = false;

//  Should application server host be put into profiling table 
$wgProfilePerHost = false;

//  Settings for UDP profiler 
$wgUDPProfilerHost = '127.0.0.1';
$wgUDPProfilerPort = '3811';

//  Detects non-matching wfProfileIn/wfProfileOut calls 
$wgDebugProfiling = false;

//  Output debug message on every wfProfileIn/wfProfileOut 
$wgDebugFunctionEntry = 0;

//  Lots of debugging output from SquidUpdate.php 
$wgDebugSquid = false;


//---- Email debugging ------------------------------------------------------

// Disable email so we don't send notifications to other users
// when watched pages are changed. BEWARE changing this value.
//
// If you are working on an extension that requires email setup, consider removing the rows
// in the 'watchlist' table with the sql TRUNCATE command. 
$wgEnableEmail = false;

/*
// Credentials
$wgSMTP = array(
	'host' 			=> 'relay.myserver.com',   			// Where the SMTP server is located
	'IDHost' 		=> '',	// This websites domain name
	'port' 			=> "25",								// Port to use when connecting
	'auth' 			=> false,								// SMTP authentication?
	//'username' 	=> 
	//'password' 	=> 
);
//unset( $wgSMTP );
 */