Create a new RequestContext to use its OutputPage and Skin members instead of messing with global ones
This commit is contained in:
parent
cf6ed78ed5
commit
ffd52683c8
2 changed files with 21 additions and 3 deletions
|
|
@ -173,6 +173,24 @@ abstract class ApiBase {
|
|||
return $this->getResult()->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RequestContext object to use e.g. for calls to other parts
|
||||
* the software.
|
||||
* The object will have the WebRequest and the User object set to the ones
|
||||
* used in this instance.
|
||||
*
|
||||
* @return RequestContext
|
||||
*/
|
||||
public function createContext() {
|
||||
global $wgUser;
|
||||
|
||||
$context = new RequestContext;
|
||||
$context->setRequest( $this->getMain()->getRequest() );
|
||||
$context->setUser( $wgUser ); /// @todo FIXME: we should store the User object
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set warning section for this module. Users should monitor this
|
||||
* section to notice any changes in API. Multiple calls to this
|
||||
|
|
|
|||
|
|
@ -373,9 +373,9 @@ class ApiParse extends ApiBase {
|
|||
}
|
||||
|
||||
private function categoriesHtml( $categories ) {
|
||||
global $wgOut, $wgUser;
|
||||
$wgOut->addCategoryLinks( $categories );
|
||||
return $wgUser->getSkin()->getCategories();
|
||||
$context = $this->createContext();
|
||||
$context->getOutput()->addCategoryLinks( $categories );
|
||||
return $context->getSkin()->getCategories();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue