Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple MediaWiki extension debugging

I am trying to write my very first MediaWiki extension and need some way to debug it. What is the simplest way to do it? Showing a message, logging into a file etc. would be fine. I just want to slowly progress over the code and see where it breaks and what the content of a variable is.

I've tried (from http://www.mediawiki.org/wiki/Manual:How_to_debug#Useful_debugging_functions)

// ...somewhere in your code
if ( true ) {
    wfDebugLog( 'myext', 'Something is not right: ' . print_r( 'asdf', true ) );
}

in extensions/myext/myext.php and added to LocalSettings.php

require_once( 'extensions/myext/myext.php' );
# debugging on
$wgDebugLogGroups = array(
     'myext'     => 'extensions/myext/myextension.log'
);

but then my Wiki doesn't work at all (error 500). With the above code removed from myext.php everything's fine (with $wgExtensionCredits in myext.php, I can see myext in the Special:Version).

Is it the right thing to do (then what is the mistake) or is there a better/simpler way to start with?

like image 330
texnic Avatar asked Nov 05 '22 05:11

texnic


1 Answers

500 means you have a syntax error or wrong configuration somewhere. Have you followed the instructions at Manual:How to debug and turned on PHP logging, so you can at least see what is causing the error? Alternatively, take a look at your Apache server log.

Also, you'll want to turn on debugging before you load your own extension!

like image 151
lambshaanxy Avatar answered Nov 12 '22 19:11

lambshaanxy