如何从mediawiki扩展获取http标头


How do I get the http headers from a mediawiki extension?

问题

我想检查一下媒体wiki扩展中的http头。具体来说,如果其中一个标头存在,我将采取行动。

背景

我是php和mediawiki的新手。我正在mediawiki中进行第二个扩展。如果某个特定的http标头是页面请求的一部分,我想采取特定的操作。我现在确信钩子在正确的时间被调用,但不幸的是,我似乎无法掌握http头。

$extensionObject = new MyExtension;
$wgHooks['ArticlePageDataBefore'][] = array($extensionObject, 'onArticlePageDataBefore');
class MyExtension{
    public function onArticlePageDataBefore( &$article, &$fields ) {
        $headers =mygetallheaders();
        ...do something with the headers
        return true;
    }
    public function mygetallheaders()   {
        ...this is the function I am trying to write
        return $headers;
    }

软件堆栈

  • MediaWiki:1.20.2
  • PHP:5.3.3(apache2handler(
  • MySQL:5.1.61

目前已尝试

以下两种方法都返回一个空数组

  • apache_request_headers
  • 获取所有标头

$_SERVER变量为空

感谢您的帮助

public function onArticlePageDataBefore( &$article, &$fields ) {
    global $wgRequest;
    if ( $wgRequest->getHeader( 'My-Cool-Header' ) == 42 {
            PROFIT!
    }
    return true;
}