Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
BlockedExternalDomains
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 4
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
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    private IBlockedDomainStorage $blockedDomainStorage;
37    private BlockedDomainValidator $blockedDomainValidator;
38    private WANObjectCache $wanCache;
39
40    public function __construct(
41        IBlockedDomainStorage $blockedDomainStorage,
42        BlockedDomainValidator $blockedDomainValidator,
43        WANObjectCache $wanCache
44    ) {
45        parent::__construct( 'BlockedExternalDomains' );
46        $this->blockedDomainStorage = $blockedDomainStorage;
47        $this->blockedDomainValidator = $blockedDomainValidator;
48        $this->wanCache = $wanCache;
49    }
50
51    /** @inheritDoc */
52    public function execute( $par ) {
53        if ( ExtensionRegistry::getInstance()->isLoaded( 'CommunityConfiguration' ) ) {
54            $this->getOutput()->redirect(
55                $this->getSpecialPageFactory()
56                    ->getTitleForAlias( 'CommunityConfiguration' )
57                    ->getSubpage( BlockedDomainConfigProvider::PROVIDER_ID )
58                    ->getLocalURL()
59            );
60            return;
61        }
62
63        $this->setHeaders();
64        $this->outputHeader();
65
66        $editor = new BlockedDomainEditor(
67            $this->getContext(), $this->getPageTitle(),
68            $this->wanCache, $this->getLinkRenderer(),
69            $this->blockedDomainStorage, $this->blockedDomainValidator
70        );
71        $editor->execute( $par );
72    }
73
74    /** @inheritDoc */
75    protected function getGroupName() {
76        return 'spam';
77    }
78
79    /** @inheritDoc */
80    public function isListed() {
81        return $this->getConfig()->get( 'AbuseFilterEnableBlockedExternalDomain' );
82    }
83}