Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
BlockedExternalDomains
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 5
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 doesWrites
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
6
 getGroupName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isListed
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20namespace MediaWiki\Extension\AbuseFilter\Special;
21
22use MediaWiki\Extension\AbuseFilter\BlockedDomains\BlockedDomainConfigProvider;
23use MediaWiki\Extension\AbuseFilter\BlockedDomains\BlockedDomainEditor;
24use MediaWiki\Extension\AbuseFilter\BlockedDomains\BlockedDomainValidator;
25use MediaWiki\Extension\AbuseFilter\BlockedDomains\IBlockedDomainStorage;
26use MediaWiki\Registration\ExtensionRegistry;
27use MediaWiki\SpecialPage\SpecialPage;
28use Wikimedia\ObjectCache\WANObjectCache;
29
30/**
31 * List and manage blocked external domains
32 *
33 * @ingroup SpecialPage
34 */
35class BlockedExternalDomains extends SpecialPage {
36
37    public function __construct(
38        private readonly IBlockedDomainStorage $blockedDomainStorage,
39        private readonly BlockedDomainValidator $blockedDomainValidator,
40        private readonly WANObjectCache $wanCache
41    ) {
42        parent::__construct( 'BlockedExternalDomains' );
43    }
44
45    /** @inheritDoc */
46    public function doesWrites() {
47        return !ExtensionRegistry::getInstance()->isLoaded( 'CommunityConfiguration' );
48    }
49
50    /** @inheritDoc */
51    public function execute( $par ) {
52        if ( ExtensionRegistry::getInstance()->isLoaded( 'CommunityConfiguration' ) ) {
53            $this->getOutput()->redirect(
54                $this->getSpecialPageFactory()
55                    ->getTitleForAlias( 'CommunityConfiguration' )
56                    ->getSubpage( BlockedDomainConfigProvider::PROVIDER_ID )
57                    ->getLocalURL()
58            );
59            return;
60        }
61
62        $this->setHeaders();
63        $this->outputHeader();
64
65        $editor = new BlockedDomainEditor(
66            $this->getContext(), $this->getPageTitle(),
67            $this->wanCache, $this->getLinkRenderer(),
68            $this->blockedDomainStorage, $this->blockedDomainValidator
69        );
70        $editor->execute( $par );
71    }
72
73    /** @inheritDoc */
74    protected function getGroupName() {
75        return 'spam';
76    }
77
78    /** @inheritDoc */
79    public function isListed() {
80        return $this->getConfig()->get( 'AbuseFilterEnableBlockedExternalDomain' );
81    }
82}