r37938 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37937‎ | r37938 | r37939 >
Date:08:15, 23 July 2008
Author:brion
Status:old
Tags:
Comment:
Revert r37932, r37933 -- this is just downright bizarre. o_O

Format the list as a *list*. There's no need for multiple messages with different numbers of parameters!

Also use the {{PLURAL:}} parser function where necessary, rather than creating separate messages for "account" and "accounts" etc.
Modified paths:
  • /trunk/extensions/AntiSpoof/AntiSpoof.i18n.php (modified) (history)
  • /trunk/extensions/AntiSpoof/AntiSpoof.php (modified) (history)
  • /trunk/extensions/AntiSpoof/SpoofUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AntiSpoof/AntiSpoof.i18n.php
@@ -9,13 +9,8 @@
1010
1111 $messages['en'] = array(
1212 'antispoof-desc' => 'Blocks the creation of accounts with mixed-script, confusing and similar usernames',
13 - 'antispoof-name-conflict' => 'The name "$1" is too similar to existing $2.
 13+ 'antispoof-name-conflict' => 'The name "$1" is too similar to the existing account "$2".
1414 Please choose another name.',
15 - 'antispoof-name-conflict1' => 'account: "$1"',
16 - 'antispoof-name-conflict2' => 'accounts: "$1", "$2"',
17 - 'antispoof-name-conflict3' => 'accounts: "$1", "$2", "$3"',
18 - 'antispoof-name-conflict4' => 'accounts: "$1", "$2", "$3", "$4"',
19 - 'antispoof-name-conflict5' => 'accounts: "$1", "$2", "$3", "$4", "$5"',
2015 'antispoof-name-illegal' => 'The name "$1" is not allowed to prevent confusing or spoofed usernames: $2.
2116 Please choose another name.',
2217 'antispoof-badtype' => 'Bad data type',
Index: trunk/extensions/AntiSpoof/AntiSpoof.php
@@ -85,34 +85,9 @@
8686 if( $conflict === false ) {
8787 wfDebugLog( 'antispoof', "{$mode}PASS new account '$name' [$normalized]" );
8888 } else {
89 - wfDebugLog( 'antispoof', "{$mode}CONFLICT new account '$name' [$normalized] spoofs: '" . implode( ', ', $conflict ) . "'" );
 89+ wfDebugLog( 'antispoof', "{$mode}CONFLICT new account '$name' [$normalized] spoofs '$conflict'" );
9090 if( $active ) {
91 - $numConflicts = count( $conflict );
92 - switch ( $numConflicts ) {
93 - case 1:
94 - $message = wfMsg( 'antispoof-name-conflict', $name,
95 - wfMsg( 'antispoof-name-conflict1', $conflict['0'] ) );
96 - break;
97 - case 2:
98 - $message = wfMsg( 'antispoof-name-conflict', $name,
99 - wfMsg( 'antispoof-name-conflict2', $conflict['0'], $conflict['1'] ) );
100 - break;
101 - case 3:
102 - $message = wfMsg( 'antispoof-name-conflict', $name,
103 - wfMsg( 'antispoof-name-conflict3', $conflict['0'], $conflict['1'], $conflict['2'] ) );
104 - break;
105 - case 4:
106 - $message = wfMsg( 'antispoof-name-conflict', $name,
107 - wfMsg( 'antispoof-name-conflict4', $conflict['0'], $conflict['1'],
108 - $conflict['2'], $conflict['3'] ) );
109 - break;
110 - case 5:
111 - $message = wfMsg( 'antispoof-name-conflict', $name,
112 - wfMsg( 'antispoof-name-conflict5', $conflict['0'], $conflict['1'], $conflict['2'],
113 - $conflict['3'], $conflict['4'] ) );
114 - break;
115 - }
116 -
 91+ $message = wfMsg( 'antispoof-name-conflict', $name, $conflict );
11792 return false;
11893 }
11994 }
Index: trunk/extensions/AntiSpoof/SpoofUser.php
@@ -39,7 +39,7 @@
4040 /**
4141 * Does the username pass Unicode legality and script-mixing checks?
4242 *
43 - * @return mixed false if no conflict, or array with up to five conflicting usernames
 43+ * @return mixed false if no conflict, or string with conflicting username
4444 */
4545 public function getConflict() {
4646 if( $this->isLegal() ) {
@@ -47,26 +47,17 @@
4848
4949 // Join against the user table to ensure that we skip stray
5050 // entries left after an account is renamed or otherwise munged.
51 - $spoofedUsers = $dbr->select(
 51+ $row = $dbr->selectRow(
5252 array( 'spoofuser', 'user' ),
5353 array( 'user_name' ),
5454 array(
5555 'su_normalized' => $this->mNormalized,
5656 'su_name=user_name',
5757 ),
58 - __METHOD__,
59 - array(
60 - 'LIMIT' => 5
61 - ) );
 58+ __METHOD__ );
6259
63 - $spoofs = array();
64 -
65 - while( $row = $dbr->fetchObject( $spoofedUsers ) ) {
66 - array_push( $spoofs, $row->user_name );
67 - }
68 -
69 - if( count( $spoofs ) > 0 ) {
70 - return $spoofs;
 60+ if( $row ) {
 61+ return $row->user_name;
7162 } else {
7263 return false;
7364 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r37932Try again at bug 12232 - Return more than one result on attempted spoofing....sql03:39, 23 July 2008
r37933Put requests inside double quotes, as OverlordQ pointed out to me a few secon...sql04:02, 23 July 2008

Status & tagging log