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