aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2020-10-12 21:38:49 +0200
committerUmherirrender <umherirrender_de.wp@web.de>2020-10-12 23:03:18 +0200
commit3919941386fde61aeb5d9c51a078a11c82e3bb24 (patch)
tree8c197f9250e0f0fb4a227c43e240670919c65efc
parenta6be801fc6331a6a6b96f02f368750200d50ab09 (diff)
downloadmediawikicore-3919941386fde61aeb5d9c51a078a11c82e3bb24.tar.gz
mediawikicore-3919941386fde61aeb5d9c51a078a11c82e3bb24.zip
Inject RepoGroup into SpecialWantedfiles
This covers only directly used services by this special page and pager Services used by the base class are not part of this patch set Bug: T259960 Change-Id: I4a55c8e84df4855d784ab98c33064a025960362f
-rw-r--r--includes/specialpage/SpecialPageFactory.php7
-rw-r--r--includes/specials/SpecialWantedfiles.php18
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() {