r102197 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102196‎ | r102197 | r102198 >
Date:21:05, 6 November 2011
Author:cryptocoryne
Status:ok
Tags:
Comment:
Followup r102138 -- fixes according to Werdna's comment
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.php
@@ -167,4 +167,5 @@
168168 // Block duration
169169 $wgAbuseFilterBlockDuration = 'indefinite';
170170
171 -$wgAbuseFilterCustomActionsHandlers = false;
\ No newline at end of file
 171+// Callback functions for custom actions
 172+$wgAbuseFilterCustomActionsHandlers = array();
\ No newline at end of file
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -1075,19 +1075,17 @@
10761076 AbuseFilter::$tagsToSet[$actionID] = $parameters;
10771077 break;
10781078 default:
1079 - if( is_array( $wgAbuseFilterCustomActionsHandlers ) &&
1080 - in_array( $action, array_keys( $wgAbuseFilterCustomActionsHandlers ) ) )
1081 - {
 1079+ if( isset( $wgAbuseFilterCustomActionsHandlers[$action] ) ) {
10821080 $custom_function = $wgAbuseFilterCustomActionsHandlers[$action];
10831081 if( is_callable( $custom_function ) ) {
1084 - $ok = call_user_func( $custom_function, $action, $parameters, $title, $vars, $rule_desc );
 1082+ $msg = call_user_func( $custom_function, $action, $parameters, $title, $vars, $rule_desc );
10851083 }
1086 - if( $ok ) {
1087 - $display .= wfMsgExt( 'abusefilter-' . $action, 'parseinline', array() ) . "<br />\n";
 1084+ if( isset( $msg ) ) {
 1085+ $display .= wfMsgExt( $msg, 'parseinline', array() ) . "<br />\n";
10881086 }
1089 - break;
 1087+ } else {
 1088+ wfDebugLog( 'AbuseFilter', "Unrecognised action $action" );
10901089 }
1091 - wfDebugLog( 'AbuseFilter', "Unrecognised action $action" );
10921090 }
10931091
10941092 return $display;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102138Allow to define custom actions and their callback functionscryptocoryne01:15, 6 November 2011

Status & tagging log