From de1c2af0e1c99f970d45ffbc6d86969cd4e3c58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= Date: Mon, 2 Jan 2017 11:42:06 +0000 Subject: [PATCH] Unify global filters decoding across AbuseFilter Change-Id: I3c97c24b5d0e4818b36e233a8bb3b205cbb2c7d0 --- includes/AbuseFilter.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/AbuseFilter.class.php b/includes/AbuseFilter.class.php index d2dec7e13..3686744cd 100644 --- a/includes/AbuseFilter.class.php +++ b/includes/AbuseFilter.class.php @@ -759,7 +759,7 @@ class AbuseFilter { self::getFilter( $filter )->af_public_comments ); - $global_filter = ( preg_match( '/^global-/', $filter ) == 1 ); + $global_filter = self::decodeGlobalName( $filter ) !== false; // If the filter is throttled and throttling is available via object // caching, check to see if the user has hit the throttle. @@ -995,14 +995,14 @@ class AbuseFilter { global $wgAbuseFilterCentralDB; if ( !isset( self::$filterCache[$id] ) ) { - $m = []; - if ( preg_match( '/^global-(\d+)$/', $id, $m ) ) { + $globalIndex = self::decodeGlobalName( $id ); + if ( $globalIndex ) { // Global wiki filter if ( !$wgAbuseFilterCentralDB ) { return null; // not enabled } - $id = $m[1]; + $id = $globalIndex; $lb = wfGetLB( $wgAbuseFilterCentralDB ); $dbr = $lb->getConnectionRef( DB_SLAVE, array(), $wgAbuseFilterCentralDB ); } else {