如果说,什么是诞生的喜悦,那一定是另一物的死去.

Mediawiki 调试

来自森亮号航海见识 {SLboat Insight;}
跳转至: 导航搜索

更多研究

Mediawiki 调试/调试日志

发现

  • 看起来官方做了很多有意思的机制

参考方法

http://www.mediawiki.org/wiki/Manual:How_to_debug

大概原理

开启php的调试输出,在mediawiki里开启一些相关的调试标签。

经验

  • 调试完毕后可以设置回正常,这样不影响正常的浏览-毕竟错误不是那么好看
  • error_reporting真是个非常有趣非常神奇的东西

输出调试日志

重新php日志调试信息

  • 重写php调试日志设置,将其放置到LocalSettings.php的头部进行提前宣告
/* 森亮号大船调试使用 */
# 调试信息
error_reporting( -1 ); //设置错误啰嗦程度,这看起来是最高的
ini_set( 'display_errors', 1 ); //霸占php.ini里的错误显示设置,强制显示,它会显示所有信息给客户端
/* 森亮号大船调试使用结束 */

$wgShowExceptionDetails

  • 如果必要的话可以显示错误堆栈信息,它非常有用
$wgShowExceptionDetails = true; //显示错误堆栈信息
开启它之前的效果:
JustCapIt5549.jpg
开启它之后得到的玩意!
JustCapIt5548.jpg
它的最后调试很顺利!哇哈!-感谢调试玩意
扩展:Translate/消息组管理

最终的可调制性代码

/* 森亮号大船调试使用 */
# 调试信息
error_reporting( -1 ); //设置错误啰嗦程度,这看起来是最高的
ini_set( 'display_errors', 1 ); //霸占php.ini里的错误显示设置,强制显示
$wgShowExceptionDetails = true;  //显示错误堆栈信息,它很酷
/* 森亮号大船调试使用结束 */

官方页面

http://www.mediawiki.org/wiki/Manual:How_to_debug

见识

Manual:How to debug - MediaWiki 沿途见识[1]

PHP errors

To see PHP errors, add this to the very top of LocalSettings.php:
error_reporting( -1 );
ini_set( 'display_errors', 1 );
Or set it in php.ini:
error_reporting = E_ALL | E_STRICT
display_errors = On
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 error_log setting in php.ini (or use phpinfo())
There are several configuration options to aid debugging. The following are all false by default. Enable them by setting them to true in your LocalSettings.php:
$wgShowExceptionDetails Enable more details (like a stack trace) to be shown on the "Fatal error" page.
$wgDebugToolbar Shows a toolbar on the page with profiling, log messages and more.
$wgShowDebug Adds the "log messages" part of wgDebugToolbar as a raw list to the page.

Wikipedia Developers - Debug toolbar 沿途见识[2]

This is a pretty spiffy-looking upgrade from the old $wgDebugComments mode
(which exported debug log items into at the end of
each page). This exports the log items, and a few other bits of info such
as query data, into JSON which then gets rendered as an attractive
slide-out panel at the bottom of the window.

It can use some tweaking, but I think it's going to be helpful for a lot of
devs -- please try it out and give John your feedback! (Warning: current
version may have some HTML injection vectors, don't use on production
sites.)

Enable:
$wgDebugToolbar = true;

引用信息

以下是[Mediawiki 调试]所有用到的引用信息,向这些伟大的家伙致敬:
  1. ^ Manual:How to debug - MediaWiki, 见识于2013-4-16 22:10
  2. ^ Wikipedia Developers - Debug toolbar, 见识于2013-4-20 0:5