diff options
-rw-r--r-- | includes/specialpage/SpecialPageFactory.php | 7 | ||||
-rw-r--r-- | includes/specials/SpecialWantedfiles.php | 18 |
2 files changed, 20 insertions, 5 deletions
diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 768a1db7570d..06a2d8956c7c 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -162,7 +162,12 @@ class SpecialPageFactory { ] ], 'Wantedcategories' => \SpecialWantedCategories::class, - 'Wantedfiles' => \WantedFilesPage::class, + 'Wantedfiles' => [ + 'class' => \WantedFilesPage::class, + 'services' => [ + 'RepoGroup', + ] + ], 'Wantedpages' => [ 'class' => \WantedPagesPage::class, 'services' => [ diff --git a/includes/specials/SpecialWantedfiles.php b/includes/specials/SpecialWantedfiles.php index 6822d76958f1..2eb5ddd60959 100644 --- a/includes/specials/SpecialWantedfiles.php +++ b/includes/specials/SpecialWantedfiles.php @@ -33,8 +33,18 @@ use MediaWiki\MediaWikiServices; */ class WantedFilesPage extends WantedQueryPage { - public function __construct( $name = 'Wantedfiles' ) { - parent::__construct( $name ); + /** @var RepoGroup */ + private $repoGroup; + + /** + * @param RepoGroup|string $repoGroup + */ + public function __construct( $repoGroup ) { + parent::__construct( is_string( $repoGroup ) ? $repoGroup : 'Wantedfiles' ); + // This class is extended and therefor fallback to global state - T265301 + $this->repoGroup = $repoGroup instanceof RepoGroup + ? $repoGroup + : MediaWikiServices::getInstance()->getRepoGroup(); } protected function getPageHeader() { @@ -79,7 +89,7 @@ class WantedFilesPage extends WantedQueryPage { * @return bool */ protected function likelyToHaveFalsePositives() { - return MediaWikiServices::getInstance()->getRepoGroup()->hasForeignRepos(); + return $this->repoGroup->hasForeignRepos(); } /** @@ -106,7 +116,7 @@ class WantedFilesPage extends WantedQueryPage { * @return bool */ protected function existenceCheck( Title $title ) { - return (bool)MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title ); + return (bool)$this->repoGroup->findFile( $title ); } public function getQueryInfo() { |