mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SpamBlacklist
synced 2024-12-03 11:16:16 +00:00
Namespace extension
Change-Id: Ie53302078d5f405eaa6caef3b7ef4daebf47d877
This commit is contained in:
parent
1f10a3f7fc
commit
52bb0939d9
|
@ -27,7 +27,7 @@
|
|||
"spamblacklist": "spamblacklistlog"
|
||||
},
|
||||
"LogActionsHandlers": {
|
||||
"spamblacklist/*": "SpamBlacklistLogFormatter"
|
||||
"spamblacklist/*": "MediaWiki\\Extension\\SpamBlacklist\\SpamBlacklistLogFormatter"
|
||||
},
|
||||
"GrantPermissions": {
|
||||
"viewrestrictedlogs": {
|
||||
|
@ -35,7 +35,7 @@
|
|||
}
|
||||
},
|
||||
"APIModules": {
|
||||
"spamblacklist": "ApiSpamBlacklist"
|
||||
"spamblacklist": "MediaWiki\\Extension\\SpamBlacklist\\ApiSpamBlacklist"
|
||||
},
|
||||
"MessagesDirs": {
|
||||
"SpamBlackList": [
|
||||
|
@ -44,14 +44,11 @@
|
|||
]
|
||||
},
|
||||
"AutoloadClasses": {
|
||||
"ApiSpamBlacklist": "includes/ApiSpamBlacklist.php",
|
||||
"BaseBlacklist": "includes/BaseBlacklist.php",
|
||||
"EmailBlacklist": "includes/EmailBlacklist.php",
|
||||
"SpamBlacklistHooks": "includes/SpamBlacklistHooks.php",
|
||||
"SpamBlacklist": "includes/SpamBlacklist.php",
|
||||
"SpamBlacklistLogFormatter": "includes/SpamBlacklistLogFormatter.php",
|
||||
"SpamRegexBatch": "includes/SpamRegexBatch.php",
|
||||
"SpamBlacklistPreAuthenticationProvider": "includes/SpamBlacklistPreAuthenticationProvider.php"
|
||||
"MediaWiki\\Extension\\SpamBlacklist\\BaseBlacklist": "includes/BaseBlacklist.php"
|
||||
},
|
||||
"AutoloadNamespaces": {
|
||||
"MediaWiki\\Extension\\SpamBlacklist\\": "includes/"
|
||||
},
|
||||
"ResourceModules": {
|
||||
"ext.spamBlacklist.visualEditor": {
|
||||
|
@ -83,7 +80,7 @@
|
|||
},
|
||||
"HookHandlers": {
|
||||
"SpamBlacklistHookHandler": {
|
||||
"class": "SpamBlacklistHooks"
|
||||
"class": "MediaWiki\\Extension\\SpamBlacklist\\Hooks"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
@ -104,7 +101,7 @@
|
|||
"AuthManagerAutoConfig": {
|
||||
"preauth": {
|
||||
"SpamBlacklistPreAuthenticationProvider": {
|
||||
"class": "SpamBlacklistPreAuthenticationProvider"
|
||||
"class": "MediaWiki\\Extension\\SpamBlacklist\\SpamBlacklistPreAuthenticationProvider"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
namespace MediaWiki\Extension\SpamBlacklist;
|
||||
|
||||
use ApiBase;
|
||||
use ApiResult;
|
||||
use Wikimedia\ParamValidator\ParamValidator;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +48,7 @@ class ApiSpamBlacklist extends ApiBase {
|
|||
if ( $matches !== false ) {
|
||||
// this url is blacklisted.
|
||||
$res->addValue( 'spamblacklist', 'result', 'blacklisted' );
|
||||
$res->setIndexedTagName( $matches, 'match' );
|
||||
ApiResult::setIndexedTagName( $matches, 'match' );
|
||||
$res->addValue( 'spamblacklist', 'matches', $matches );
|
||||
} else {
|
||||
// not blacklisted
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\SpamBlacklist;
|
||||
|
||||
use Exception;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
use ObjectCache;
|
||||
use TextContent;
|
||||
use Title;
|
||||
use User;
|
||||
|
||||
/**
|
||||
* Base class for different kinds of blacklists
|
||||
|
@ -44,8 +51,8 @@ abstract class BaseBlacklist {
|
|||
* @var array
|
||||
*/
|
||||
private static $blacklistTypes = [
|
||||
'spam' => 'SpamBlacklist',
|
||||
'email' => 'EmailBlacklist',
|
||||
'spam' => SpamBlacklist::class,
|
||||
'email' => EmailBlacklist::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -446,3 +453,5 @@ abstract class BaseBlacklist {
|
|||
// subclass this
|
||||
}
|
||||
}
|
||||
|
||||
class_alias( BaseBlacklist::class, 'BaseBlacklist' );
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\SpamBlacklist;
|
||||
|
||||
use LogicException;
|
||||
use Title;
|
||||
use User;
|
||||
use Wikimedia\AtEase\AtEase;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,21 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\SpamBlacklist;
|
||||
|
||||
use ApiMessage;
|
||||
use Content;
|
||||
use ContentHandler;
|
||||
use EditPage;
|
||||
use Html;
|
||||
use IContextSource;
|
||||
use LogicException;
|
||||
use MediaWiki\Hook\EditFilterHook;
|
||||
use MediaWiki\Hook\EditFilterMergedContentHook;
|
||||
use MediaWiki\Hook\UploadVerifyUploadHook;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use MediaWiki\Storage\EditResult;
|
||||
use MediaWiki\Storage\Hook\PageSaveCompleteHook;
|
||||
use MediaWiki\Storage\Hook\ParserOutputStashForEditHook;
|
||||
use MediaWiki\User\Hook\UserCanSendEmailHook;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use Message;
|
||||
use MessageSpecifier;
|
||||
use ParserOptions;
|
||||
use ParserOutput;
|
||||
use Status;
|
||||
use UploadBase;
|
||||
use User;
|
||||
use Wikimedia\Assert\PreconditionException;
|
||||
use WikiPage;
|
||||
|
||||
/**
|
||||
* Hooks for the spam blacklist extension
|
||||
*/
|
||||
class SpamBlacklistHooks implements
|
||||
\MediaWiki\Hook\EditFilterHook,
|
||||
\MediaWiki\Hook\EditFilterMergedContentHook,
|
||||
\MediaWiki\Hook\UploadVerifyUploadHook,
|
||||
\MediaWiki\Storage\Hook\PageSaveCompleteHook,
|
||||
\MediaWiki\Storage\Hook\ParserOutputStashForEditHook,
|
||||
\MediaWiki\User\Hook\UserCanSendEmailHook
|
||||
class Hooks implements
|
||||
EditFilterHook,
|
||||
EditFilterMergedContentHook,
|
||||
UploadVerifyUploadHook,
|
||||
PageSaveCompleteHook,
|
||||
ParserOutputStashForEditHook,
|
||||
UserCanSendEmailHook
|
||||
{
|
||||
|
||||
/**
|
|
@ -1,7 +1,16 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\CheckUser\Hooks;
|
||||
namespace MediaWiki\Extension\SpamBlacklist;
|
||||
|
||||
use ExtensionRegistry;
|
||||
use LogPage;
|
||||
use ManualLogEntry;
|
||||
use MediaWiki\CheckUser\Hooks as CUHooks;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use ObjectCache;
|
||||
use RequestContext;
|
||||
use Title;
|
||||
use User;
|
||||
use Wikimedia\AtEase\AtEase;
|
||||
use Wikimedia\Rdbms\Database;
|
||||
|
||||
|
@ -246,7 +255,7 @@ class SpamBlacklist extends BaseBlacklist {
|
|||
// (which is the default)
|
||||
if ( ExtensionRegistry::getInstance()->isLoaded( 'CheckUser' ) ) {
|
||||
$rc = $logEntry->getRecentChange( $logid );
|
||||
Hooks::updateCheckUserData( $rc );
|
||||
CUHooks::updateCheckUserData( $rc );
|
||||
}
|
||||
} else {
|
||||
// If the log is unrestricted, publish normally to RC,
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\SpamBlacklist;
|
||||
|
||||
use LogFormatter;
|
||||
use Message;
|
||||
|
||||
class SpamBlacklistLogFormatter extends LogFormatter {
|
||||
/**
|
||||
* @return array
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\SpamBlacklist;
|
||||
|
||||
use MediaWiki\Auth\AbstractPreAuthenticationProvider;
|
||||
use StatusValue;
|
||||
|
||||
class SpamBlacklistPreAuthenticationProvider extends AbstractPreAuthenticationProvider {
|
||||
public function testForAccountCreation( $user, $creator, array $reqs ) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\SpamBlacklist;
|
||||
|
||||
use Wikimedia\AtEase\AtEase;
|
||||
|
||||
/**
|
||||
|
@ -84,7 +86,9 @@ class SpamRegexBatch {
|
|||
return array_filter(
|
||||
array_map( 'trim',
|
||||
preg_replace( '/#.*$/', '',
|
||||
$lines ) ) );
|
||||
$lines )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* If all revisions contain spam, blanks the page
|
||||
*/
|
||||
|
||||
use MediaWiki\Extension\SpamBlacklist\BaseBlacklist;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionLookup;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\Extension\SpamBlacklist\BaseBlacklist;
|
||||
|
||||
/**
|
||||
* @covers BaseBlacklist
|
||||
* @covers \MediaWiki\Extension\SpamBlacklist\BaseBlacklist
|
||||
*/
|
||||
class BaseBlacklistTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\SpamBlacklist\BaseBlacklist;
|
||||
use MediaWiki\Extension\SpamBlacklist\SpamBlacklist;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @group SpamBlacklist
|
||||
* @group Database
|
||||
* @covers SpamBlacklist
|
||||
* @covers \MediaWiki\Extension\SpamBlacklist\SpamBlacklist
|
||||
*/
|
||||
class SpamBlacklistTest extends MediaWikiIntegrationTestCase {
|
||||
/**
|
||||
|
@ -142,7 +144,7 @@ class SpamBlacklistTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// That only works if the spam blacklist is really reset
|
||||
$instance = BaseBlacklist::getInstance( 'spam' );
|
||||
$reflProp = new \ReflectionProperty( $instance, 'regexes' );
|
||||
$reflProp = new ReflectionProperty( $instance, 'regexes' );
|
||||
$reflProp->setAccessible( true );
|
||||
$reflProp->setValue( $instance, false );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue