r81905 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81904‎ | r81905 | r81906 >
Date:17:25, 10 February 2011
Author:reedy
Status:resolved
Tags:
Comment:
while to foreach

Remove unused variables

Condense css
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.hooks.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilterVariableHolder.php (modified) (history)
  • /trunk/extensions/AbuseFilter/ApiQueryAbuseFilters.php (modified) (history)
  • /trunk/extensions/AbuseFilter/ApiQueryAbuseLog.php (modified) (history)
  • /trunk/extensions/AbuseFilter/abusefilter.css (modified) (history)
  • /trunk/extensions/AbuseFilter/edit.js (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -207,7 +207,7 @@
208208
209209 public static function keywordRegex( $str, $regex, $pos, $insensitive = false ) {
210210 $str = $str->toString();
211 - $pattern = $regex = $regex->toString();
 211+ $pattern = $regex->toString();
212212
213213 $pattern = preg_replace( '!(\\\\\\\\)*(\\\\)?/!', '$1\/', $pattern );
214214 $pattern = "/$pattern/u";
@@ -1279,7 +1279,6 @@
12801280 if ( preg_match( $radixRegex, $code, $matches, 0, $offset ) ) {
12811281 $input = $matches[1];
12821282 $baseChar = @$matches[2];
1283 - $num = null;
12841283 // Sometimes the base char gets mixed in with the rest of it because
12851284 // the regex targets hex, too.
12861285 // This mostly happens with binary
@@ -1378,7 +1377,7 @@
13791378 $s = $args[0]->toString();
13801379
13811380 $s = preg_replace( '/[\d\W]+/', '', $s );
1382 - $s = strtolower( $value );
 1381+ $s = strtolower( $s );
13831382 return new AFPData( AFPData::DString, $s );
13841383 }
13851384
@@ -1442,20 +1441,16 @@
14431442 );
14441443 }
14451444
1446 - $offset = -1;
1447 -
14481445 if ( count( $args ) == 1 ) {
14491446 $count = count( explode( ',', $args[0]->toString() ) );
14501447 } else {
1451 - $needle = $regex = $args[0]->toString();
 1448+ $needle = $args[0]->toString();
14521449 $haystack = $args[1]->toString();
1453 - $pos = $this->mCur->pos;
14541450
14551451 # Munge the regex
14561452 $needle = preg_replace( '!(\\\\\\\\)*(\\\\)?/!', '$1\/', $needle );
14571453 $needle = "/$needle/u";
14581454
1459 - $count = 0;
14601455 $matches = array();
14611456
14621457 try {
@@ -1554,7 +1549,6 @@
15551550 }
15561551
15571552 protected function rmspecials( $s ) {
1558 - $orig = $s;
15591553 $s = preg_replace( '/[^\p{L}\p{N}]/u', '', $s );
15601554
15611555 return $s;
Index: trunk/extensions/AbuseFilter/abusefilter.css
@@ -65,9 +65,8 @@
6666 #mw-abusefilter-syntaxresult,
6767 li.mw-abusefilter-changeslist-nomatch,
6868 li.mw-abusefilter-changeslist-match {
69 - background-repeat: no-repeat;
 69+ background: no-repeat left center;
7070 padding-left: 25px;
71 - background-position: left center;
7271 }
7372
7473 .mw-abusefilter-navigation {
Index: trunk/extensions/AbuseFilter/ApiQueryAbuseFilters.php
@@ -97,7 +97,7 @@
9898 $showhidden = $wgUser->isAllowed( 'abusefilter-modify' );
9999
100100 $count = 0;
101 - while ( $row = $res->fetchObject() ) {
 101+ foreach ( $res as $row ) {
102102 if ( ++$count > $params['limit'] ) {
103103 // We've had enough
104104 $this->setContinueEnumParameter( 'startid', $row->af_id );
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -1219,7 +1219,6 @@
12201220
12211221 // Figure out if we've triggered overflows and blocks.
12221222 $overflow_triggered = ( self::$condCount > $wgAbuseFilterConditionLimit );
1223 - $filter_triggered = count( $blocking_filters ) > 0;
12241223
12251224 // Store some keys...
12261225 $overflow_key = self::filterLimitReachedKey();
@@ -1589,9 +1588,13 @@
15901589 return $vars;
15911590 }
15921591
 1592+ /**
 1593+ * @static
 1594+ * @param $title Title
 1595+ * @return AbuseFilterVariableHolder
 1596+ */
15931597 public static function getEditVars( $title ) {
15941598 $vars = new AbuseFilterVariableHolder;
1595 - $article = new Article( $title );
15961599
15971600 $vars->setLazyLoadVar( 'edit_diff', 'diff',
15981601 array( 'oldtext-var' => 'old_wikitext', 'newtext-var' => 'new_wikitext' ) );
Index: trunk/extensions/AbuseFilter/AbuseFilterVariableHolder.php
@@ -330,7 +330,7 @@
331331 );
332332
333333 $users = array();
334 - while ( $user = $dbr->fetchRow( $res ) ) {
 334+ foreach ( $res as $user ) {
335335 $users[] = $user[0];
336336 }
337337 $result = $users;
Index: trunk/extensions/AbuseFilter/edit.js
@@ -152,7 +152,7 @@
153153 addOnloadHook( function() {
154154 addHandler( document.getElementById( wgFilterBoxName ), 'keyup', function() {
155155 el = document.getElementById( 'mw-abusefilter-syntaxresult' );
156 - if ( el.syntaxOk == true ) {
 156+ if ( el.syntaxOk ) {
157157 el.style.display = 'none';
158158 }
159159 } );
Index: trunk/extensions/AbuseFilter/ApiQueryAbuseLog.php
@@ -104,7 +104,7 @@
105105 $res = $this->select( __METHOD__ );
106106
107107 $count = 0;
108 - while ( $row = $res->fetchObject() ) {
 108+ foreach ( $res as $row ) {
109109 if ( ++$count > $params['limit'] ) {
110110 // We've had enough
111111 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->afl_timestamp ) );
Index: trunk/extensions/AbuseFilter/AbuseFilter.hooks.php
@@ -155,7 +155,7 @@
156156 array( 'abuse_filter' => array( 'INNER JOIN', 'afa_filter=af_id' ) )
157157 );
158158
159 - while ( $row = $res->fetchObject() ) {
 159+ foreach ( $res as $row ) {
160160 $emptyTags = array_filter(
161161 array_merge( explode( "\n", $row->afa_parameters ), $emptyTags )
162162 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r81958Partial revert to r81905reedy11:37, 11 February 2011
r101756* (bug 31870) Fix regression in AbuseFilter: pass/fail checkmark images for s...brion00:13, 3 November 2011
r101758MFT r101756 -- bug 31870: fix Special:Abusefilter pass/fail icons broken by r...brion00:18, 3 November 2011

Status & tagging log