Hi All,
There is an index of PHP runtime errors encountered in MediaWiki 1.6.6 now online at http://files.nickj.org/MediaWiki/runtime-errors/
These errors are of varying severity, and hopefully most should be fairly painless to resolve. A lot of them seem to be "Non-static method Foo::Bar() should not be called statically".
The reporting level used deliberately included E_STRICT, which is PHP's fussiest level, although the things it finds in my personal experience tend nevertheless to be worth fixing to ensure correctness and to help prevent problems.
The index contains a bit over 80 files. Each file is a text file that corresponds to one runtime error.
How to read the files: * The name of each file tells you the name of file that the runtime error occurred in, and the line it occurred on. For example "SpecialLog.php-35.txt" means it happened on line 35 of MediaWiki's SpecialLog.php * The contents of each file include the details of the error, the "Action" attribute, and a full backtrace explaining how we got there.
If you wish to recreate this index, you can, and here's how (note: these steps assume a UNIX-like system):
# Create somewhere for the files to be stored, needs to be public (so that apache can write to it) : mkdir /tmp/errors chmod a+wrx /tmp/errors
Then add this to the end of your wiki's LocalSettings.php (note: the E_STRICT level assumes PHP5) :
================================================================================== // -------------------- error logging --------------------------- // want all warnings error_reporting (E_ALL | E_STRICT);
set_error_handler( 'error_handler' );
function error_handler ($type, $message, $file=__FILE__, $line=__LINE__) { global $action, $PHP_SELF;
// PHP 5.1.4 does away with this error, so ignore: if ($message == "var: Deprecated. Please use the public/private/protected modifiers") return;
$save_as = "/tmp/errors/" . substr(strrchr($file,"/"),1) . "-" . $line . ".txt";
$backtrace = DBG_GetBacktrace();
file_put_contents ($save_as, "Page : $PHP_SELF\n" ."Message : $message\n" .(isset($action)?"Action : $action\n":"") ."Type : $type\n" ."File : $file\n" ."Line : $line\n" ."Backtrace: \n$backtrace"); }
function DBG_GetBacktrace() { $s = ''; $MAXSTRLEN = 64;
$traceArr = debug_backtrace(); // remove the error handler and this function from the backtrace. array_shift($traceArr); array_shift($traceArr); $tabs = sizeof($traceArr)-1; foreach($traceArr as $arr) { for ($i=0; $i < $tabs; $i++) $s .= ' '; $tabs -= 1; if (isset($arr['class'])) $s .= $arr['class'] . '.'; $args = array(); if(!empty($arr['args'])) foreach($arr['args'] as $v) { if (is_null($v)) $args[] = 'null'; else if (is_array($v)) $args[] = 'Array['.sizeof($v).']'; else if (is_object($v)) $args[] = 'Object:'.get_class($v); else if (is_bool($v)) $args[] = $v ? 'true' : 'false'; else { $v = (string) @$v; $str = substr($v,0,$MAXSTRLEN); if (strlen($v) > $MAXSTRLEN) $str .= '...'; $args[] = """.$str."""; } } $s .= $arr['function'].'('.implode(', ',$args).')'; $Line = (isset($arr['line'])? $arr['line'] : "unknown"); $File = (isset($arr['file'])? $arr['file'] : "unknown"); $s .= " # line $Line, file: $File\n"; } return $s; } ==================================================================================
Then just click around your wiki for a minute or two. I also ran the wiki fuzz-tester for a few minutes to try and catch some of the more obscure stuff.
All the best, Nick.
wikitech-l@lists.wikimedia.org