MaxSem has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/370602 )
Change subject: Fix some deprecated function usage
......................................................................
Fix some deprecated function usage
Change-Id: I544cdfa75c7472f2d98b2561bc6f6f9c2d2ad639
---
M includes/api/ApiAbuseFilterCheckMatch.php
M includes/api/ApiAbuseFilterCheckSyntax.php
M includes/api/ApiAbuseFilterUnblockAutopromote.php
M includes/api/ApiQueryAbuseFilters.php
M includes/api/ApiQueryAbuseLog.php
M includes/parser/AFPData.php
6 files changed, 17 insertions(+), 80 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter
refs/changes/02/370602/1
diff --git a/includes/api/ApiAbuseFilterCheckMatch.php
b/includes/api/ApiAbuseFilterCheckMatch.php
index 60ee658..d2d4410 100644
--- a/includes/api/ApiAbuseFilterCheckMatch.php
+++ b/includes/api/ApiAbuseFilterCheckMatch.php
@@ -7,11 +7,7 @@
// "Anti-DoS"
if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) ) {
- $this->dieWithError(
'apierror-abusefilter-canttest', 'permissiondenied' );
- } else {
- $this->dieUsage( 'You don\'t have permission to
test abuse filters', 'permissiondenied' );
- }
+ $this->dieWithError( 'apierror-abusefilter-canttest',
'permissiondenied' );
}
$vars = null;
@@ -31,11 +27,7 @@
);
if ( !$row ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError( [
'apierror-nosuchrcid', $params['rcid'] ] );
- } else {
- $this->dieUsageMsg( [ 'nosuchrcid',
$params['rcid'] ] );
- }
+ $this->dieWithError( [ 'apierror-nosuchrcid',
$params['rcid'] ] );
}
$vars = AbuseFilter::getVarsFromRCRow( $row );
@@ -49,25 +41,14 @@
);
if ( !$row ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError( [
'apierror-abusefilter-nosuchlogid', $params['logid'] ], 'nosuchlogid' );
- } else {
- $this->dieUsage(
- "There is no abuselog entry
with the id ``{$params['logid']}''",
- 'nosuchlogid'
- );
- }
+ $this->dieWithError( [
'apierror-abusefilter-nosuchlogid', $params['logid'] ], 'nosuchlogid' );
}
$vars = AbuseFilter::loadVarDump( $row->afl_var_dump );
}
if ( AbuseFilter::checkSyntax( $params[ 'filter' ] ) !== true )
{
- if ( is_callable( [ $this, 'dieWithError' ] ) ) {
- $this->dieWithError(
'apierror-abusefilter-badsyntax', 'badsyntax' );
- } else {
- $this->dieUsage( 'The filter has invalid
syntax', 'badsyntax' );
- }
+ $this->dieWithError( 'apierror-abusefilter-badsyntax',
'badsyntax' );
}
$result = [
diff --git a/includes/api/ApiAbuseFilterCheckSyntax.php
b/includes/api/ApiAbuseFilterCheckSyntax.php
index 05fb699..b0ac3f7 100644
--- a/includes/api/ApiAbuseFilterCheckSyntax.php
+++ b/includes/api/ApiAbuseFilterCheckSyntax.php
@@ -5,14 +5,7 @@
public function execute() {
// "Anti-DoS"
if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) ) {
- $this->dieWithError(
'apierror-abusefilter-cantcheck', 'permissiondenied' );
- } else {
- $this->dieUsage(
- 'You don\'t have permission to check
syntax of abuse filters',
- 'permissiondenied'
- );
- }
+ $this->dieWithError( 'apierror-abusefilter-cantcheck',
'permissiondenied' );
}
$params = $this->extractRequestParams();
diff --git a/includes/api/ApiAbuseFilterUnblockAutopromote.php
b/includes/api/ApiAbuseFilterUnblockAutopromote.php
index e616dc3..5ceb17f 100644
--- a/includes/api/ApiAbuseFilterUnblockAutopromote.php
+++ b/includes/api/ApiAbuseFilterUnblockAutopromote.php
@@ -2,42 +2,23 @@
class ApiAbuseFilterUnblockAutopromote extends ApiBase {
public function execute() {
- if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) {
- $this->checkUserRightsAny( 'abusefilter-modify' );
- } else {
- if ( !$this->getUser()->isAllowed( 'abusefilter-modify'
) ) {
- $this->dieUsage( 'You do not have permissions
to unblock autopromotion', 'permissiondenied' );
- }
- }
+ $this->checkUserRightsAny( 'abusefilter-modify' );
$params = $this->extractRequestParams();
$user = User::newFromName( $params['user'] );
if ( $user === false ) {
$encParamName = $this->encodeParamName( 'user' );
- if ( is_callable( [ $this, 'dieWithError' ] ) ) {
- $this->dieWithError(
- [ 'apierror-baduser', $encParamName,
wfEscapeWikiText( $param['user'] ) ],
- "baduser_{$encParamName}"
- );
- } else {
- $this->dieUsage(
- "Invalid value '{$param['user']}' for
user parameter $encParamName",
- "baduser_{$encParamName}"
- );
- }
+ $this->dieWithError(
+ [ 'apierror-baduser', $encParamName,
wfEscapeWikiText( $param['user'] ) ],
+ "baduser_{$encParamName}"
+ );
}
$key = AbuseFilter::autoPromoteBlockKey( $user );
$stash = ObjectCache::getMainStashInstance();
if ( !$stash->get( $key ) ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) ) {
- $this->dieWithError( [
'abusefilter-reautoconfirm-none', $user->getName() ], 'notsuspended' );
- } else {
- $msg = wfMessage(
'abusefilter-reautoconfirm-none', $user->getName() )
- ->inLanguage( 'en' )->useDatabase(
false )->text();
- $this->dieUsage( $msg, 'notsuspended' );
- }
+ $this->dieWithError( [
'abusefilter-reautoconfirm-none', $user->getName() ], 'notsuspended' );
}
$stash->delete( $key );
diff --git a/includes/api/ApiQueryAbuseFilters.php
b/includes/api/ApiQueryAbuseFilters.php
index 0a6af15..7980812 100644
--- a/includes/api/ApiQueryAbuseFilters.php
+++ b/includes/api/ApiQueryAbuseFilters.php
@@ -36,13 +36,7 @@
public function execute() {
$user = $this->getUser();
- if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) {
- $this->checkUserRightsAny( 'abusefilter-view' );
- } else {
- if ( !$user->isAllowed( 'abusefilter-view' ) ) {
- $this->dieUsage( 'You don\'t have permission to
view abuse filters', 'permissiondenied' );
- }
- }
+ $this->checkUserRightsAny( 'abusefilter-view' );
$params = $this->extractRequestParams();
@@ -86,11 +80,7 @@
|| ( isset( $show['deleted'] ) && isset(
$show['!deleted'] ) )
|| ( isset( $show['private'] ) && isset(
$show['!private'] ) )
) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError( 'apierror-show' );
- } else {
- $this->dieUsageMsg( 'show' );
- }
+ $this->dieWithError( 'apierror-show' );
}
$this->addWhereIf( 'af_enabled = 0', isset(
$show['!enabled'] ) );
diff --git a/includes/api/ApiQueryAbuseLog.php
b/includes/api/ApiQueryAbuseLog.php
index f221adc..a86fbe9 100644
--- a/includes/api/ApiQueryAbuseLog.php
+++ b/includes/api/ApiQueryAbuseLog.php
@@ -39,11 +39,7 @@
$errors = $this->getTitle()->getUserPermissionsErrors(
'abusefilter-log', $user, true, [ 'ns-specialprotected'
] );
if ( count( $errors ) ) {
- if ( is_callable( [ $this, 'errorArrayToStatus' ] ) ) {
- $this->dieStatus( $this->errorArrayToStatus(
$errors ) );
- } else {
- $this->dieUsageMsg( $errors[0] );
- }
+ $this->dieStatus( $this->errorArrayToStatus( $errors )
);
return;
}
@@ -164,11 +160,7 @@
if ( !is_null( $title ) ) {
$titleObj = Title::newFromText( $title );
if ( is_null( $titleObj ) ) {
- if ( is_callable( [ $this, 'dieWithError' ] ) )
{
- $this->dieWithError( [
'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
- } else {
- $this->dieUsageMsg( [ 'invalidtitle',
$title ] );
- }
+ $this->dieWithError( [ 'apierror-invalidtitle',
wfEscapeWikiText( $title ) ] );
}
$this->addWhereFld( 'afl_namespace',
$titleObj->getNamespace() );
$this->addWhereFld( 'afl_title', $titleObj->getDBkey()
);
diff --git a/includes/parser/AFPData.php b/includes/parser/AFPData.php
index 7a9f815..d5a0069 100644
--- a/includes/parser/AFPData.php
+++ b/includes/parser/AFPData.php
@@ -205,9 +205,9 @@
public static function keywordLike( $str, $pattern ) {
$str = $str->toString();
$pattern = '#^' . strtr( preg_quote( $pattern->toString(), '#'
), self::$wildcardMap ) . '$#u';
- wfSuppressWarnings();
+ MediaWiki\suppressWarnings();
$result = preg_match( $pattern, $str );
- wfRestoreWarnings();
+ MediaWiki\restoreWarnings();
return new AFPData( self::DBOOL, (bool)$result );
}
--
To view, visit https://gerrit.wikimedia.org/r/370602
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I544cdfa75c7472f2d98b2561bc6f6f9c2d2ad639
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits