r48856 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48855‎ | r48856 | r48857 >
Date:04:41, 26 March 2009
Author:werdna
Status:ok
Tags:
Comment:
Fix batch-testing (follow-up to r48855)
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.i18n.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.php
@@ -107,3 +107,8 @@
108108 $wgAbuseFilterUDPPrefix = 'abusefilter:';
109109 $wgAbuseFilterUDPAddress = null;
110110 $wgAbuseFilterUDPPort = null;
 111+
 112+// Centralised filters
 113+$wgAbuseFilterCentralDB = null;
 114+$wgAbuseFilterIsCentral = false;
 115+
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php
@@ -153,7 +153,9 @@
154154 'tables' => array('abuse_filter', 'abuse_filter_action'),
155155 'fields' => array(
156156 'af_id',
157 - '(af_enabled | af_deleted << 1) AS status',
 157+ 'af_enabled',
 158+ 'af_deleted',
 159+ 'af_global',
158160 'af_public_comments',
159161 'af_hidden',
160162 'af_hit_count',
@@ -220,12 +222,19 @@
221223 }
222224 return htmlspecialchars( implode( ', ', $displayActions ) );
223225 case 'status':
224 - if ($value & 2)
225 - return wfMsgExt( 'abusefilter-deleted', 'parseinline' );
226 - elseif ($value & 1)
227 - return wfMsgExt( 'abusefilter-enabled', 'parseinline' );
 226+ $statuses = array();
 227+ if ($row->af_deleted)
 228+ $statuses[] = wfMsgExt( 'abusefilter-deleted', 'parseinline' );
 229+ elseif ($row->af_enabled)
 230+ $statuses[] = wfMsgExt( 'abusefilter-enabled', 'parseinline' );
228231 else
229 - return wfMsgExt( 'abusefilter-disabled', 'parseinline' );
 232+ $statuses[] = wfMsgExt( 'abusefilter-disabled', 'parseinline' );
 233+
 234+ global $wgAbuseFilterIsCentral;
 235+ if ($row->af_global && $wgAbuseFilterIsCentral)
 236+ $statuses[] = wfMsgExt( 'abusefilter-status-global', 'parseinline' );
 237+
 238+ return $wgLang->semicolonList( $statuses );
230239 case 'af_hidden':
231240 $msg = $value ? 'abusefilter-hidden' : 'abusefilter-unhidden';
232241 return wfMsgExt( $msg, 'parseinline' );
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php
@@ -280,6 +280,10 @@
281281 // Build checkboxen
282282 $checkboxes = array( 'hidden', 'enabled', 'deleted' );
283283 $flags = '';
 284+
 285+ global $wgAbuseFilterIsCentral;
 286+ if ($wgAbuseFilterIsCentral)
 287+ $checkboxes[] = 'global';
284288
285289 if (isset($row->af_throttled) && $row->af_throttled) {
286290 global $wgAbuseFilterEmergencyDisableThreshold;
@@ -582,6 +586,7 @@
583587 $obj->af_pattern = '';
584588 $obj->af_enabled = 1;
585589 $obj->af_hidden = 0;
 590+ $obj->af_global = 0;
586591 return array( $obj, array() );
587592 }
588593
@@ -641,6 +646,8 @@
642647 $row->af_deleted = $wgRequest->getBool( 'wpFilterDeleted' );
643648 $row->af_enabled = $wgRequest->getBool( 'wpFilterEnabled' ) && !$row->af_deleted;
644649 $row->af_hidden = $wgRequest->getBool( 'wpFilterHidden' );
 650+ global $wgAbuseFilterIsCentral;
 651+ $row->af_global = $wgRequest->getBool( 'wpFilterGlobal' ) && $wgAbuseFilterIsCentral;
645652
646653 // Actions
647654 global $wgAbuseFilterAvailableActions;
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -336,14 +336,15 @@
337337 return htmlspecialchars( self::evaluateExpression( $expr ) );
338338 }
339339
340 - public static function checkConditions( $conds, $vars, $ignoreError = true ) {
 340+ public static function checkConditions( $conds, $vars, $ignoreError = true,
 341+ $keepVars = 'resetvars' ) {
341342 global $wgAbuseFilterParserClass;
342343
343344 static $parser;
344345
345346 wfProfileIn( __METHOD__ );
346347
347 - if ( is_null($parser) ) {
 348+ if ( is_null($parser) || $keepVars == 'resetvars' ) {
348349 $parser = new $wgAbuseFilterParserClass;
349350
350351 $parser->setVars( $vars );
@@ -388,7 +389,8 @@
389390
390391 // Check conditions...
391392 $pattern = trim($row->af_pattern);
392 - if ( self::checkConditions( $pattern, $vars ) ) {
 393+ if ( self::checkConditions( $pattern, $vars, true /* ignore errors */,
 394+ 'keepvars' ) ) {
393395 // Record match.
394396 $filter_matched[$row->af_id] = true;
395397 } else {
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
@@ -118,6 +118,7 @@
119119 'abusefilter-tools' => 'Abuse filter tools',
120120 'abusefilter-loglink' => 'View the abuse log',
121121 'abusefilter-return' => 'Return to filter management',
 122+ 'abusefilter-status-global' => 'Global',
122123
123124 // Options form
124125 'abusefilter-list-options' => 'Options',
@@ -204,6 +205,7 @@
205206 'abusefilter-edit-revert' => 'Revert actions taken by this filter',
206207 'abusefilter-edit-tools' => 'Tools:',
207208 'abusefilter-edit-test-link' => 'Test this filter against recent edits',
 209+ 'abusefilter-edit-global' => 'Apply this filter globally',
208210
209211 // Filter editing helpers
210212 'abusefilter-edit-builder-select' => 'Select an option to add it at the cursor',

Follow-up revisions

RevisionCommit summaryAuthorDate
r48857Remove accidentally-committed code in r48856werdna04:44, 26 March 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r48855(bug 18165) Keep the same parser object between filter runswerdna04:09, 26 March 2009

Status & tagging log