mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
Merge "Don't use wgLang and wgContLang"
This commit is contained in:
commit
e2f1880922
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset>
|
||||
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
|
||||
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgContLang" />
|
||||
</rule>
|
||||
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" />
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<exclude-pattern>AbuseFilter\.alias\.php</exclude-pattern>
|
||||
</rule>
|
||||
|
|
|
@ -3073,11 +3073,10 @@ class AbuseFilter {
|
|||
/**
|
||||
* @param string $action
|
||||
* @param string[] $parameters
|
||||
* @param Language $lang
|
||||
* @return string
|
||||
*/
|
||||
public static function formatAction( $action, $parameters ) {
|
||||
/** @var $wgLang Language */
|
||||
global $wgLang;
|
||||
public static function formatAction( $action, $parameters, $lang ) {
|
||||
if ( count( $parameters ) === 0 ||
|
||||
( $action === 'block' && count( $parameters ) !== 3 ) ) {
|
||||
$displayAction = self::getActionDisplay( $action );
|
||||
|
@ -3087,15 +3086,15 @@ class AbuseFilter {
|
|||
$messages = [
|
||||
wfMessage( 'abusefilter-block-anon' )->escaped() .
|
||||
wfMessage( 'colon-separator' )->escaped() .
|
||||
$wgLang->translateBlockExpiry( $parameters[1] ),
|
||||
$lang->translateBlockExpiry( $parameters[1] ),
|
||||
wfMessage( 'abusefilter-block-user' )->escaped() .
|
||||
wfMessage( 'colon-separator' )->escaped() .
|
||||
$wgLang->translateBlockExpiry( $parameters[2] )
|
||||
$lang->translateBlockExpiry( $parameters[2] )
|
||||
];
|
||||
if ( $parameters[0] === 'blocktalk' ) {
|
||||
$messages[] = wfMessage( 'abusefilter-block-talk' )->escaped();
|
||||
}
|
||||
$displayAction = $wgLang->commaList( $messages );
|
||||
$displayAction = $lang->commaList( $messages );
|
||||
} elseif ( $action === 'throttle' ) {
|
||||
array_shift( $parameters );
|
||||
list( $actions, $time ) = explode( ',', array_shift( $parameters ) );
|
||||
|
@ -3122,14 +3121,14 @@ class AbuseFilter {
|
|||
$group = $msg->exists() ? $msg->text() : $group;
|
||||
}
|
||||
unset( $group );
|
||||
$val = $wgLang->listToText( $subGroups );
|
||||
$val = $lang->listToText( $subGroups );
|
||||
} else {
|
||||
$msg = wfMessage( "abusefilter-throttle-$val" );
|
||||
$val = $msg->exists() ? $msg->text() : $val;
|
||||
}
|
||||
}
|
||||
unset( $val );
|
||||
$groups = $wgLang->semicolonList( $parameters );
|
||||
$groups = $lang->semicolonList( $parameters );
|
||||
}
|
||||
$displayAction = self::getActionDisplay( $action ) .
|
||||
wfMessage( 'colon-separator' )->escaped() .
|
||||
|
@ -3137,7 +3136,7 @@ class AbuseFilter {
|
|||
} else {
|
||||
$displayAction = self::getActionDisplay( $action ) .
|
||||
wfMessage( 'colon-separator' )->escaped() .
|
||||
$wgLang->semicolonList( array_map( 'htmlspecialchars', $parameters ) );
|
||||
$lang->semicolonList( array_map( 'htmlspecialchars', $parameters ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3146,18 +3145,17 @@ class AbuseFilter {
|
|||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param Language $lang
|
||||
* @return string
|
||||
*/
|
||||
public static function formatFlags( $value ) {
|
||||
/** @var $wgLang Language */
|
||||
global $wgLang;
|
||||
public static function formatFlags( $value, $lang ) {
|
||||
$flags = array_filter( explode( ',', $value ) );
|
||||
$flags_display = [];
|
||||
foreach ( $flags as $flag ) {
|
||||
$flags_display[] = wfMessage( "abusefilter-history-$flag" )->escaped();
|
||||
}
|
||||
|
||||
return $wgLang->commaList( $flags_display );
|
||||
return $lang->commaList( $flags_display );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -311,8 +311,8 @@ class AbuseFilterViewDiff extends AbuseFilterView {
|
|||
}
|
||||
$info .= $this->getDiffRow(
|
||||
'abusefilter-edit-flags',
|
||||
AbuseFilter::formatFlags( $oldVersion['info']['flags'] ),
|
||||
AbuseFilter::formatFlags( $newVersion['info']['flags'] )
|
||||
AbuseFilter::formatFlags( $oldVersion['info']['flags'], $this->getLanguage() ),
|
||||
AbuseFilter::formatFlags( $newVersion['info']['flags'], $this->getLanguage() )
|
||||
);
|
||||
|
||||
$info .= $this->getDiffRow(
|
||||
|
@ -374,7 +374,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
|
|||
|
||||
ksort( $actions );
|
||||
foreach ( $actions as $action => $parameters ) {
|
||||
$lines[] = AbuseFilter::formatAction( $action, $parameters );
|
||||
$lines[] = AbuseFilter::formatAction( $action, $parameters, $this->getLanguage() );
|
||||
}
|
||||
|
||||
if ( !count( $lines ) ) {
|
||||
|
|
|
@ -89,7 +89,7 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
$formatted = htmlspecialchars( $value, ENT_QUOTES, 'UTF-8', false );
|
||||
break;
|
||||
case 'afh_flags':
|
||||
$formatted = AbuseFilter::formatFlags( $value );
|
||||
$formatted = AbuseFilter::formatFlags( $value, $lang );
|
||||
break;
|
||||
case 'afh_actions':
|
||||
$actions = unserialize( $value );
|
||||
|
@ -97,7 +97,7 @@ class AbuseFilterHistoryPager extends TablePager {
|
|||
$display_actions = '';
|
||||
|
||||
foreach ( $actions as $action => $parameters ) {
|
||||
$displayAction = AbuseFilter::formatAction( $action, $parameters );
|
||||
$displayAction = AbuseFilter::formatAction( $action, $parameters, $lang );
|
||||
$display_actions .= Xml::tags( 'li', null, $displayAction );
|
||||
}
|
||||
$display_actions = Xml::tags( 'ul', null, $display_actions );
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Wikimedia\Equivset\Equivset;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
class AbuseFilterParser {
|
||||
public $mTokens, $mPos, $mShortCircuit, $mAllowShort;
|
||||
|
@ -899,11 +900,11 @@ class AbuseFilterParser {
|
|||
* @return AFPData
|
||||
*/
|
||||
protected function funcLc( $args ) {
|
||||
global $wgContLang;
|
||||
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
||||
$this->checkEnoughArguments( $args, 'lc', 1 );
|
||||
$s = $args[0]->toString();
|
||||
|
||||
return new AFPData( AFPData::DSTRING, $wgContLang->lc( $s ) );
|
||||
return new AFPData( AFPData::DSTRING, $contLang->lc( $s ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -911,11 +912,11 @@ class AbuseFilterParser {
|
|||
* @return AFPData
|
||||
*/
|
||||
protected function funcUc( $args ) {
|
||||
global $wgContLang;
|
||||
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
||||
$this->checkEnoughArguments( $args, 'uc', 1 );
|
||||
$s = $args[0]->toString();
|
||||
|
||||
return new AFPData( AFPData::DSTRING, $wgContLang->uc( $s ) );
|
||||
return new AFPData( AFPData::DSTRING, $contLang->uc( $s ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1331,7 +1331,6 @@ class AbuseFilterTest extends MediaWikiTestCase {
|
|||
* @dataProvider provideEditVars
|
||||
*/
|
||||
public function testGetEditVars( $oldText, $newText ) {
|
||||
global $wgLang;
|
||||
self::$mTitle = Title::makeTitle( 0, 'AbuseFilter test' );
|
||||
self::$mPage = WikiPage::factory( self::$mTitle );
|
||||
|
||||
|
@ -1379,7 +1378,7 @@ class AbuseFilterTest extends MediaWikiTestCase {
|
|||
$this->assertCount(
|
||||
0,
|
||||
$differences,
|
||||
'The following AbuseFilter variables are computed wrongly: ' . $wgLang->commaList( $differences )
|
||||
'The following AbuseFilter variables are computed wrongly: ' . implode( ', ', $differences )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue