r47778 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47777‎ | r47778 | r47779 >
Date:02:33, 25 February 2009
Author:werdna
Status:ok
Tags:
Comment:
Normalise usernames before searching for them in Abuse Filter examine and test interfaces.
Modified paths:
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewExamine.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewTestBatch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewTestBatch.php
@@ -124,7 +124,7 @@
125125
126126 $this->mFilter = $wgRequest->getText( 'wpTestFilter' );
127127 $this->mShowNegative = $wgRequest->getBool( 'wpShowNegative' );
128 - $this->mTestUser = $wgRequest->getText( 'wpTestUser' );
 128+ $testUsername = $wgRequest->getText( 'wpTestUser' );
129129 $this->mTestPeriodEnd = $wgRequest->getText( 'wpTestPeriodEnd' );
130130 $this->mTestPeriodStart = $wgRequest->getText( 'wpTestPeriodStart' );
131131
@@ -137,5 +137,17 @@
138138 array( 'af_id' => $this->mParams[1] ),
139139 __METHOD__ );
140140 }
 141+
 142+ // Normalise username
 143+ $userTitle = Title::newFromText( $testUsername );
 144+
 145+ if ( $userTitle && $userTitle->getNamespace() == NS_USER )
 146+ $this->mTestUser = $userTitle->getText(); // Allow User:Blah syntax.
 147+ elseif ( $userTitle )
 148+ // Not sure of the value of prefixedText over text, but no need to munge unnecessarily.
 149+ $this->mTestUser = $userTitle->getPrefixedText();
 150+ else
 151+ $this->mTestUser = null; // No user specified.
 152+
141153 }
142154 }
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewExamine.php
@@ -203,10 +203,21 @@
204204
205205 function loadParameters() {
206206 global $wgRequest;
207 - $this->mSearchUser = $wgRequest->getText( 'wpSearchUser' );
 207+ $searchUsername = $wgRequest->getText( 'wpSearchUser' );
208208 $this->mSearchPeriodStart = $wgRequest->getText( 'wpSearchPeriodStart' );
209209 $this->mSearchPeriodEnd = $wgRequest->getText( 'wpSearchPeriodEnd' );
210210 $this->mSubmit = $wgRequest->getCheck( 'submit' );
211211 $this->mTestFilter = $wgRequest->getText( 'testfilter' );
 212+
 213+ // Normalise username
 214+ $userTitle = Title::newFromText( $searchUsername );
 215+
 216+ if ( $userTitle->getNamespace() == NS_USER )
 217+ $this->mSearchUser = $userTitle->getText(); // Allow User:Blah syntax.
 218+ elseif ( $userTitle )
 219+ // Not sure of the value of prefixedText over text, but no need to munge unnecessarily.
 220+ $this->mSearchUser = $userTitle->getPrefixedText();
 221+ else
 222+ $this->mSearchUser = '';
212223 }
213224 }

Status & tagging log