Use IContextSource::getConfig to access configs stored in globals

Change-Id: Id48a17ee63ea7d9629f103bd1cb6ca2f6489d484
This commit is contained in:
Umherirrender 2021-03-12 20:40:10 +01:00
parent 2df36795c0
commit 63b9527d9c
3 changed files with 8 additions and 12 deletions

View file

@ -2,7 +2,6 @@
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
</rule>
<file>.</file>
<arg name="extensions" value="php" />

View file

@ -30,14 +30,12 @@ class CategoryTreeCategoryViewer extends CategoryViewer {
* @return CategoryTree
*/
private function getCategoryTree() {
global $wgCategoryTreeCategoryPageOptions;
if ( !isset( $this->categorytree ) ) {
if ( !CategoryTreeHooks::shouldForceHeaders() ) {
CategoryTree::setHeaders( $this->getOutput() );
}
$this->categorytree = new CategoryTree( $wgCategoryTreeCategoryPageOptions );
$this->categorytree = new CategoryTree( $this->getConfig()->get( 'CategoryTreeCategoryPageOptions' ) );
}
return $this->categorytree;

View file

@ -45,12 +45,10 @@ class CategoryTreePage extends SpecialPage {
* @return mixed
*/
private function getOption( $name ) {
global $wgCategoryTreeDefaultOptions;
if ( $this->tree ) {
return $this->tree->getOption( $name );
} else {
return $wgCategoryTreeDefaultOptions[$name];
return $this->getConfig()->get( 'CategoryTreeDefaultOptions' )[$name];
}
}
@ -59,8 +57,6 @@ class CategoryTreePage extends SpecialPage {
* @param string|null $par Parameters passed to the page
*/
public function execute( $par ) {
global $wgCategoryTreeDefaultOptions, $wgCategoryTreeSpecialPageOptions;
$this->setHeaders();
$this->addHelpLink( 'Extension:CategoryTree' );
$request = $this->getRequest();
@ -79,11 +75,14 @@ class CategoryTreePage extends SpecialPage {
$this->target = trim( $this->target );
$options = [];
$config = $this->getConfig();
# grab all known options from the request. Normalization is done by the CategoryTree class
foreach ( $wgCategoryTreeDefaultOptions as $option => $default ) {
if ( isset( $wgCategoryTreeSpecialPageOptions[$option] ) ) {
$default = $wgCategoryTreeSpecialPageOptions[$option];
$categoryTreeDefaultOptions = $config->get( 'CategoryTreeDefaultOptions' );
$categoryTreeSpecialPageOptions = $config->get( 'CategoryTreeSpecialPageOptions' );
foreach ( $categoryTreeDefaultOptions as $option => $default ) {
if ( isset( $categoryTreeSpecialPageOptions[$option] ) ) {
$default = $categoryTreeSpecialPageOptions[$option];
}
$options[$option] = $request->getVal( $option, $default );