From 9823d78e3b347199c85188fd2a580f9f35aadcef Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Tue, 2 Jul 2013 03:55:53 +0200 Subject: [PATCH] Make AbuseFilter work without AntiSpoof This dependency isn't really needed in many cases while it can cause troubles if not fulfilled. Change-Id: I9990e99c4d3d49b5bc400bbc4a0ec02142d6f055 --- AbuseFilter.parser.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/AbuseFilter.parser.php b/AbuseFilter.parser.php index 601c8bd00..13c542836 100644 --- a/AbuseFilter.parser.php +++ b/AbuseFilter.parser.php @@ -1926,13 +1926,21 @@ class AbuseFilterParser { * @return mixed */ protected function ccnorm( $s ) { - static $equivset = null; static $replacementArray = null; - if ( is_null( $equivset ) || is_null( $replacementArray ) ) { + if ( is_null( $replacementArray ) ) { global $IP; - require_once( "$IP/extensions/AntiSpoof/equivset.php" ); - $replacementArray = new ReplacementArray( $equivset ); + if ( is_readable( "$IP/extensions/AntiSpoof/equivset.php" ) ) { + require "$IP/extensions/AntiSpoof/equivset.php"; + $replacementArray = new ReplacementArray( $equivset ); + } else { + // AntiSpoof isn't available, so just create a dummy + wfDebugLog( + 'AbuseFilter', + "Can't compute normalized string (ccnorm) as the AntiSpoof Extension isn't isntalled." + ); + $replacementArray = new ReplacementArray( array() ); + } } return $replacementArray->replace( $s );